stm32: Minor optimization to can.c IRQ data reading

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-03-18 16:50:33 -04:00
parent fee84c2afb
commit 4566392faf
1 changed files with 5 additions and 10 deletions

View File

@ -201,16 +201,11 @@ CAN_IRQHandler(void)
SOC_CAN->RF1R = CAN_RF1R_RFOM1; SOC_CAN->RF1R = CAN_RF1R_RFOM1;
// Process packet // Process packet
union {
struct { uint32_t rdlr, rdhr; };
uint8_t data[8]; uint8_t data[8];
data[0] = (rdlr >> 0) & 0xff; } rdata = { .rdlr = rdlr, .rdhr = rdhr };
data[1] = (rdlr >> 8) & 0xff; canbus_process_data(rir_id, dlc, rdata.data);
data[2] = (rdlr >> 16) & 0xff;
data[3] = (rdlr >> 24) & 0xff;
data[4] = (rdhr >> 0) & 0xff;
data[5] = (rdhr >> 8) & 0xff;
data[6] = (rdhr >> 16) & 0xff;
data[7] = (rdhr >> 24) & 0xff;
canbus_process_data(rir_id, dlc, data);
} }
uint32_t ier = SOC_CAN->IER; uint32_t ier = SOC_CAN->IER;
if (ier & CAN_IER_FMPIE0 && SOC_CAN->RF0R & CAN_RF0R_FMP0) { if (ier & CAN_IER_FMPIE0 && SOC_CAN->RF0R & CAN_RF0R_FMP0) {