stm32: Add support for disabling the canbus filter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
84b2bfe313
commit
f5d5f53914
|
@ -83,6 +83,9 @@ config CANSERIAL
|
||||||
config CANBUS_FREQUENCY
|
config CANBUS_FREQUENCY
|
||||||
int "CAN bus speed" if LOW_LEVEL_OPTIONS && CANSERIAL
|
int "CAN bus speed" if LOW_LEVEL_OPTIONS && CANSERIAL
|
||||||
default 500000
|
default 500000
|
||||||
|
config CANBUS_FILTER
|
||||||
|
bool
|
||||||
|
default y if CANSERIAL
|
||||||
|
|
||||||
# Support setting gpio state at startup
|
# Support setting gpio state at startup
|
||||||
config INITIAL_PINS
|
config INITIAL_PINS
|
||||||
|
|
|
@ -136,6 +136,7 @@ canbus_set_filter(uint32_t id)
|
||||||
/* Initialisation mode for the filter */
|
/* Initialisation mode for the filter */
|
||||||
SOC_CAN->FA1R = 0;
|
SOC_CAN->FA1R = 0;
|
||||||
|
|
||||||
|
if (CONFIG_CANBUS_FILTER) {
|
||||||
uint32_t mask = CAN_TI0R_STID | CAN_TI0R_IDE | CAN_TI0R_RTR;
|
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].FR1 = CANBUS_ID_ADMIN << CAN_RI0R_STID_Pos;
|
||||||
SOC_CAN->sFilterRegister[0].FR2 = mask;
|
SOC_CAN->sFilterRegister[0].FR2 = mask;
|
||||||
|
@ -143,6 +144,11 @@ canbus_set_filter(uint32_t id)
|
||||||
SOC_CAN->sFilterRegister[1].FR2 = mask;
|
SOC_CAN->sFilterRegister[1].FR2 = mask;
|
||||||
SOC_CAN->sFilterRegister[2].FR1 = id << CAN_RI0R_STID_Pos;
|
SOC_CAN->sFilterRegister[2].FR1 = id << CAN_RI0R_STID_Pos;
|
||||||
SOC_CAN->sFilterRegister[2].FR2 = mask;
|
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 */
|
/* 32-bit scale for the filter */
|
||||||
SOC_CAN->FS1R = (1<<0) | (1<<1) | (1<<2);
|
SOC_CAN->FS1R = (1<<0) | (1<<1) | (1<<2);
|
||||||
|
|
|
@ -113,6 +113,8 @@ can_filter(uint32_t index, uint32_t id)
|
||||||
void
|
void
|
||||||
canbus_set_filter(uint32_t id)
|
canbus_set_filter(uint32_t id)
|
||||||
{
|
{
|
||||||
|
if (!CONFIG_CANBUS_FILTER)
|
||||||
|
return;
|
||||||
/* Request initialisation */
|
/* Request initialisation */
|
||||||
SOC_CAN->CCCR |= FDCAN_CCCR_INIT;
|
SOC_CAN->CCCR |= FDCAN_CCCR_INIT;
|
||||||
/* Wait the acknowledge */
|
/* Wait the acknowledge */
|
||||||
|
|
Loading…
Reference in New Issue