aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-06-11 18:19:53 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-06-27 10:50:23 -0400
commitf5d5f53914d46dfccdd21399e44f8af71a8f345a (patch)
tree4ec476dccec577efd9fcca32d488401bb664d17e /src
parent84b2bfe3135990983d55fd4d530139cf8ddb1f33 (diff)
downloadkutter-f5d5f53914d46dfccdd21399e44f8af71a8f345a.tar.gz
kutter-f5d5f53914d46dfccdd21399e44f8af71a8f345a.tar.xz
kutter-f5d5f53914d46dfccdd21399e44f8af71a8f345a.zip
stm32: Add support for disabling the canbus filter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/Kconfig3
-rw-r--r--src/stm32/can.c20
-rwxr-xr-xsrc/stm32/fdcan.c2
3 files changed, 18 insertions, 7 deletions
diff --git a/src/Kconfig b/src/Kconfig
index eba05243..79cb4182 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -83,6 +83,9 @@ config CANSERIAL
config CANBUS_FREQUENCY
int "CAN bus speed" if LOW_LEVEL_OPTIONS && CANSERIAL
default 500000
+config CANBUS_FILTER
+ bool
+ default y if CANSERIAL
# Support setting gpio state at startup
config INITIAL_PINS
diff --git a/src/stm32/can.c b/src/stm32/can.c
index 9cd72209..6e50cea9 100644
--- a/src/stm32/can.c
+++ b/src/stm32/can.c
@@ -136,13 +136,19 @@ canbus_set_filter(uint32_t id)
/* Initialisation mode for the filter */
SOC_CAN->FA1R = 0;
- uint32_t mask = CAN_TI0R_STID | CAN_TI0R_IDE | CAN_TI0R_RTR;
- SOC_CAN->sFilterRegister[0].FR1 = CANBUS_ID_ADMIN << CAN_RI0R_STID_Pos;
- SOC_CAN->sFilterRegister[0].FR2 = mask;
- SOC_CAN->sFilterRegister[1].FR1 = (id + 1) << CAN_RI0R_STID_Pos;
- SOC_CAN->sFilterRegister[1].FR2 = mask;
- SOC_CAN->sFilterRegister[2].FR1 = id << CAN_RI0R_STID_Pos;
- SOC_CAN->sFilterRegister[2].FR2 = mask;
+ if (CONFIG_CANBUS_FILTER) {
+ uint32_t mask = CAN_TI0R_STID | CAN_TI0R_IDE | CAN_TI0R_RTR;
+ SOC_CAN->sFilterRegister[0].FR1 = CANBUS_ID_ADMIN << CAN_RI0R_STID_Pos;
+ SOC_CAN->sFilterRegister[0].FR2 = mask;
+ SOC_CAN->sFilterRegister[1].FR1 = (id + 1) << CAN_RI0R_STID_Pos;
+ SOC_CAN->sFilterRegister[1].FR2 = mask;
+ SOC_CAN->sFilterRegister[2].FR1 = id << CAN_RI0R_STID_Pos;
+ SOC_CAN->sFilterRegister[2].FR2 = mask;
+ } else {
+ SOC_CAN->sFilterRegister[0].FR1 = 0;
+ SOC_CAN->sFilterRegister[0].FR2 = 0;
+ id = 0;
+ }
/* 32-bit scale for the filter */
SOC_CAN->FS1R = (1<<0) | (1<<1) | (1<<2);
diff --git a/src/stm32/fdcan.c b/src/stm32/fdcan.c
index cf2cc276..3af9ffa8 100755
--- a/src/stm32/fdcan.c
+++ b/src/stm32/fdcan.c
@@ -113,6 +113,8 @@ can_filter(uint32_t index, uint32_t id)
void
canbus_set_filter(uint32_t id)
{
+ if (!CONFIG_CANBUS_FILTER)
+ return;
/* Request initialisation */
SOC_CAN->CCCR |= FDCAN_CCCR_INIT;
/* Wait the acknowledge */