From 91b4fb8fd33b699b658a097dc6029f31abdee0b3 Mon Sep 17 00:00:00 2001 From: Ethan Zonca Date: Tue, 1 Jan 2019 11:59:37 -0500 Subject: [PATCH] Fix support for disabling autoretransmission. Tested; works. --- src/can.c | 16 +++++++++++++--- src/system.c | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/can.c b/src/can.c index a29bf12..4bf9a97 100644 --- a/src/can.c +++ b/src/can.c @@ -17,6 +17,8 @@ enum can_bus_state bus_state; static volatile uint8_t process_recv = 0; static volatile uint8_t process_tx = 0; +static uint8_t can_nart = DISABLE; + static CanRxMsgTypeDef can_rx_msg; static CanTxMsgTypeDef can_tx_msg; @@ -75,7 +77,7 @@ void can_enable(void) can_handle.Init.TTCM = DISABLE; can_handle.Init.ABOM = ENABLE; can_handle.Init.AWUM = DISABLE; - can_handle.Init.NART = DISABLE; + can_handle.Init.NART = can_nart; can_handle.Init.RFLM = DISABLE; can_handle.Init.TXFP = DISABLE; can_handle.pTxMsg = NULL; //&can_tx_msg; @@ -103,6 +105,8 @@ void can_disable(void) // HAL_NVIC_DisableIRQ(CEC_CAN_IRQn); // HAL_CAN_DeInit(&can_handle); + + led_green_on(); } } @@ -146,6 +150,8 @@ void can_set_bitrate(enum can_bitrate bitrate) prescaler = 6; break; } + + led_green_on(); } @@ -163,6 +169,8 @@ void can_set_silent(uint8_t silent) } else { can_handle.Init.Mode = CAN_MODE_NORMAL; } + + led_green_on(); } @@ -176,10 +184,12 @@ void can_set_autoretransmit(uint8_t autoretransmit) } if (autoretransmit) { - can_handle.Init.NART = DISABLE; + can_nart = DISABLE; } else { - can_handle.Init.NART = ENABLE; + can_nart = ENABLE; } + + led_green_on(); } diff --git a/src/system.c b/src/system.c index 01598e8..e42ba9b 100644 --- a/src/system.c +++ b/src/system.c @@ -102,6 +102,7 @@ void system_init(void) } +// Convert a 32-bit value to an ascii hex value void system_hex32(char *out, uint32_t val) { char *p = out + 8;