diff --git a/include/led.h b/include/led.h index 906341a2..02f6d9f9 100644 --- a/include/led.h +++ b/include/led.h @@ -41,8 +41,9 @@ typedef enum { } led_mode_t; typedef enum { - led_rx = 0, //will also index into array led_state[] - led_tx + LED_RX = 0, //will also index into array led_state[] + LED_TX, + LED_MAX } led_num_t; typedef struct { @@ -68,7 +69,7 @@ typedef struct { uint32_t t_sequence_next; int32_t seq_num_repeat; - led_state_t led_state[2]; + led_state_t led_state[LED_MAX]; } led_data_t; diff --git a/src/can_common.c b/src/can_common.c index 5b0dd13b..311b0431 100644 --- a/src/can_common.c +++ b/src/can_common.c @@ -59,7 +59,7 @@ void CAN_SendFrame(USBD_GS_CAN_HandleTypeDef *hcan, can_data_t *channel) list_add_tail_locked(&frame_object->list, &hcan->list_to_host); - led_indicate_trx(&channel->leds, led_tx); + led_indicate_trx(&channel->leds, LED_TX); } void CAN_ReceiveFrame(USBD_GS_CAN_HandleTypeDef *hcan, can_data_t *channel) @@ -97,7 +97,7 @@ void CAN_ReceiveFrame(USBD_GS_CAN_HandleTypeDef *hcan, can_data_t *channel) list_add_tail_locked(&frame_object->list, &hcan->list_to_host); - led_indicate_trx(&channel->leds, led_rx); + led_indicate_trx(&channel->leds, LED_RX); } // If there are frames to receive, don't report any error frames. The diff --git a/src/led.c b/src/led.c index ff02b13f..63a30b48 100644 --- a/src/led.c +++ b/src/led.c @@ -38,12 +38,12 @@ void led_init( void* led_tx_port, uint16_t led_tx_pin, bool led_tx_active_high ) { memset(leds, 0, sizeof(led_data_t)); - leds->led_state[led_rx].port = led_rx_port; - leds->led_state[led_rx].pin = led_rx_pin; - leds->led_state[led_rx].is_active_high = led_rx_active_high; - leds->led_state[led_tx].port = led_tx_port; - leds->led_state[led_tx].pin = led_tx_pin; - leds->led_state[led_tx].is_active_high = led_tx_active_high; + leds->led_state[LED_RX].port = led_rx_port; + leds->led_state[LED_RX].pin = led_rx_pin; + leds->led_state[LED_RX].is_active_high = led_rx_active_high; + leds->led_state[LED_TX].port = led_tx_port; + leds->led_state[LED_TX].pin = led_tx_pin; + leds->led_state[LED_TX].is_active_high = led_tx_active_high; } void led_set_mode(led_data_t *leds,led_mode_t mode) @@ -65,8 +65,8 @@ static uint32_t led_set_sequence_step(led_data_t *leds, uint32_t step_num) { const led_seq_step_t *step = &leds->sequence[step_num]; leds->sequence_step = step_num; - led_set(&leds->led_state[led_rx], step->state & 0x01); - led_set(&leds->led_state[led_tx], step->state & 0x02); + led_set(&leds->led_state[LED_RX], step->state & 0x01); + led_set(&leds->led_state[LED_TX], step->state & 0x02); uint32_t delta = 10 * step->time_in_10ms; if (delta > INT32_MAX) { delta = INT32_MAX; //clamp @@ -150,13 +150,13 @@ void led_update(led_data_t *leds) switch (leds->mode) { case led_mode_off: - led_set(&leds->led_state[led_rx], false); - led_set(&leds->led_state[led_tx], false); + led_set(&leds->led_state[LED_RX], false); + led_set(&leds->led_state[LED_TX], false); break; case led_mode_normal: - led_update_normal_mode(&leds->led_state[led_rx], now); - led_update_normal_mode(&leds->led_state[led_tx], now); + led_update_normal_mode(&leds->led_state[LED_RX], now); + led_update_normal_mode(&leds->led_state[LED_TX], now); break; case led_mode_sequence: