From 4566392fafe801573972380ef7d2391affd1282c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 18 Mar 2021 16:50:33 -0400 Subject: [PATCH] stm32: Minor optimization to can.c IRQ data reading Signed-off-by: Kevin O'Connor --- src/stm32/can.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/stm32/can.c b/src/stm32/can.c index 323c1d54..af10f6ab 100644 --- a/src/stm32/can.c +++ b/src/stm32/can.c @@ -201,16 +201,11 @@ CAN_IRQHandler(void) SOC_CAN->RF1R = CAN_RF1R_RFOM1; // Process packet - uint8_t data[8]; - data[0] = (rdlr >> 0) & 0xff; - data[1] = (rdlr >> 8) & 0xff; - 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); + union { + struct { uint32_t rdlr, rdhr; }; + uint8_t data[8]; + } rdata = { .rdlr = rdlr, .rdhr = rdhr }; + canbus_process_data(rir_id, dlc, rdata.data); } uint32_t ier = SOC_CAN->IER; if (ier & CAN_IER_FMPIE0 && SOC_CAN->RF0R & CAN_RF0R_FMP0) {