[led] add LED_AVAILABLE macro

This commit is contained in:
Felix Ruess
2014-12-07 14:47:11 +01:00
parent 5aea05a8ba
commit dd4f4150ae
2 changed files with 8 additions and 4 deletions
+4 -4
View File
@@ -53,13 +53,13 @@ static inline void tunnel_event(void)
{
unsigned char inc;
#ifdef TUNNEL_RX_LED
#if LED_AVAILABLE(TUNNEL_RX_LED)
static uint32_t rx_time=0;
if (get_sys_time_msec() > rx_time + BLINK_MIN) {
LED_OFF(TUNNEL_RX_LED);
}
#endif
#ifdef TUNNEL_TX_LED
#if LED_AVAILABLE(TUNNEL_TX_LED)
static uint32_t tx_time=0;
if (get_sys_time_msec() > tx_time + BLINK_MIN) {
LED_OFF(TUNNEL_TX_LED);
@@ -67,7 +67,7 @@ static inline void tunnel_event(void)
#endif
if (uart_char_available(&USB_TUNNEL_UART) && VCOM_check_free_space(1)) {
#ifdef TUNNEL_RX_LED
#if LED_AVAILABLE(TUNNEL_RX_LED)
LED_ON(TUNNEL_RX_LED);
rx_time = get_sys_time_msec();
#endif
@@ -75,7 +75,7 @@ static inline void tunnel_event(void)
VCOM_putchar(inc);
}
if (VCOM_check_available() && uart_check_free_space(&USB_TUNNEL_UART, 1)) {
#ifdef TUNNEL_TX_LED
#if LED_AVAILABLE(TUNNEL_TX_LED)
LED_ON(TUNNEL_TX_LED);
tx_time = get_sys_time_msec();
#endif
+4
View File
@@ -95,12 +95,16 @@ static inline void led_init ( void ) {
#endif /* LED_12 */
}
#define _LED_AVAILABLE(i) USE_LED_ ## i
#define LED_AVAILABLE(i) _LED_AVAILABLE(i)
#else /* USE_LED */
static inline void led_init ( void ) {}
#define LED_ON(i) {}
#define LED_OFF(i) {}
#define LED_TOGGLE(i) {}
#define LED_PERIODIC() {}
#define LED_AVAILABLE(i) 0
#endif /* USE_LED */
#endif /* LED_H */