From feccb722866fbdcc7628b941efe9f79295b0cf81 Mon Sep 17 00:00:00 2001 From: Daniel Kucera Date: Tue, 8 Mar 2022 12:05:36 +0100 Subject: [PATCH] Properly reset the module It looks like the module is much more stable when reset bit is first set and then cleared. Fixes #36 --- src/CAN.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CAN.c b/src/CAN.c index 826f9db..7e80b98 100644 --- a/src/CAN.c +++ b/src/CAN.c @@ -171,6 +171,7 @@ int CAN_init() { // enable module DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN); + DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST); DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST); // configure TX pin @@ -296,4 +297,4 @@ int CAN_config_filter(const CAN_filter_t* p_filter) { __filter.AMR3 = p_filter->AMR3; return 0; -} \ No newline at end of file +}