diff --git a/src/generic/canbus.c b/src/generic/canbus.c index b3e1bada..50cc50bc 100644 --- a/src/generic/canbus.c +++ b/src/generic/canbus.c @@ -137,7 +137,7 @@ can_process_set_id(uint32_t id, uint32_t len, uint8_t *data) // compare my UUID with packet to check if this packet mine if (memcmp(&data[2], canbus_uuid, sizeof(canbus_uuid)) == 0) { canbus_assigned_id = data[0] | (data[1] << 8); - canbus_set_dataport(canbus_assigned_id); + canbus_set_filter(canbus_assigned_id); } } diff --git a/src/generic/canbus.h b/src/generic/canbus.h index d797dc53..3a3283ca 100644 --- a/src/generic/canbus.h +++ b/src/generic/canbus.h @@ -11,7 +11,7 @@ // callbacks provided by board specific code int canbus_read(uint32_t *id, uint8_t *data); int canbus_send(uint32_t id, uint32_t len, uint8_t *data); -void canbus_set_dataport(uint32_t id); +void canbus_set_filter(uint32_t id); void canbus_reboot(void); // canbus.c diff --git a/src/stm32/can.c b/src/stm32/can.c index 987a8190..cb5f442b 100644 --- a/src/stm32/can.c +++ b/src/stm32/can.c @@ -157,8 +157,8 @@ canbus_send(uint32_t id, uint32_t len, uint8_t *data) #define CAN_FILTER_NUMBER 0 // Setup the receive packet filter -static void -can_set_filter(uint32_t id1, uint32_t id2) +void +canbus_set_filter(uint32_t id) { uint32_t filternbrbitpos = 1 << CAN_FILTER_NUMBER; @@ -167,8 +167,9 @@ can_set_filter(uint32_t id1, uint32_t id2) /* Initialisation mode for the filter */ SOC_CAN->FA1R = 0; - SOC_CAN->sFilterRegister[CAN_FILTER_NUMBER].FR1 = id1 << (5 + 16); - SOC_CAN->sFilterRegister[CAN_FILTER_NUMBER].FR2 = id2 << (5 + 16); + uint32_t idadmin = CANBUS_ID_UUID; + SOC_CAN->sFilterRegister[CAN_FILTER_NUMBER].FR1 = idadmin << (5 + 16); + SOC_CAN->sFilterRegister[CAN_FILTER_NUMBER].FR2 = id << (5 + 16); /* Identifier list mode for the filter */ SOC_CAN->FM1R = filternbrbitpos; @@ -184,12 +185,6 @@ can_set_filter(uint32_t id1, uint32_t id2) SOC_CAN->FMR &= ~CAN_FMR_FINIT; } -void -canbus_set_dataport(uint32_t id) -{ - can_set_filter(CANBUS_ID_UUID, id); -} - void canbus_reboot(void) { @@ -292,7 +287,7 @@ can_init(void) ; /*##-2- Configure the CAN Filter #######################################*/ - can_set_filter(CANBUS_ID_UUID, CANBUS_ID_SET); + canbus_set_filter(CANBUS_ID_SET); /*##-3- Configure Interrupts #################################*/