mirror of https://github.com/Desuuuu/klipper.git
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
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue