From d8aeedceb51f31b0823ff90b1c089794051d3602 Mon Sep 17 00:00:00 2001 From: Tomasz Date: Wed, 30 Jun 2021 16:13:59 +0200 Subject: [PATCH] Make status led blink when device is alive. When it crashes the LED freezes. --- Src/main.c | 1 + Src/pcanpro_fd_protocol.c | 2 +- Src/pcanpro_protocol.c | 1 + Src/pcanpro_timestamp.c | 4 ++++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Src/main.c b/Src/main.c index 1537bcb..cf62e6d 100644 --- a/Src/main.c +++ b/Src/main.c @@ -76,6 +76,7 @@ int main(void) pcan_timestamp_init(); pcan_led_init(); + pcan_led_set_mode( LED_STAT, LED_MODE_BLINK_FAST, 0xFFFFFFFF ); pcan_protocol_init(); pcan_usb_device_init(); diff --git a/Src/pcanpro_fd_protocol.c b/Src/pcanpro_fd_protocol.c index a4c911b..fbf8d72 100644 --- a/Src/pcanpro_fd_protocol.c +++ b/Src/pcanpro_fd_protocol.c @@ -203,7 +203,7 @@ void pcan_ep0_receive( void ) pcan_flush_ep( PCAN_USB_EP_MSGIN_CH1 ); pcan_flush_ep( PCAN_USB_EP_CMDIN ); pcan_device.can_drv_loaded = drv_load_packet[1]; - pcan_led_set_mode( LED_STAT, LED_MODE_ON, 0 ); + pcan_led_set_mode( LED_STAT, LED_MODE_BLINK_SLOW, 0xFFFFFFFF ); } else pcan_device.lin_drv_loaded = drv_load_packet[1]; diff --git a/Src/pcanpro_protocol.c b/Src/pcanpro_protocol.c index ef83566..3c2cf78 100644 --- a/Src/pcanpro_protocol.c +++ b/Src/pcanpro_protocol.c @@ -243,6 +243,7 @@ void pcan_ep0_receive( void ) { pcan_flush_ep( PCAN_USB_EP_MSGIN_CH1 ); pcan_flush_ep( PCAN_USB_EP_CMDIN ); + pcan_led_set_mode( LED_STAT, LED_MODE_BLINK_SLOW, 0xFFFFFFFF ); } else { diff --git a/Src/pcanpro_timestamp.c b/Src/pcanpro_timestamp.c index 0a5baa7..9f09212 100644 --- a/Src/pcanpro_timestamp.c +++ b/Src/pcanpro_timestamp.c @@ -33,6 +33,10 @@ void pcan_timestamp_init( void ) assert( 0 ); break; } + + //HAL_GetTick must not return 0 to use LED events in early stage. + //Let's increment the value here by one. + HAL_IncTick(); } uint32_t pcan_timestamp_millis( void )