[uart] replace #ifdef USE_UARTx with #if USE_UARTx

This commit is contained in:
Felix Ruess
2013-12-27 18:59:34 +01:00
parent dee2ee53a3
commit 0166f097ad
19 changed files with 58 additions and 58 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
<define name="AHRS_TRIGGERED_ATTITUDE_LOOP"/> <define name="AHRS_TRIGGERED_ATTITUDE_LOOP"/>
<define name="USE_AHRS"/> <define name="USE_AHRS"/>
<define name="USE_INS_MODULE"/> <define name="USE_INS_MODULE"/>
<define name="USE_UART$(CHIMU_UART_NR)"/> <define name="USE_UART$(CHIMU_UART_NR)" value="1"/>
<define name="INS_LINK" value="UART$(CHIMU_UART_NR)"/> <define name="INS_LINK" value="UART$(CHIMU_UART_NR)"/>
<define name="UART$(CHIMU_UART_NR)_BAUD" value="B115200"/> <define name="UART$(CHIMU_UART_NR)_BAUD" value="B115200"/>
<file name="ahrs_chimu_uart.c"/> <file name="ahrs_chimu_uart.c"/>
+1 -1
View File
@@ -11,7 +11,7 @@
<makefile> <makefile>
<define name="EXTRA_DOWNLINK_DEVICE" value="UART0"/> <define name="EXTRA_DOWNLINK_DEVICE" value="UART0"/>
<define name="EXTRA_PPRZ_UART" value="UART0"/> <define name="EXTRA_PPRZ_UART" value="UART0"/>
<define name="USE_UART0"/> <define name="USE_UART0" value="1"/>
<define name="UART0_BAUD" value="B57600"/> <define name="UART0_BAUD" value="B57600"/>
<file name="extra_pprz_dl.c"/> <file name="extra_pprz_dl.c"/>
</makefile> </makefile>
+1 -1
View File
@@ -12,7 +12,7 @@
<init fun="ins_init()"/> <init fun="ins_init()"/>
<periodic fun="ins_periodic()" freq="60"/> <periodic fun="ins_periodic()" freq="60"/>
<makefile> <makefile>
<define name="USE_UART0"/> <define name="USE_UART0" value="1"/>
<define name="INS_LINK" value="UART0"/> <define name="INS_LINK" value="UART0"/>
<define name="UART0_BAUD" value="B115200"/> <define name="UART0_BAUD" value="B115200"/>
<define name="USE_GPS_XSENS"/> <define name="USE_GPS_XSENS"/>
+1 -1
View File
@@ -11,7 +11,7 @@
<init fun="ins_init()"/> <init fun="ins_init()"/>
<periodic fun="ins_periodic()" freq="60"/> <periodic fun="ins_periodic()" freq="60"/>
<makefile> <makefile>
<define name="USE_UART0"/> <define name="USE_UART0" value="1"/>
<define name="INS_LINK" value="UART0"/> <define name="INS_LINK" value="UART0"/>
<define name="UART0_BAUD" value="B115200"/> <define name="UART0_BAUD" value="B115200"/>
<!-- calibrated, orientation, status --> <!-- calibrated, orientation, status -->
@@ -161,7 +161,7 @@ static inline void uart_ISR(struct uart_periph* p)
} }
} }
#ifdef USE_UART0 #if USE_UART0
#ifndef UART0_VIC_SLOT #ifndef UART0_VIC_SLOT
#define UART0_VIC_SLOT 5 #define UART0_VIC_SLOT 5
@@ -222,7 +222,7 @@ void uart0_init( void ) {
#endif /* USE_UART0 */ #endif /* USE_UART0 */
#ifdef USE_UART1 #if USE_UART1
#ifndef UART1_VIC_SLOT #ifndef UART1_VIC_SLOT
#define UART1_VIC_SLOT 6 #define UART1_VIC_SLOT 6
+2 -2
View File
@@ -350,13 +350,13 @@ void set_linecoding(TLineCoding linecoding)
break; break;
} }
#ifdef USE_UART0 #if USE_UART0
U0LCR = ULCR_DLAB_ENABLE; // select divisor latches U0LCR = ULCR_DLAB_ENABLE; // select divisor latches
U0DLL = (uint8_t)baud; // set for baud low byte U0DLL = (uint8_t)baud; // set for baud low byte
U0DLM = (uint8_t)(baud >> 8); // set for baud high byte U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
U0LCR = (mode & ~ULCR_DLAB_ENABLE); U0LCR = (mode & ~ULCR_DLAB_ENABLE);
#endif #endif
#ifdef USE_UART1 #if USE_UART1
U1LCR = ULCR_DLAB_ENABLE; // select divisor latches U1LCR = ULCR_DLAB_ENABLE; // select divisor latches
U1DLL = (uint8_t)baud; // set for baud low byte U1DLL = (uint8_t)baud; // set for baud low byte
U1DLM = (uint8_t)(baud >> 8); // set for baud high byte U1DLM = (uint8_t)(baud >> 8); // set for baud high byte
+1 -1
View File
@@ -55,7 +55,7 @@ int main( void ) {
LED_ON(3); LED_ON(3);
#ifdef USE_UART0 #if USE_UART0
while(1) { while(1) {
if (T0TC > (rx_time+((PCLK / T0_PCLK_DIV) / BLINK_MIN))) LED_OFF(1); if (T0TC > (rx_time+((PCLK / T0_PCLK_DIV) / BLINK_MIN))) LED_OFF(1);
if (T0TC > (tx_time+((PCLK / T0_PCLK_DIV) / BLINK_MIN))) LED_OFF(2); if (T0TC > (tx_time+((PCLK / T0_PCLK_DIV) / BLINK_MIN))) LED_OFF(2);
+2 -2
View File
@@ -117,7 +117,7 @@ static inline void uart_handler(struct uart_periph* periph) {
} }
#ifdef USE_UART0 #if USE_UART0
void uart0_init( void ) { void uart0_init( void ) {
uart_periph_init(&uart0); uart_periph_init(&uart0);
@@ -132,7 +132,7 @@ void uart0_handler(void) {
#endif /* USE_UART0 */ #endif /* USE_UART0 */
#ifdef USE_UART1 #if USE_UART1
void uart1_init( void ) { void uart1_init( void ) {
uart_periph_init(&uart1); uart_periph_init(&uart1);
@@ -183,7 +183,7 @@ static inline void usart_enable_irq(uint8_t IRQn) {
} }
#ifdef USE_UART1 #if USE_UART1
/* by default enable UART Tx and Rx */ /* by default enable UART Tx and Rx */
#ifndef USE_UART1_TX #ifndef USE_UART1_TX
@@ -247,7 +247,7 @@ void usart1_isr(void) { usart_isr(&uart1); }
#endif /* USE_UART1 */ #endif /* USE_UART1 */
#ifdef USE_UART2 #if USE_UART2
/* by default enable UART Tx and Rx */ /* by default enable UART Tx and Rx */
#ifndef USE_UART2_TX #ifndef USE_UART2_TX
@@ -311,7 +311,7 @@ void usart2_isr(void) { usart_isr(&uart2); }
#endif /* USE_UART2 */ #endif /* USE_UART2 */
#ifdef USE_UART3 #if USE_UART3
/* by default enable UART Tx and Rx */ /* by default enable UART Tx and Rx */
#ifndef USE_UART3_TX #ifndef USE_UART3_TX
@@ -426,7 +426,7 @@ void uart4_isr(void) { usart_isr(&uart4); }
#endif /* USE_UART4 */ #endif /* USE_UART4 */
#ifdef USE_UART5 #if USE_UART5
/* by default enable UART Tx and Rx */ /* by default enable UART Tx and Rx */
#ifndef USE_UART5_TX #ifndef USE_UART5_TX
+2 -2
View File
@@ -130,10 +130,10 @@ static void main_periodic(int my_sig_num) {
RunOnceEvery(50, {DOWNLINK_SEND_ALIVE(gcs_com.udp_transport, 16, MD5SUM);}); RunOnceEvery(50, {DOWNLINK_SEND_ALIVE(gcs_com.udp_transport, 16, MD5SUM);});
RunOnceEvery(5, {DOWNLINK_SEND_ADC_GENERIC(gcs_com.udp_transport,&adc1,&adc2);}); RunOnceEvery(5, {DOWNLINK_SEND_ADC_GENERIC(gcs_com.udp_transport,&adc1,&adc2);});
#ifdef USE_UART0 #if USE_UART0
uart0_handler(); uart0_handler();
#endif #endif
#ifdef USE_UART1 #if USE_UART1
uart1_handler(); uart1_handler();
#endif #endif
DatalinkEvent() DatalinkEvent()
+6 -6
View File
@@ -30,7 +30,7 @@
#include "serial_port.h" #include "serial_port.h"
#ifdef USE_UART0 #if USE_UART0
volatile uint16_t uart0_rx_insert_idx, uart0_rx_extract_idx; volatile uint16_t uart0_rx_insert_idx, uart0_rx_extract_idx;
uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE]; uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE];
@@ -156,7 +156,7 @@ void uart0_handler(void) {
#endif /* USE_UART0 */ #endif /* USE_UART0 */
#ifdef USE_UART1 #if USE_UART1
volatile uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx; volatile uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx;
uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE]; uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE];
@@ -250,17 +250,17 @@ void uart1_handler(void) {
void uart_init( void ) void uart_init( void )
{ {
#ifdef USE_UART0 #if USE_UART0
uart0_init(); uart0_init();
#endif #endif
#ifdef USE_UART1 #if USE_UART1
uart1_init(); uart1_init();
#endif #endif
//TODO: add uart2 and greater //TODO: add uart2 and greater
#ifdef USE_UART2 #if USE_UART2
uart2_init(); uart2_init();
#endif #endif
#ifdef USE_UART3 #if USE_UART3
uart3_init(); uart3_init();
#endif #endif
} }
+2 -2
View File
@@ -44,7 +44,7 @@ extern void uart0_handler(void);
#endif #endif
#ifdef USE_UART0 #if USE_UART0
#define UART0_RX_BUFFER_SIZE 128 #define UART0_RX_BUFFER_SIZE 128
#define UART0_TX_BUFFER_SIZE 128 #define UART0_TX_BUFFER_SIZE 128
@@ -69,7 +69,7 @@ extern void uart1_handler(void);
#endif #endif
#ifdef USE_UART1 #if USE_UART1
#define UART1_RX_BUFFER_SIZE 128 #define UART1_RX_BUFFER_SIZE 128
#define UART1_TX_BUFFER_SIZE 128 #define UART1_TX_BUFFER_SIZE 128
+2 -2
View File
@@ -447,7 +447,7 @@ int do_log(void)
} }
#endif #endif
#ifdef USE_UART0 #if USE_UART0
temp = 0; temp = 0;
while (uart_char_available(&uart0) && (temp++ < 128)) while (uart_char_available(&uart0) && (temp++ < 128))
{ {
@@ -464,7 +464,7 @@ int do_log(void)
#endif #endif
} }
#endif #endif
#ifdef USE_UART1 #if USE_UART1
temp = 0; temp = 0;
while (uart_char_available(&uart1) && (temp++ < 128)) while (uart_char_available(&uart1) && (temp++ < 128))
{ {
+7 -7
View File
@@ -71,25 +71,25 @@ void mcu_init(void) {
#if defined RADIO_CONTROL & defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT & defined RADIO_CONTROL_BIND_IMPL_FUNC #if defined RADIO_CONTROL & defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT & defined RADIO_CONTROL_BIND_IMPL_FUNC
RADIO_CONTROL_BIND_IMPL_FUNC(); RADIO_CONTROL_BIND_IMPL_FUNC();
#endif #endif
#ifdef USE_UART0 #if USE_UART0
uart0_init(); uart0_init();
#endif #endif
#ifdef USE_UART1 #if USE_UART1
uart1_init(); uart1_init();
#endif #endif
#ifdef USE_UART2 #if USE_UART2
uart2_init(); uart2_init();
#endif #endif
#ifdef USE_UART3 #if USE_UART3
uart3_init(); uart3_init();
#endif #endif
#ifdef USE_UART4 #if USE_UART4
uart4_init(); uart4_init();
#endif #endif
#ifdef USE_UART5 #if USE_UART5
uart5_init(); uart5_init();
#endif #endif
#ifdef USE_UART6 #if USE_UART6
uart6_init(); uart6_init();
#endif #endif
#ifdef USE_I2C0 #ifdef USE_I2C0
+7 -7
View File
@@ -26,7 +26,7 @@
#include "subsystems/datalink/telemetry.h" #include "subsystems/datalink/telemetry.h"
#endif #endif
#ifdef USE_UART0 #if USE_UART0
struct uart_periph uart0; struct uart_periph uart0;
#if DOWNLINK #if DOWNLINK
@@ -42,7 +42,7 @@ static void send_uart0_err(void) {
#endif #endif
#ifdef USE_UART1 #if USE_UART1
struct uart_periph uart1; struct uart_periph uart1;
#if DOWNLINK #if DOWNLINK
@@ -58,7 +58,7 @@ static void send_uart1_err(void) {
#endif #endif
#ifdef USE_UART2 #if USE_UART2
struct uart_periph uart2; struct uart_periph uart2;
#if DOWNLINK #if DOWNLINK
@@ -74,7 +74,7 @@ static void send_uart2_err(void) {
#endif #endif
#ifdef USE_UART3 #if USE_UART3
struct uart_periph uart3; struct uart_periph uart3;
#if DOWNLINK #if DOWNLINK
@@ -90,7 +90,7 @@ static void send_uart3_err(void) {
#endif #endif
#ifdef USE_UART4 #if USE_UART4
struct uart_periph uart4; struct uart_periph uart4;
#if DOWNLINK #if DOWNLINK
@@ -106,7 +106,7 @@ static void send_uart4_err(void) {
#endif #endif
#ifdef USE_UART5 #if USE_UART5
struct uart_periph uart5; struct uart_periph uart5;
#if DOWNLINK #if DOWNLINK
@@ -122,7 +122,7 @@ static void send_uart5_err(void) {
#endif #endif
#ifdef USE_UART6 #if USE_UART6
struct uart_periph uart6; struct uart_periph uart6;
#if DOWNLINK #if DOWNLINK
+7 -7
View File
@@ -92,7 +92,7 @@ static inline uint16_t uart_char_available(struct uart_periph* p) {
} }
#ifdef USE_UART0 #if USE_UART0
extern struct uart_periph uart0; extern struct uart_periph uart0;
extern void uart0_init(void); extern void uart0_init(void);
@@ -108,7 +108,7 @@ extern void uart0_init(void);
#endif // USE_UART0 #endif // USE_UART0
#ifdef USE_UART1 #if USE_UART1
extern struct uart_periph uart1; extern struct uart_periph uart1;
extern void uart1_init(void); extern void uart1_init(void);
@@ -124,7 +124,7 @@ extern void uart1_init(void);
#endif // USE_UART1 #endif // USE_UART1
#ifdef USE_UART2 #if USE_UART2
extern struct uart_periph uart2; extern struct uart_periph uart2;
extern void uart2_init(void); extern void uart2_init(void);
@@ -140,7 +140,7 @@ extern void uart2_init(void);
#endif // USE_UART2 #endif // USE_UART2
#ifdef USE_UART3 #if USE_UART3
extern struct uart_periph uart3; extern struct uart_periph uart3;
extern void uart3_init(void); extern void uart3_init(void);
@@ -156,7 +156,7 @@ extern void uart3_init(void);
#endif // USE_UART3 #endif // USE_UART3
#ifdef USE_UART4 #if USE_UART4
extern struct uart_periph uart4; extern struct uart_periph uart4;
extern void uart4_init(void); extern void uart4_init(void);
@@ -172,7 +172,7 @@ extern void uart4_init(void);
#endif // USE_UART4 #endif // USE_UART4
#ifdef USE_UART5 #if USE_UART5
extern struct uart_periph uart5; extern struct uart_periph uart5;
extern void uart5_init(void); extern void uart5_init(void);
@@ -188,7 +188,7 @@ extern void uart5_init(void);
#endif // USE_UART5 #endif // USE_UART5
#ifdef USE_UART6 #if USE_UART6
extern struct uart_periph uart6; extern struct uart_periph uart6;
extern void uart6_init(void); extern void uart6_init(void);
+7 -7
View File
@@ -56,7 +56,7 @@
_PrintHex16(out_fun, low32); \ _PrintHex16(out_fun, low32); \
} }
#ifdef USE_UART0 #if USE_UART0
#define UART0PrintHex(c) _PrintHex(UART0Transmit, c) #define UART0PrintHex(c) _PrintHex(UART0Transmit, c)
#define UART0PrintHex16(c) _PrintHex16(UART0Transmit, c) #define UART0PrintHex16(c) _PrintHex16(UART0Transmit, c)
@@ -65,7 +65,7 @@
#endif /* USE_UART0 */ #endif /* USE_UART0 */
#ifdef USE_UART1 #if USE_UART1
#define UART1PrintHex(c) _PrintHex(UART1Transmit, c) #define UART1PrintHex(c) _PrintHex(UART1Transmit, c)
#define UART1PrintHex16(c) _PrintHex16(UART1Transmit, c) #define UART1PrintHex16(c) _PrintHex16(UART1Transmit, c)
@@ -74,7 +74,7 @@
#endif /* USE_UART1 */ #endif /* USE_UART1 */
#ifdef USE_UART2 #if USE_UART2
#define UART2PrintHex(c) _PrintHex(UART2Transmit, c) #define UART2PrintHex(c) _PrintHex(UART2Transmit, c)
#define UART2PrintHex16(c) _PrintHex16(UART2Transmit, c) #define UART2PrintHex16(c) _PrintHex16(UART2Transmit, c)
@@ -83,7 +83,7 @@
#endif /* USE_UART2 */ #endif /* USE_UART2 */
#ifdef USE_UART3 #if USE_UART3
#define UART3PrintHex(c) _PrintHex(UART3Transmit, c) #define UART3PrintHex(c) _PrintHex(UART3Transmit, c)
#define UART3PrintHex16(c) _PrintHex16(UART3Transmit, c) #define UART3PrintHex16(c) _PrintHex16(UART3Transmit, c)
@@ -92,7 +92,7 @@
#endif /* USE_UART3 */ #endif /* USE_UART3 */
#ifdef USE_UART4 #if USE_UART4
#define UART4PrintHex(c) _PrintHex(UART4Transmit, c) #define UART4PrintHex(c) _PrintHex(UART4Transmit, c)
#define UART4PrintHex16(c) _PrintHex16(UART4Transmit, c) #define UART4PrintHex16(c) _PrintHex16(UART4Transmit, c)
@@ -101,7 +101,7 @@
#endif /* USE_UART4 */ #endif /* USE_UART4 */
#ifdef USE_UART5 #if USE_UART5
#define UART5PrintHex(c) _PrintHex(UART5Transmit, c) #define UART5PrintHex(c) _PrintHex(UART5Transmit, c)
#define UART5PrintHex16(c) _PrintHex16(UART5Transmit, c) #define UART5PrintHex16(c) _PrintHex16(UART5Transmit, c)
@@ -110,7 +110,7 @@
#endif /* USE_UART5 */ #endif /* USE_UART5 */
#ifdef USE_UART6 #if USE_UART6
#define UART6PrintHex(c) _PrintHex(UART6Transmit, c) #define UART6PrintHex(c) _PrintHex(UART6Transmit, c)
#define UART6PrintHex16(c) _PrintHex16(UART6Transmit, c) #define UART6PrintHex16(c) _PrintHex16(UART6Transmit, c)
@@ -38,7 +38,7 @@ void imu_periodic(void) {
void navdata_event(void) { void navdata_event(void) {
#ifdef USE_UART1 #if USE_UART1
uart1_handler(); uart1_handler();
#endif #endif
} }
+2 -2
View File
@@ -41,10 +41,10 @@ int main (int argc, char** argv) {
#error "8 ADCs expected !" #error "8 ADCs expected !"
#endif #endif
#ifdef USE_UART0 #if USE_UART0
uart_periph_init(&uart0); uart_periph_init(&uart0);
#endif #endif
#ifdef USE_UART1 #if USE_UART1
uart_periph_init(&uart1); uart_periph_init(&uart1);
#endif #endif