From 56a2006fd8f370faa5242ec2c260d7e394521a35 Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Fri, 6 Apr 2012 18:44:31 -0700 Subject: [PATCH] Reconfigured to run on the real PipX board. --- .../Modules/RadioComBridge/RadioComBridge.c | 22 ++++++++++++++++--- .../PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h | 11 +++------- .../board_hw_defs/pipxtreme/board_hw_defs.c | 8 +++---- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index b5400098e..b19f3ffbf 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -190,14 +190,24 @@ static void com2RadioBridgeTask(void * parameters) uint32_t rx_bytes = 0; portTickType packet_start_time = 0; uint32_t timeout = 500; + uint32_t inputPort; /* Handle usart/usb -> radio direction */ while (1) { +#if defined(PIOS_INCLUDE_USB) + // Determine input port (USB takes priority over telemetry port) + if (PIOS_USB_CheckAvailable(0) && PIOS_COM_TELEM_USB) { + inputPort = PIOS_COM_TELEM_USB; + } else +#endif /* PIOS_INCLUDE_USB */ + { + inputPort = data->com_port; + } // Receive data from the com port //debug_msg = "COM receive"; - uint32_t cur_rx_bytes = PIOS_COM_ReceiveBuffer(data->com_port, data->com2radio_buf + - rx_bytes, BRIDGE_BUF_LEN - rx_bytes, timeout); + uint32_t cur_rx_bytes = PIOS_COM_ReceiveBuffer(inputPort, data->com2radio_buf + + rx_bytes, BRIDGE_BUF_LEN - rx_bytes, timeout); //debug_msg = "COM receive done"; rx_bytes += cur_rx_bytes; @@ -265,7 +275,13 @@ static void com2RadioBridgeTask(void * parameters) */ static int32_t transmitData(uint8_t *buf, int32_t length) { - return PIOS_COM_SendBuffer(data->com_port, buf, length); + uint32_t inputPort = data->com_port; +#if defined(PIOS_INCLUDE_USB) + // Determine input port (USB takes priority over telemetry port) + if (PIOS_USB_CheckAvailable(0) && PIOS_COM_TELEM_USB) + inputPort = PIOS_COM_TELEM_USB; +#endif /* PIOS_INCLUDE_USB */ + return PIOS_COM_SendBuffer(inputPort, buf, length); } /** diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index 8d421a8dd..6d6e11d0e 100755 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -160,14 +160,9 @@ extern uint32_t pios_com_rfm22b_id; #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id) #define PIOS_COM_VCP_USB (pios_com_vcp_usb_id) #define PIOS_COM_RFM22B_RF (pios_com_rfm22b_id) -/* -#define PIOS_COM_DEBUG PIOS_COM_TELEM_SERIAL -#define PIOS_COM_BRIDGE_COM PIOS_COM_TELEM_USB -*/ -#define PIOS_COM_DEBUG PIOS_COM_FLEXI -#define PIOS_COM_BRIDGE_COM PIOS_COM_TELEM_SERIAL -//#define PIOS_COM_BRIDGE_COM PIOS_COM_FLEXI -#define PIOS_COM_BRIDGE_RADIO PIOS_COM_RFM22B_RF +#define PIOS_COM_BRIDGE_RADIO PIOS_COM_RFM22B_RF +#define PIOS_COM_DEBUG PIOS_COM_FLEXI +#define PIOS_COM_BRIDGE_COM PIOS_COM_TELEM_SERIAL #define DEBUG_LEVEL 2 #if DEBUG_LEVEL > 0 diff --git a/flight/board_hw_defs/pipxtreme/board_hw_defs.c b/flight/board_hw_defs/pipxtreme/board_hw_defs.c index 3db021079..dcf7d7501 100644 --- a/flight/board_hw_defs/pipxtreme/board_hw_defs.c +++ b/flight/board_hw_defs/pipxtreme/board_hw_defs.c @@ -6,11 +6,11 @@ static const struct pios_led pios_leds[] = { [PIOS_LED_USB] = { .pin = { - //.gpio = GPIOA, - .gpio = GPIOC, + .gpio = GPIOA, + //.gpio = GPIOC, .init = { - //.GPIO_Pin = GPIO_Pin_3, - .GPIO_Pin = GPIO_Pin_13, + .GPIO_Pin = GPIO_Pin_3, + //.GPIO_Pin = GPIO_Pin_13, .GPIO_Mode = GPIO_Mode_Out_PP, .GPIO_Speed = GPIO_Speed_50MHz, },