From b34b67feeefc4c890f93f3ee211b58c1902b3a3d Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 12 Nov 2021 16:08:30 +0100 Subject: [PATCH] drivers/dose: reduce struct padding By moving all the single byte struct elements to the end, we can reduce padding inside `dose_t` and ensure that `recv_buf` is always aligned. This saves some RAM: master ------ text data bss dec hex filename 36384 136 12944 49464 c138 tests/driver_dose/bin/samr21-xpro/tests_driver_dose.e this patch ---------- text data bss dec hex filename 36484 136 12936 49556 c194 tests/driver_dose/bin/samr21-xpro/tests_driver_dose.elf --- drivers/include/dose.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/include/dose.h b/drivers/include/dose.h index 5013e0e77a..3ba955ccfe 100644 --- a/drivers/include/dose.h +++ b/drivers/include/dose.h @@ -152,17 +152,17 @@ typedef struct { uint8_t opts; /**< Driver options */ dose_state_t state; /**< Current state of the driver's state machine */ mutex_t state_mtx; /**< Is unlocked every time a state is (re)entered */ - uint8_t flags; /**< Several flags */ uint8_t recv_buf[DOSE_FRAME_LEN]; /**< Receive buffer for incoming frames */ size_t recv_buf_ptr; /**< Index of the next empty octet of the recveive buffer */ - uart_t uart; /**< UART device to use */ - uint8_t uart_octet; /**< Last received octet */ #if !defined(MODULE_PERIPH_UART_RXSTART_IRQ) || DOXYGEN gpio_t sense_pin; /**< GPIO to sense for start bits on the UART's rx line */ #endif gpio_t standby_pin; /**< GPIO to put the CAN transceiver in standby mode */ xtimer_t timeout; /**< Timeout timer ensuring always to get back to IDLE state */ uint32_t timeout_base; /**< Base timeout in us */ + uart_t uart; /**< UART device to use */ + uint8_t uart_octet; /**< Last received octet */ + uint8_t flags; /**< Several flags */ } dose_t; /**