1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

usart: serial telemetry can be disabled to free USART

It was tested being merged with OP-472_CorvusCorax_CopterControl-Guidance_v3
branch, Spektrum on USART3 and GPS on USART1 and seems to work.

Currently defaults mimic original behavior, that is, if USE_SPEKTRUM
is not defined - define USE_PWM and USE_GPS. Thsi should be refactored
later to make it configurable from the Makefile.

Also it was not ported to the OP MB: it currently does not support the
S.Bus hardware and still has original behavior with the patch. But this
is one more step to dynamic configuration of ports.
This commit is contained in:
Oleg Semyonov 2011-06-16 15:06:01 +03:00
parent 50e819192b
commit aeda61d252
3 changed files with 14 additions and 3 deletions

View File

@ -55,9 +55,11 @@
* and optionally define PIOS_PORT_* to USART port numbers * and optionally define PIOS_PORT_* to USART port numbers
*/ */
/* Current defaults */ /* Current defaults - mimic original behavior */
#define USE_TELEMETRY #define USE_TELEMETRY
#if !defined(USE_SPEKTRUM)
#define USE_GPS #define USE_GPS
#endif
/* Serial telemetry: USART1 or USART3 */ /* Serial telemetry: USART1 or USART3 */
#if !defined(PIOS_PORT_TELEMETRY) #if !defined(PIOS_PORT_TELEMETRY)
@ -103,6 +105,7 @@
#define PIOS_GPIO_TELEMETRY USART_GPIO(PIOS_PORT_TELEMETRY) #define PIOS_GPIO_TELEMETRY USART_GPIO(PIOS_PORT_TELEMETRY)
#define PIOS_RXIO_TELEMETRY USART_RXIO(PIOS_PORT_TELEMETRY) #define PIOS_RXIO_TELEMETRY USART_RXIO(PIOS_PORT_TELEMETRY)
#define PIOS_TXIO_TELEMETRY USART_TXIO(PIOS_PORT_TELEMETRY) #define PIOS_TXIO_TELEMETRY USART_TXIO(PIOS_PORT_TELEMETRY)
#define PIOS_INCLUDE_TELEMETRY_RF
#endif #endif
#if defined(USE_GPS) #if defined(USE_GPS)

View File

@ -200,6 +200,7 @@ void PIOS_ADC_handler() {
#include "pios_usart_priv.h" #include "pios_usart_priv.h"
#if defined(PIOS_INCLUDE_TELEMETRY_RF)
/* /*
* Telemetry USART * Telemetry USART
*/ */
@ -245,6 +246,7 @@ const struct pios_usart_cfg pios_usart_telem_cfg = {
}, },
}, },
}; };
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
#if defined(PIOS_INCLUDE_GPS) #if defined(PIOS_INCLUDE_GPS)
/* /*
@ -472,11 +474,13 @@ void PIOS_SUPV_irq_handler() {
} }
#endif /* PIOS_INCLUDE_SBUS */ #endif /* PIOS_INCLUDE_SBUS */
#if defined(PIOS_INCLUDE_TELEMETRY_RF)
static uint32_t pios_usart_telem_rf_id; static uint32_t pios_usart_telem_rf_id;
void PIOS_USART_telem_irq_handler(void) void PIOS_USART_telem_irq_handler(void)
{ {
PIOS_USART_IRQ_Handler(pios_usart_telem_rf_id); PIOS_USART_IRQ_Handler(pios_usart_telem_rf_id);
} }
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
#if defined(PIOS_INCLUDE_GPS) #if defined(PIOS_INCLUDE_GPS)
static uint32_t pios_usart_gps_id; static uint32_t pios_usart_gps_id;
@ -807,12 +811,14 @@ void PIOS_Board_Init(void) {
/* Initialize the PiOS library */ /* Initialize the PiOS library */
#if defined(PIOS_INCLUDE_COM) #if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_TELEMETRY_RF)
if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_cfg)) { if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id)) { if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
#if defined(PIOS_INCLUDE_GPS) #if defined(PIOS_INCLUDE_GPS)
if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_cfg)) { if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);

View File

@ -38,7 +38,7 @@
static bool PIOS_COM_validate(struct pios_com_dev * com_dev) static bool PIOS_COM_validate(struct pios_com_dev * com_dev)
{ {
return (com_dev->magic == PIOS_COM_DEV_MAGIC); return (com_dev && (com_dev->magic == PIOS_COM_DEV_MAGIC));
} }
#if defined(PIOS_INCLUDE_FREERTOS) && 0 #if defined(PIOS_INCLUDE_FREERTOS) && 0
@ -298,7 +298,9 @@ int32_t PIOS_COM_ReceiveBufferUsed(uint32_t com_id)
if (!PIOS_COM_validate(com_dev)) { if (!PIOS_COM_validate(com_dev)) {
/* Undefined COM port for this board (see pios_board.c) */ /* Undefined COM port for this board (see pios_board.c) */
PIOS_DEBUG_Assert(0); /* This is commented out so com_id=NULL can be used to disable telemetry */
//PIOS_DEBUG_Assert(0);
return 0;
} }
if (!com_dev->driver->rx_avail) { if (!com_dev->driver->rx_avail) {