mirror of https://github.com/Desuuuu/klipper.git
canbus: Rename canbus_set_dataport() to canbus_set_filter() and simplify
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5769a9072b
commit
5c4cf54557
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 #################################*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue