mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Working PipX com relay.
This commit is contained in:
parent
444150269a
commit
d73895de7d
@ -104,9 +104,8 @@ static int32_t RadioComBridgeInitialize(void)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// TODO: Get from settings object
|
// TODO: Get from settings object
|
||||||
//data->com_port = PIOS_COM_VCP;
|
|
||||||
data->com_port = PIOS_COM_TELEM_USB;
|
data->com_port = PIOS_COM_TELEM_USB;
|
||||||
data->radio_port = PIOS_COM_TELEM_SERIAL;
|
data->radio_port = PIOS_COM_RFM22B_RF;
|
||||||
|
|
||||||
data->radio2com_buf = pvPortMalloc(BRIDGE_BUF_LEN);
|
data->radio2com_buf = pvPortMalloc(BRIDGE_BUF_LEN);
|
||||||
PIOS_Assert(data->radio2com_buf);
|
PIOS_Assert(data->radio2com_buf);
|
||||||
@ -150,7 +149,6 @@ static void com2RadioBridgeTask(void * parameters)
|
|||||||
|
|
||||||
rx_bytes = PIOS_COM_ReceiveBuffer(data->com_port, data->com2radio_buf, BRIDGE_BUF_LEN, 500);
|
rx_bytes = PIOS_COM_ReceiveBuffer(data->com_port, data->com2radio_buf, BRIDGE_BUF_LEN, 500);
|
||||||
if (rx_bytes > 0) {
|
if (rx_bytes > 0) {
|
||||||
PIOS_COM_SendString(PIOS_COM_TELEM_SERIAL, "Rec com\n\r");
|
|
||||||
/* Bytes available to transfer */
|
/* Bytes available to transfer */
|
||||||
if (PIOS_COM_SendBuffer(data->radio_port, data->com2radio_buf, rx_bytes) != rx_bytes) {
|
if (PIOS_COM_SendBuffer(data->radio_port, data->com2radio_buf, rx_bytes) != rx_bytes) {
|
||||||
/* Error on transmit */
|
/* Error on transmit */
|
||||||
|
@ -147,20 +147,19 @@ extern uint32_t pios_i2c_flexi_adapter_id;
|
|||||||
//
|
//
|
||||||
// See also pios_board.c
|
// See also pios_board.c
|
||||||
//-------------------------
|
//-------------------------
|
||||||
#define PIOS_COM_MAX_DEVS 4
|
#define PIOS_COM_MAX_DEVS 5
|
||||||
|
|
||||||
extern uint32_t pios_com_telem_usb_id;
|
extern uint32_t pios_com_telem_usb_id;
|
||||||
extern uint32_t pios_com_vcp_usb_id;
|
extern uint32_t pios_com_vcp_usb_id;
|
||||||
extern uint32_t pios_com_usart1_id;
|
extern uint32_t pios_com_usart1_id;
|
||||||
extern uint32_t pios_com_usart2_id;
|
|
||||||
extern uint32_t pios_com_usart3_id;
|
extern uint32_t pios_com_usart3_id;
|
||||||
extern uint32_t pios_com_rfm22b_id;
|
extern uint32_t pios_com_rfm22b_id;
|
||||||
#define PIOS_COM_TELEM_SERIAL (pios_com_usart1_id)
|
#define PIOS_COM_TELEM_SERIAL (pios_com_usart1_id)
|
||||||
#define PIOS_COM_DEBUG (pios_com_usart2_id)
|
|
||||||
#define PIOS_COM_FLEXI (pios_com_usart3_id)
|
#define PIOS_COM_FLEXI (pios_com_usart3_id)
|
||||||
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
|
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
|
||||||
#define PIOS_COM_VCP_USB (pios_com_vcp_usb_id)
|
#define PIOS_COM_VCP_USB (pios_com_vcp_usb_id)
|
||||||
#define PIOS_COM_RFM22B_RF (pios_com_rfm22b_id)
|
#define PIOS_COM_RFM22B_RF (pios_com_rfm22b_id)
|
||||||
|
#define PIOS_COM_DEBUG PIOS_COM_TELEM_SERIAL
|
||||||
|
|
||||||
//------------------------
|
//------------------------
|
||||||
// PIOS_RCVR
|
// PIOS_RCVR
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include <pios_rfm22b_priv.h>
|
#include <pios_rfm22b_priv.h>
|
||||||
|
|
||||||
|
#define OUTPUT_COM PIOS_COM_FLEXI
|
||||||
|
|
||||||
/* Provide a COM driver */
|
/* Provide a COM driver */
|
||||||
static void PIOS_RFM22B_ChangeBaud(uint32_t rfm22b_id, uint32_t baud);
|
static void PIOS_RFM22B_ChangeBaud(uint32_t rfm22b_id, uint32_t baud);
|
||||||
static void PIOS_RFM22B_RegisterRxCallback(uint32_t rfm22b_id, pios_com_callback rx_in_cb, uint32_t context);
|
static void PIOS_RFM22B_RegisterRxCallback(uint32_t rfm22b_id, pios_com_callback rx_in_cb, uint32_t context);
|
||||||
@ -139,10 +141,8 @@ static void PIOS_RFM22B_RxStart(uint32_t rfm22b_id, uint16_t rx_bytes_avail)
|
|||||||
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
||||||
PIOS_Assert(valid);
|
PIOS_Assert(valid);
|
||||||
|
|
||||||
#ifdef NEVER
|
|
||||||
RFM22B_ITConfig(rfm22b_dev->cfg->regs, RFM22B_IT_RXNE, ENABLE);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIOS_RFM22B_TxStart(uint32_t rfm22b_id, uint16_t tx_bytes_avail)
|
static void PIOS_RFM22B_TxStart(uint32_t rfm22b_id, uint16_t tx_bytes_avail)
|
||||||
{
|
{
|
||||||
struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||||
@ -150,9 +150,18 @@ static void PIOS_RFM22B_TxStart(uint32_t rfm22b_id, uint16_t tx_bytes_avail)
|
|||||||
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
||||||
PIOS_Assert(valid);
|
PIOS_Assert(valid);
|
||||||
|
|
||||||
#ifdef NEVER
|
bool need_yield = false;
|
||||||
RFM22B_ITConfig(rfm22b_dev->cfg->regs, RFM22B_IT_TXE, ENABLE);
|
if (rfm22b_dev->tx_out_cb) {
|
||||||
#endif
|
uint8_t buf[16];
|
||||||
|
uint16_t bytes_to_send = (rfm22b_dev->tx_out_cb)(rfm22b_dev->tx_out_context, buf, 16, NULL, &need_yield);
|
||||||
|
if(bytes_to_send > 0)
|
||||||
|
PIOS_COM_SendBuffer(OUTPUT_COM, buf, bytes_to_send);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||||
|
if (need_yield)
|
||||||
|
vPortYieldFromISR();
|
||||||
|
#endif /* PIOS_INCLUDE_FREERTOS */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,23 +176,10 @@ static void PIOS_RFM22B_ChangeBaud(uint32_t rfm22b_id, uint32_t baud)
|
|||||||
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
||||||
PIOS_Assert(valid);
|
PIOS_Assert(valid);
|
||||||
|
|
||||||
#ifdef NEVER
|
|
||||||
RFM22B_InitTypeDef RFM22B_InitStructure;
|
|
||||||
|
|
||||||
/* Start with a copy of the default configuration for the peripheral */
|
|
||||||
RFM22B_InitStructure = rfm22b_dev->cfg->init;
|
|
||||||
|
|
||||||
/* Adjust the baud rate */
|
|
||||||
RFM22B_InitStructure.RFM22B_BaudRate = baud;
|
|
||||||
|
|
||||||
/* Write back the new configuration */
|
|
||||||
RFM22B_Init(rfm22b_dev->cfg->regs, &RFM22B_InitStructure);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIOS_RFM22B_RegisterRxCallback(uint32_t rfm22b_id, pios_com_callback rx_in_cb, uint32_t context)
|
static void PIOS_RFM22B_RegisterRxCallback(uint32_t rfm22b_id, pios_com_callback rx_in_cb, uint32_t context)
|
||||||
{
|
{
|
||||||
#ifdef NEVER
|
|
||||||
struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||||
|
|
||||||
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
||||||
@ -195,12 +191,10 @@ static void PIOS_RFM22B_RegisterRxCallback(uint32_t rfm22b_id, pios_com_callback
|
|||||||
*/
|
*/
|
||||||
rfm22b_dev->rx_in_context = context;
|
rfm22b_dev->rx_in_context = context;
|
||||||
rfm22b_dev->rx_in_cb = rx_in_cb;
|
rfm22b_dev->rx_in_cb = rx_in_cb;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIOS_RFM22B_RegisterTxCallback(uint32_t rfm22b_id, pios_com_callback tx_out_cb, uint32_t context)
|
static void PIOS_RFM22B_RegisterTxCallback(uint32_t rfm22b_id, pios_com_callback tx_out_cb, uint32_t context)
|
||||||
{
|
{
|
||||||
#ifdef NEVER
|
|
||||||
struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
struct pios_rfm22b_dev * rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||||
|
|
||||||
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
bool valid = PIOS_RFM22B_validate(rfm22b_dev);
|
||||||
@ -212,7 +206,6 @@ static void PIOS_RFM22B_RegisterTxCallback(uint32_t rfm22b_id, pios_com_callback
|
|||||||
*/
|
*/
|
||||||
rfm22b_dev->tx_out_context = context;
|
rfm22b_dev->tx_out_context = context;
|
||||||
rfm22b_dev->tx_out_cb = tx_out_cb;
|
rfm22b_dev->tx_out_cb = tx_out_cb;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIOS_RFM22B_Timer_Callback(uint32_t dev_id) {
|
static void PIOS_RFM22B_Timer_Callback(uint32_t dev_id) {
|
||||||
@ -224,13 +217,21 @@ static void PIOS_RFM22B_Timer_Callback(uint32_t dev_id) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool need_yield = false;
|
||||||
|
if (rfm22b_dev->rx_in_cb) {
|
||||||
|
uint8_t buf[16];
|
||||||
|
uint32_t rx_bytes = PIOS_COM_ReceiveBuffer(OUTPUT_COM, buf, 16, 0);
|
||||||
|
|
||||||
|
if (rx_bytes > 0)
|
||||||
|
(rfm22b_dev->rx_in_cb)(rfm22b_dev->rx_in_context, buf, rx_bytes, NULL, &need_yield);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RTC runs at 625Hz.
|
* RTC runs at 625Hz.
|
||||||
*/
|
*/
|
||||||
if(--rfm22b_dev->countdown_timer > 0)
|
if(--rfm22b_dev->countdown_timer > 0)
|
||||||
return;
|
return;
|
||||||
rfm22b_dev->countdown_timer = (uint32_t)((float)(rfm22b_dev->cfg->send_timeout) / 0.625);
|
rfm22b_dev->countdown_timer = (uint32_t)((float)(rfm22b_dev->cfg->send_timeout) / 0.625);
|
||||||
PIOS_COM_SendString(PIOS_COM_TELEM_SERIAL, "Hello Telem\n\r");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -613,7 +613,6 @@ uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE];
|
|||||||
uint32_t pios_com_telem_usb_id;
|
uint32_t pios_com_telem_usb_id;
|
||||||
uint32_t pios_com_vcp_usb_id;
|
uint32_t pios_com_vcp_usb_id;
|
||||||
uint32_t pios_com_usart1_id;
|
uint32_t pios_com_usart1_id;
|
||||||
uint32_t pios_com_usart2_id;
|
|
||||||
uint32_t pios_com_usart3_id;
|
uint32_t pios_com_usart3_id;
|
||||||
uint32_t pios_com_rfm22b_id;
|
uint32_t pios_com_rfm22b_id;
|
||||||
|
|
||||||
@ -820,24 +819,6 @@ void PIOS_Board_Init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure USART2 */
|
|
||||||
{
|
|
||||||
uint32_t pios_usart2_id;
|
|
||||||
if (PIOS_USART_Init(&pios_usart2_id, &pios_usart_usart2_cfg)) {
|
|
||||||
PIOS_Assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
|
|
||||||
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
|
|
||||||
PIOS_Assert(rx_buffer);
|
|
||||||
PIOS_Assert(tx_buffer);
|
|
||||||
if (PIOS_COM_Init(&pios_com_usart2_id, &pios_usart_com_driver, pios_usart2_id,
|
|
||||||
rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN,
|
|
||||||
tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) {
|
|
||||||
PIOS_Assert(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure USART3 */
|
/* Configure USART3 */
|
||||||
{
|
{
|
||||||
uint32_t pios_usart3_id;
|
uint32_t pios_usart3_id;
|
||||||
@ -872,10 +853,7 @@ void PIOS_Board_Init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PIOS_INCLUDE_RFM22B */
|
#endif /* PIOS_INCLUDE_RFM22B */
|
||||||
PIOS_COM_SendString(PIOS_COM_TELEM_SERIAL, "Hello Telem\n\r");
|
PIOS_COM_SendString(PIOS_COM_DEBUG, "Hello DEBUG\n\r");
|
||||||
PIOS_COM_SendString(PIOS_COM_DEBUG, "Hello Debug\n\r");
|
|
||||||
PIOS_COM_SendString(PIOS_COM_FLEXI, "Hello Flexi\n\r");
|
|
||||||
PIOS_COM_SendString(PIOS_COM_RFM22B_RF, "Hello RMF22B\n\r");
|
|
||||||
|
|
||||||
/* Remap AFIO pin */
|
/* Remap AFIO pin */
|
||||||
GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE);
|
GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user