Skip to content

Commit

Permalink
[uart] Fix stupid weak errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fvantienen committed Nov 23, 2014
1 parent c046fa7 commit 2affa15
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 36 deletions.
59 changes: 52 additions & 7 deletions sw/airborne/arch/omap/mcu_periph/uart_arch.c
Expand Up @@ -36,6 +36,27 @@
// #define TRACE(fmt,args...) fprintf(stderr, fmt, args)
#define TRACE(fmt,args...)

#if USE_UART0
static inline void uart0_handler(void);
#endif
#if USE_UART1
static inline void uart1_handler(void);
#endif
#if USE_UART2
static inline void uart2_handler(void);
#endif
#if USE_UART3
static inline void uart3_handler(void);
#endif
#if USE_UART4
static inline void uart4_handler(void);
#endif
#if USE_UART5
static inline void uart5_handler(void);
#endif
#if USE_UART6
static inline void uart6_handler(void);
#endif

void uart_periph_set_baudrate(struct uart_periph* periph, uint32_t baud) {
struct SerialPort* port;
Expand Down Expand Up @@ -117,14 +138,38 @@ static inline void uart_handler(struct uart_periph* periph) {

}

void uart_event(void) {
#if USE_UART0
uart0_handler();
#endif
#if USE_UART1
uart1_handler();
#endif
#if USE_UART2
uart2_handler();
#endif
#if USE_UART3
uart3_handler();
#endif
#if USE_UART4
uart4_handler();
#endif
#if USE_UART5
uart5_handler();
#endif
#if USE_UART6
uart6_handler();
#endif
}

#if USE_UART0
void uart0_init( void ) {
uart_periph_init(&uart0);
strcpy(uart0.dev, UART0_DEV);
uart_periph_set_baudrate(&uart0, UART0_BAUD);
}

void uart0_handler(void) {
static inline void uart0_handler(void) {
uart_handler(&uart0);
}
#endif /* USE_UART0 */
Expand All @@ -136,7 +181,7 @@ void uart1_init( void ) {
uart_periph_set_baudrate(&uart1, UART1_BAUD);
}

void uart1_handler(void) {
static inline void uart1_handler(void) {
uart_handler(&uart1);
}
#endif /* USE_UART1 */
Expand All @@ -148,7 +193,7 @@ void uart2_init(void) {
uart_periph_set_baudrate(&uart2, UART2_BAUD);
}

void uart2_handler(void) {
static inline void uart2_handler(void) {
uart_handler(&uart2);
}
#endif /* USE_UART2 */
Expand All @@ -160,7 +205,7 @@ void uart3_init(void) {
uart_periph_set_baudrate(&uart3, UART3_BAUD);
}

void uart3_handler(void) {
static inline void uart3_handler(void) {
uart_handler(&uart3);
}
#endif /* USE_UART3 */
Expand All @@ -172,7 +217,7 @@ void uart4_init(void) {
uart_periph_set_baudrate(&uart4, UART4_BAUD);
}

void uart4_handler(void) {
static inline void uart4_handler(void) {
uart_handler(&uart4);
}
#endif /* USE_UART4 */
Expand All @@ -184,7 +229,7 @@ void uart5_init(void) {
uart_periph_set_baudrate(&uart5, UART5_BAUD);
}

void uart5_handler(void) {
static inline void uart5_handler(void) {
uart_handler(&uart5);
}
#endif /* USE_UART5 */
Expand All @@ -196,7 +241,7 @@ void uart6_init(void) {
uart_periph_set_baudrate(&uart6, UART6_BAUD);
}

void uart6_handler(void) {
static inline void uart6_handler(void) {
uart_handler(&uart6);
}
#endif /* USE_UART6 */
22 changes: 1 addition & 21 deletions sw/airborne/mcu_periph/uart.c
Expand Up @@ -214,25 +214,5 @@ uint8_t uart_getch(struct uart_periph* p) {
}

void WEAK uart_event(void) {
#if USE_UART0
uart0_handler();
#endif
#if USE_UART1
uart1_handler();
#endif
#if USE_UART2
uart2_handler();
#endif
#if USE_UART3
uart3_handler();
#endif
#if USE_UART4
uart4_handler();
#endif
#if USE_UART5
uart5_handler();
#endif
#if USE_UART6
uart6_handler();
#endif

}
9 changes: 1 addition & 8 deletions sw/airborne/mcu_periph/uart.h
Expand Up @@ -82,7 +82,7 @@ extern void uart_periph_set_mode(struct uart_periph* p, bool_t tx_enabled, bool_
extern void uart_transmit(struct uart_periph* p, uint8_t data);
extern bool_t uart_check_free_space(struct uart_periph* p, uint8_t len);
extern uint8_t uart_getch(struct uart_periph* p);
extern void WEAK uart_event(void);
extern void uart_event(void);

/**
* Check UART for available chars in receive buffer.
Expand All @@ -99,7 +99,6 @@ static inline uint16_t uart_char_available(struct uart_periph* p) {
#if USE_UART0
extern struct uart_periph uart0;
extern void uart0_init(void);
extern void WEAK uart0_handler(void);

#define UART0Init() uart_periph_init(&uart0)
#define UART0CheckFreeSpace(_x) uart_check_free_space(&uart0, _x)
Expand All @@ -116,7 +115,6 @@ extern void WEAK uart0_handler(void);
#if USE_UART1
extern struct uart_periph uart1;
extern void uart1_init(void);
extern void WEAK uart1_handler(void);

#define UART1Init() uart_periph_init(&uart1)
#define UART1CheckFreeSpace(_x) uart_check_free_space(&uart1, _x)
Expand All @@ -133,7 +131,6 @@ extern void WEAK uart1_handler(void);
#if USE_UART2
extern struct uart_periph uart2;
extern void uart2_init(void);
extern void WEAK uart2_handler(void);

#define UART2Init() uart_periph_init(&uart2)
#define UART2CheckFreeSpace(_x) uart_check_free_space(&uart2, _x)
Expand All @@ -150,7 +147,6 @@ extern void WEAK uart2_handler(void);
#if USE_UART3
extern struct uart_periph uart3;
extern void uart3_init(void);
extern void WEAK uart3_handler(void);

#define UART3Init() uart_periph_init(&uart3)
#define UART3CheckFreeSpace(_x) uart_check_free_space(&uart3, _x)
Expand All @@ -167,7 +163,6 @@ extern void WEAK uart3_handler(void);
#if USE_UART4
extern struct uart_periph uart4;
extern void uart4_init(void);
extern void WEAK uart4_handler(void);

#define UART4Init() uart_periph_init(&uart4)
#define UART4CheckFreeSpace(_x) uart_check_free_space(&uart4, _x)
Expand All @@ -184,7 +179,6 @@ extern void WEAK uart4_handler(void);
#if USE_UART5
extern struct uart_periph uart5;
extern void uart5_init(void);
extern void WEAK uart5_handler(void);

#define UART5Init() uart_periph_init(&uart5)
#define UART5CheckFreeSpace(_x) uart_check_free_space(&uart5, _x)
Expand All @@ -201,7 +195,6 @@ extern void WEAK uart5_handler(void);
#if USE_UART6
extern struct uart_periph uart6;
extern void uart6_init(void);
extern void WEAK uart6_handler(void);

#define UART6Init() uart_periph_init(&uart6)
#define UART6CheckFreeSpace(_x) uart_check_free_space(&uart6, _x)
Expand Down

0 comments on commit 2affa15

Please sign in to comment.