From 4a0b3e5d705b8a57036a6dde1e73b08ab17e2b81 Mon Sep 17 00:00:00 2001 From: Cristian Cristea Date: Fri, 1 Dec 2023 19:32:13 +0200 Subject: [PATCH] Update some formatting --- Base/include/oled-draw.h | 14 ++++---- Base/include/oled.h | 4 +-- Base/include/spi.h | 2 +- Base/src/oled-draw.c | 37 +++++++++---------- Base/src/oled.c | 76 ++++++++++++++++++++-------------------- Base/src/spi.c | 31 ++++++++-------- include/bluetooth.h | 4 +-- include/bme280.h | 4 +-- include/config.h | 2 +- include/crc8.h | 4 +-- include/i2c.h | 2 +- include/uart.h | 2 +- include/utils.h | 13 +++++-- include/vector.h | 4 +-- src/bluetooth.c | 24 ++++++------- src/bme280.c | 6 ++-- src/config.c | 9 ++--- src/i2c.c | 10 +++--- src/uart.c | 49 +++++++++++++------------- src/vector.c | 4 +-- 20 files changed, 158 insertions(+), 143 deletions(-) diff --git a/Base/include/oled-draw.h b/Base/include/oled-draw.h index e60e84c..b6fa822 100644 --- a/Base/include/oled-draw.h +++ b/Base/include/oled-draw.h @@ -8,7 +8,7 @@ #ifndef OLED_DRAW_H -#define OLED_DRAW_H +#define OLED_DRAW_H //////////////////////////////////////////////////////////////////////////////// // // @@ -43,11 +43,11 @@ typedef enum OLED_SHAPE_TYPE OLED_SHAPE_LINE = 0x01, OLED_SHAPE_RECTANGLE = 0x02, OLED_SHAPE_FILLED_RECTANGLE = 0x03, - OLED_SHAPE_DISC = 0x04, - OLED_SHAPE_CIRCLE = 0x05, - OLED_SHAPE_BITMAP = 0x06, - OLED_SHAPE_CHARACTER = 0x07, - OLED_SHAPE_STRING = 0x08, + OLED_SHAPE_DISC = 0x04, + OLED_SHAPE_CIRCLE = 0x05, + OLED_SHAPE_BITMAP = 0x06, + OLED_SHAPE_CHARACTER = 0x07, + OLED_SHAPE_STRING = 0x08, } oled_shape_type_t; typedef struct OLED_POINT @@ -138,4 +138,4 @@ typedef struct OLED_SHAPE void OLED_SetShape(oled_shape_t * const shape, oled_shape_type_t const type, oled_shape_parameters_t const * const parameters, oled_colour_t const colour); -#endif // OLED_DRAW_H \ No newline at end of file +#endif // OLED_DRAW_H diff --git a/Base/include/oled.h b/Base/include/oled.h index ed7bfa0..5d6e98c 100644 --- a/Base/include/oled.h +++ b/Base/include/oled.h @@ -8,7 +8,7 @@ #ifndef OLED_H -#define OLED_H +#define OLED_H //////////////////////////////////////////////////////////////////////////////// @@ -156,4 +156,4 @@ void OLED_SendColor(oled_device_t const * const device, oled_packed_colour_t con void OLED_SetBackground(oled_device_t const * const device, oled_colour_t const colour); -#endif // OLED_H \ No newline at end of file +#endif // OLED_H diff --git a/Base/include/spi.h b/Base/include/spi.h index 767e489..6680bce 100644 --- a/Base/include/spi.h +++ b/Base/include/spi.h @@ -8,7 +8,7 @@ #ifndef SPI_H -#define SPI_H +#define SPI_H //////////////////////////////////////////////////////////////////////////////// diff --git a/Base/src/oled-draw.c b/Base/src/oled-draw.c index c9d79fe..c15af73 100644 --- a/Base/src/oled-draw.c +++ b/Base/src/oled-draw.c @@ -16,6 +16,7 @@ #include "oled-draw.h" #include "config.h" +#include "utils.h" #include "oled.h" #include @@ -48,7 +49,7 @@ * @param[in] colour Colour of the point * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Point(oled_device_t const * const device, uint8_t const x, uint8_t const y, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_Point(oled_device_t const * const device, uint8_t const x, uint8_t const y, oled_packed_colour_t const colour); /** * @brief Draws a line on the OLED screen. @@ -59,7 +60,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Point(oled_device_t const * * @param[in] colour Colour of the line * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Line(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_Line(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour); /** * @brief Draws a rectangle on the OLED screen. @@ -70,7 +71,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Line(oled_device_t const * * @param[in] colour Colour of the border * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Rectangle(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_Rectangle(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour); /** * @brief Draws a filled rectangle on the OLED screen. @@ -80,7 +81,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Rectangle(oled_device_t con * @param[in] colour Colour of the rectangle * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_FilledRectangle(oled_device_t const * const device, oled_point_t const startPoint, oled_point_t const endPoint, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_FilledRectangle(oled_device_t const * const device, oled_point_t const startPoint, oled_point_t const endPoint, oled_packed_colour_t const colour); /** * @brief Draws a circle on the OLED screen. @@ -91,7 +92,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_FilledRectangle(oled_device * @param[in] colour Colour of the border * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Circle(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, uint8_t const width, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_Circle(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, uint8_t const width, oled_packed_colour_t const colour); /** * @brief Draws a disc on the OLED screen. @@ -101,7 +102,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Circle(oled_device_t const * @param[in] colour Colour of the disc * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Disc(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_Disc(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, oled_packed_colour_t const colour); /** * @brief Draws a 24-bit RGB colour bitmap on the OLED screen. @@ -112,7 +113,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Disc(oled_device_t const * * @param[in] start Start position (top left corner) * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Bitmap(oled_device_t const * const device, oled_packed_colour_t const * const bitmap, uint8_t const xSize, uint8_t const ySize, oled_point_t const start); +INLINE void OLED_DRAW_Bitmap(oled_device_t const * const device, oled_packed_colour_t const * const bitmap, uint8_t const xSize, uint8_t const ySize, oled_point_t const start); /** * @brief Draws a character on the OLED screen. @@ -124,7 +125,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Bitmap(oled_device_t const * @param[in] colour Colour of the character * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_Character(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const character, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_Character(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const character, oled_packed_colour_t const colour); /** * @brief Draws a string on the OLED screen. @@ -136,7 +137,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Character(oled_device_t con * @param[in] colour Colour of the characters * @return None **/ -__attribute__((always_inline)) inline void OLED_DRAW_String(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const * const data, oled_packed_colour_t const colour); +INLINE void OLED_DRAW_String(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const * const data, oled_packed_colour_t const colour); /** * @brief Unified API to draw a point on the OLED screen. @@ -216,7 +217,7 @@ void OLED_DrawString(oled_device_t const * const device, oled_shape_t const * co // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline void OLED_DRAW_Point(oled_device_t const * const device, uint8_t const x, uint8_t const y, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_Point(oled_device_t const * const device, uint8_t const x, uint8_t const y, oled_packed_colour_t const colour) { if ((x > OLED_DRAW_MAX_DIMENSION) || (y > OLED_DRAW_MAX_DIMENSION)) { @@ -233,7 +234,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Point(oled_device_t const * return; } -__attribute__((always_inline)) inline void OLED_DRAW_Line(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_Line(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour) { uint8_t const lineWidth = (width > 1) ? width : 1; @@ -285,7 +286,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Line(oled_device_t const * return; } -__attribute__((always_inline)) inline void OLED_DRAW_Rectangle(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_Rectangle(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, uint8_t const width, oled_packed_colour_t const colour) { oled_point_t const topLeft = { start.x, start.y }; @@ -301,7 +302,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Rectangle(oled_device_t con return; } -__attribute__((always_inline)) inline void OLED_DRAW_FilledRectangle(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_FilledRectangle(oled_device_t const * const device, oled_point_t const start, oled_point_t const end, oled_packed_colour_t const colour) { OLED_SetColumnAddressBounds(device, start.x, end.x); OLED_SetRowAddressBounds(device, start.y, end.y); @@ -321,7 +322,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_FilledRectangle(oled_device return; } -__attribute__((always_inline)) inline void OLED_DRAW_Circle(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, uint8_t const width, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_Circle(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, uint8_t const width, oled_packed_colour_t const colour) { int8_t x; int8_t y; @@ -365,7 +366,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Circle(oled_device_t const return; } -__attribute__((always_inline)) inline void OLED_DRAW_Disc(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_Disc(oled_device_t const * const device, oled_point_t const center, uint8_t const radius, oled_packed_colour_t const colour) { int8_t y = ((radius > 1) ? radius : 1) + 1; int8_t x = 0; @@ -403,7 +404,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Disc(oled_device_t const * return; } -__attribute__((always_inline)) inline void OLED_DRAW_Bitmap(oled_device_t const * const device, oled_packed_colour_t const * const bitmap, uint8_t const xSize, uint8_t const ySize, oled_point_t const start) +INLINE void OLED_DRAW_Bitmap(oled_device_t const * const device, oled_packed_colour_t const * const bitmap, uint8_t const xSize, uint8_t const ySize, oled_point_t const start) { OLED_SetColumnAddressBounds(device, start.x, start.x + xSize - 1); OLED_SetRowAddressBounds(device, start.y, start.y + ySize - 1); @@ -423,7 +424,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Bitmap(oled_device_t const return; } -__attribute__((always_inline)) inline void OLED_DRAW_Character(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const character, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_Character(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const character, oled_packed_colour_t const colour) { static uint8_t const font[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x00, 0xE0, 0x00, 0xE0, 0x00, /* ' ' AND ! AND " */ @@ -488,7 +489,7 @@ __attribute__((always_inline)) inline void OLED_DRAW_Character(oled_device_t con return; } -__attribute__((always_inline)) inline void OLED_DRAW_String(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const * const data, oled_packed_colour_t const colour) +INLINE void OLED_DRAW_String(oled_device_t const * const device, oled_point_t const start, uint8_t const xScale, uint8_t const yScale, uint8_t const * const data, oled_packed_colour_t const colour) { uint8_t character = '\0'; uint8_t const * currentStringPosition = data; diff --git a/Base/src/oled.c b/Base/src/oled.c index 082c818..9c69206 100644 --- a/Base/src/oled.c +++ b/Base/src/oled.c @@ -100,75 +100,75 @@ static oled_error_code_t OLED_CheckNull(oled_device_t const * const device); * @param[in] word Word to send * @return None **/ -__attribute__((always_inline)) inline static void OLED_SendWord(oled_device_t const * const device, uint16_t const word); +STATIC_INLINE void OLED_SendWord(oled_device_t const * const device, uint16_t const word); /** * @brief Set as output and clear the OLED control pins. * @return None **/ -__attribute__((always_inline)) inline static void OLED_InitializePins(void); +STATIC_INLINE void OLED_InitializePins(void); /** * @brief Enables OLED data mode. * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetDataMode(void); +STATIC_INLINE void OLED_SetDataMode(void); /** * @brief Enables OLED command mode. * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetCommandMode(void); +STATIC_INLINE void OLED_SetCommandMode(void); /** * @brief Enables OLED read mode. * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetReadMode(void); +STATIC_INLINE void OLED_SetReadMode(void); /** * @brief Enables OLED write mode. * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetWriteMode(void); +STATIC_INLINE void OLED_SetWriteMode(void); /** * @brief Sets the OLED reset pin. * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetResetPin(void); +STATIC_INLINE void OLED_SetResetPin(void); /** * @brief Clears the OLED reset pin. * @return None **/ -__attribute__((always_inline)) inline static void OLED_ClearResetPin(void); +STATIC_INLINE void OLED_ClearResetPin(void); /** * @brief Sets the OLED enable pin. * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetEnablePin(void); +STATIC_INLINE void OLED_SetEnablePin(void); /** * @brief Clears the OLED enable pin. * @return None **/ -__attribute__((always_inline)) inline static void OLED_ClearEnablePin(void); +STATIC_INLINE void OLED_ClearEnablePin(void); /** * @brief Sets the OLED chip select pin. * @param[in] device OLED device * @return None **/ -__attribute__((always_inline)) inline static void OLED_StartTransaction(oled_device_t const * const device); +STATIC_INLINE void OLED_StartTransaction(oled_device_t const * const device); /** * @brief Clears the OLED chip select pin. * @param[in] device OLED device * @return None **/ -__attribute__((always_inline)) inline static void OLED_EndTransaction(oled_device_t const * const device); +STATIC_INLINE void OLED_EndTransaction(oled_device_t const * const device); /** * @brief Sends the command to the OLED device that sets the row or column @@ -180,28 +180,28 @@ __attribute__((always_inline)) inline static void OLED_EndTransaction(oled_devic * @param[in] offset RAM offset * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetAddressBoundsWithOffset(oled_device_t const * const device, oled_command_t const command, uint8_t const min, uint8_t const max, uint8_t const offset); +STATIC_INLINE void OLED_SetAddressBoundsWithOffset(oled_device_t const * const device, oled_command_t const command, uint8_t const min, uint8_t const max, uint8_t const offset); /** * @brief Sets the display initial set-up options. * @param[in] device OLED device * @return None **/ -__attribute__((always_inline)) inline static void OLED_SetDisplayOptions(oled_device_t const * const device); +STATIC_INLINE void OLED_SetDisplayOptions(oled_device_t const * const device); /** * @brief Enables the OLED sleep mode. * @param[in] device OLED device * @return None **/ -__attribute__((always_inline)) inline static void OLED_EnableSleepMode(oled_device_t const * const device); +STATIC_INLINE void OLED_EnableSleepMode(oled_device_t const * const device); /** * @brief Disables the OLED sleep mode. * @param[in] device OLED device * @return None **/ -__attribute__((always_inline)) inline static void OLED_DisableSleepMode(oled_device_t const * const device); +STATIC_INLINE void OLED_DisableSleepMode(oled_device_t const * const device); /** * @brief Sends a command to the OLED device. @@ -235,14 +235,14 @@ static oled_error_code_t OLED_CheckNull(oled_device_t const * const device) } } -__attribute__((always_inline)) inline static void OLED_SendWord(oled_device_t const * const device, uint16_t const word) +STATIC_INLINE void OLED_SendWord(oled_device_t const * const device, uint16_t const word) { uint8_t const dataBuffer[2] = { (uint8_t) (word >> 8), (uint8_t) (word & 0x00FF) }; device->spiDevice->SendData(dataBuffer, 2); } -__attribute__((always_inline)) inline static void OLED_InitializePins(void) +STATIC_INLINE void OLED_InitializePins(void) { OLED_OUT(OLED_DATA_COMMAND); OLED_CLR(OLED_DATA_COMMAND); @@ -259,77 +259,77 @@ __attribute__((always_inline)) inline static void OLED_InitializePins(void) return; } -__attribute__((always_inline)) inline static void OLED_SetDataMode(void) +STATIC_INLINE void OLED_SetDataMode(void) { OLED_SET(OLED_DATA_COMMAND); return; } -__attribute__((always_inline)) inline static void OLED_SetCommandMode(void) +STATIC_INLINE void OLED_SetCommandMode(void) { OLED_CLR(OLED_DATA_COMMAND); return; } -__attribute__((always_inline)) inline static void OLED_SetReadMode(void) +STATIC_INLINE void OLED_SetReadMode(void) { OLED_SET(OLED_READ_WRITE); return; } -__attribute__((always_inline)) inline static void OLED_SetWriteMode(void) +STATIC_INLINE void OLED_SetWriteMode(void) { OLED_CLR(OLED_READ_WRITE); return; } -__attribute__((always_inline)) inline static void OLED_SetResetPin(void) +STATIC_INLINE void OLED_SetResetPin(void) { OLED_SET(OLED_RESET); return; } -__attribute__((always_inline)) inline static void OLED_ClearResetPin(void) +STATIC_INLINE void OLED_ClearResetPin(void) { OLED_CLR(OLED_RESET); return; } -__attribute__((always_inline)) inline static void OLED_SetEnablePin(void) +STATIC_INLINE void OLED_SetEnablePin(void) { OLED_SET(OLED_ENABLE); return; } -__attribute__((always_inline)) inline static void OLED_ClearEnablePin(void) +STATIC_INLINE void OLED_ClearEnablePin(void) { OLED_CLR(OLED_ENABLE); return; } -__attribute__((always_inline)) inline static void OLED_StartTransaction(oled_device_t const * const device) +STATIC_INLINE void OLED_StartTransaction(oled_device_t const * const device) { device->spiDevice->ClientSelect(OLED_CHIP_SELECT); return; } -__attribute__((always_inline)) inline static void OLED_EndTransaction(oled_device_t const * const device) +STATIC_INLINE void OLED_EndTransaction(oled_device_t const * const device) { device->spiDevice->ClientDeselect(OLED_CHIP_SELECT); return; } -__attribute__((always_inline)) inline static void OLED_SetAddressBoundsWithOffset(oled_device_t const * const device, oled_command_t const command, uint8_t const min, uint8_t const max, uint8_t const offset) +STATIC_INLINE void OLED_SetAddressBoundsWithOffset(oled_device_t const * const device, oled_command_t const command, uint8_t const min, uint8_t const max, uint8_t const offset) { uint8_t const payload[2] = { offset + (min > OLED_MAX_ADDRESS_BOUND ? OLED_MAX_ADDRESS_BOUND : min), @@ -341,7 +341,7 @@ __attribute__((always_inline)) inline static void OLED_SetAddressBoundsWithOffse return; } -__attribute__((always_inline)) inline static void OLED_SetDisplayOptions(oled_device_t const * const device) +STATIC_INLINE void OLED_SetDisplayOptions(oled_device_t const * const device) { uint8_t payload = 0; @@ -370,14 +370,14 @@ __attribute__((always_inline)) inline static void OLED_SetDisplayOptions(oled_de return; } -__attribute__((always_inline)) inline static void OLED_EnableSleepMode(oled_device_t const * const device) +STATIC_INLINE void OLED_EnableSleepMode(oled_device_t const * const device) { OLED_SendCommand(device, OLED_SET_SLEEP_MODE_ON, NULL, 0); return; } -__attribute__((always_inline)) inline static void OLED_DisableSleepMode(oled_device_t const * const device) +STATIC_INLINE void OLED_DisableSleepMode(oled_device_t const * const device) { OLED_SendCommand(device, OLED_SET_SLEEP_MODE_OFF, NULL, 0); @@ -417,7 +417,7 @@ static oled_error_code_t OLED_SendCommand(oled_device_t const * const device, ol // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline void OLED_Initialize(oled_device_t * const device, spi_t const * const spiDevice) +INLINE void OLED_Initialize(oled_device_t * const device, spi_t const * const spiDevice) { OLED_InitializePins(); @@ -436,7 +436,7 @@ __attribute__((always_inline)) inline void OLED_Initialize(oled_device_t * const return; } -__attribute__((always_inline)) inline void OLED_StartWritingDisplay(oled_device_t const * const device) +INLINE void OLED_StartWritingDisplay(oled_device_t const * const device) { OLED_SendCommand(device, OLED_WRITE_RAM, NULL, 0); @@ -446,7 +446,7 @@ __attribute__((always_inline)) inline void OLED_StartWritingDisplay(oled_device_ return; } -__attribute__((always_inline)) inline void OLED_StopWritingDisplay(oled_device_t const * const device) +INLINE void OLED_StopWritingDisplay(oled_device_t const * const device) { OLED_EndTransaction(device); OLED_SetCommandMode(); @@ -484,21 +484,21 @@ oled_colour_t OLED_ParsePackedToRGB(oled_packed_colour_t const rawData) return parsedColour; } -__attribute__((always_inline)) inline void OLED_SendColor(oled_device_t const * const device, oled_packed_colour_t const colour) +INLINE void OLED_SendColor(oled_device_t const * const device, oled_packed_colour_t const colour) { OLED_SendWord(device, colour); return; } -__attribute__((always_inline)) inline void OLED_SetRowAddressBounds(oled_device_t const * const device, uint8_t const min, uint8_t const max) +INLINE void OLED_SetRowAddressBounds(oled_device_t const * const device, uint8_t const min, uint8_t const max) { OLED_SetAddressBoundsWithOffset(device, OLED_SET_ROW_ADDRESS, min, max, 0); return; } -__attribute__((always_inline)) inline void OLED_SetColumnAddressBounds(oled_device_t const * const device, uint8_t const min, uint8_t const max) +INLINE void OLED_SetColumnAddressBounds(oled_device_t const * const device, uint8_t const min, uint8_t const max) { OLED_SetAddressBoundsWithOffset(device, OLED_SET_COLUMN_ADDRESS, min, max, 16); diff --git a/Base/src/spi.c b/Base/src/spi.c index 20d80ba..3f2e124 100644 --- a/Base/src/spi.c +++ b/Base/src/spi.c @@ -16,6 +16,7 @@ #include "spi.h" #include "config.h" +#include "utils.h" #include @@ -36,47 +37,47 @@ * @brief Initialize the SPI module on the SPI0 bus. * @return None **/ -__attribute__((always_inline)) inline static void SPI0_Inititialize(void); +STATIC_INLINE void SPI0_Inititialize(void); /** * @brief Enables (active low) chip select on the SPI0 bus. * @param[in] chipSelect The corresponding chip select pin * @return None **/ -__attribute__((always_inline)) inline static void SPI0_ClientSelect(spi_chip_select_t const chipSelect); +STATIC_INLINE void SPI0_ClientSelect(spi_chip_select_t const chipSelect); /** * @brief Disables (active low) chip select on the SPI0 bus. * @param[in] chipSelect The corresponding chip select pin * @return None **/ -__attribute__((always_inline)) inline static void SPI0_ClientDeselect(spi_chip_select_t const chipSelect); +STATIC_INLINE void SPI0_ClientDeselect(spi_chip_select_t const chipSelect); /** * @brief Waits for the SPI0 bus to be ready. * @return None **/ -__attribute__((always_inline)) inline static void SPI0_WaitDataReady(void); +STATIC_INLINE void SPI0_WaitDataReady(void); /** * @brief Sends a byte over the SPI0 bus. * @param[in] byte The byte to send * @return None **/ -__attribute__((always_inline)) inline static void SPI0_SendByte(uint8_t const byte); +STATIC_INLINE void SPI0_SendByte(uint8_t const byte); /** * @brief Receives a byte over the SPI0 bus. * @return uint8_t The byte received **/ -__attribute__((always_inline)) inline static uint8_t SPI0_ReceiveByte(void); +STATIC_INLINE uint8_t SPI0_ReceiveByte(void); /** * @brief Sends a byte over the SPI0 bus and receives a byte back. * @param[in] byte The byte to send * @return uint8_t The byte received **/ -__attribute__((always_inline)) inline static uint8_t SPI0_ExchangeByte(uint8_t const byte); +STATIC_INLINE uint8_t SPI0_ExchangeByte(uint8_t const byte); /** * @brief Sends a specified number of bytes to the device using the SPI bus. @@ -116,7 +117,7 @@ static spi_error_code_t SPI0_ExchangeData(uint8_t * const dataForExchange, uint8 // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline static void SPI0_Inititialize(void) +STATIC_INLINE void SPI0_Inititialize(void) { // PA4 - MOSI - OUT | PA5 - MISO - IN | PA6 - SCK - OUT PORTA.DIRSET = PIN4_bm | PIN6_bm; @@ -241,7 +242,7 @@ static spi_error_code_t SPI0_ExchangeData(uint8_t * const dataForExchange, uint8 return SPI_OK; } -__attribute__((always_inline)) inline static void SPI0_ClientSelect(spi_chip_select_t const chipSelect) +STATIC_INLINE void SPI0_ClientSelect(spi_chip_select_t const chipSelect) { switch (chipSelect) { @@ -274,7 +275,7 @@ __attribute__((always_inline)) inline static void SPI0_ClientSelect(spi_chip_sel return; } -__attribute__((always_inline)) inline static void SPI0_ClientDeselect(spi_chip_select_t const chipSelect) +STATIC_INLINE void SPI0_ClientDeselect(spi_chip_select_t const chipSelect) { switch (chipSelect) { @@ -307,7 +308,7 @@ __attribute__((always_inline)) inline static void SPI0_ClientDeselect(spi_chip_s return; } -__attribute__((always_inline)) inline static void SPI0_WaitDataReady(void) +STATIC_INLINE void SPI0_WaitDataReady(void) { while (!(SPI0.INTFLAGS & SPI_RXCIF_bm)) { @@ -317,19 +318,19 @@ __attribute__((always_inline)) inline static void SPI0_WaitDataReady(void) return; } -__attribute__((always_inline)) inline static void SPI0_SendByte(uint8_t const byte) +STATIC_INLINE void SPI0_SendByte(uint8_t const byte) { SPI0.DATA = byte; return; } -__attribute__((always_inline)) inline static uint8_t SPI0_ReceiveByte(void) +STATIC_INLINE uint8_t SPI0_ReceiveByte(void) { return SPI0.DATA; } -__attribute__((always_inline)) inline static uint8_t SPI0_ExchangeByte(uint8_t const byte) +STATIC_INLINE uint8_t SPI0_ExchangeByte(uint8_t const byte) { SPI0_SendByte(byte); @@ -354,4 +355,4 @@ spi_t const spi0 = { .ExchangeData = SPI0_ExchangeData, .ClientSelect = SPI0_ClientSelect, .ClientDeselect = SPI0_ClientDeselect, -}; \ No newline at end of file +}; diff --git a/include/bluetooth.h b/include/bluetooth.h index c26190e..278661c 100644 --- a/include/bluetooth.h +++ b/include/bluetooth.h @@ -8,7 +8,7 @@ #ifndef BLUETOOTH_H -#define BLUETOOTH_H +#define BLUETOOTH_H //////////////////////////////////////////////////////////////////////////////// @@ -98,4 +98,4 @@ bluetooth_error_code_t BLUETOOTH_ReceiveData(bluetooth_device_t const * const de **/ void BLUETOOTH_ReceiveCallback(uint8_t const data); -#endif // BLUETOOTH_H \ No newline at end of file +#endif // BLUETOOTH_H diff --git a/include/bme280.h b/include/bme280.h index 7d737ef..3b14c84 100644 --- a/include/bme280.h +++ b/include/bme280.h @@ -8,7 +8,7 @@ #ifndef BME280_H -#define BME280_H +#define BME280_H //////////////////////////////////////////////////////////////////////////////// @@ -295,4 +295,4 @@ void BME280_SerializeSensorData(bme280_device_t const * const device, uint8_t * extern bme280_handler_t const BME280_I2C_Handler; -#endif // BME280_H \ No newline at end of file +#endif // BME280_H diff --git a/include/config.h b/include/config.h index 3e0d13a..bc9e482 100644 --- a/include/config.h +++ b/include/config.h @@ -8,7 +8,7 @@ #ifndef CONFIG_H -#define CONFIG_H +#define CONFIG_H /** * @brief This must be defined at the top to have other includes working. diff --git a/include/crc8.h b/include/crc8.h index 56be747..942c940 100644 --- a/include/crc8.h +++ b/include/crc8.h @@ -8,7 +8,7 @@ #ifndef CRC8_H -#define CRC8_H +#define CRC8_H //////////////////////////////////////////////////////////////////////////////// @@ -39,4 +39,4 @@ **/ uint8_t CRC8_Compute(uint8_t const * const data, uint8_t const dataLength); -#endif // CRC8_H \ No newline at end of file +#endif // CRC8_H diff --git a/include/i2c.h b/include/i2c.h index 6b2fa6f..6915917 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -8,7 +8,7 @@ #ifndef I2C_H -#define I2C_H +#define I2C_H //////////////////////////////////////////////////////////////////////////////// diff --git a/include/uart.h b/include/uart.h index 87dad3c..0c0b32c 100644 --- a/include/uart.h +++ b/include/uart.h @@ -8,7 +8,7 @@ #ifndef UART_H -#define UART_H +#define UART_H //////////////////////////////////////////////////////////////////////////////// diff --git a/include/utils.h b/include/utils.h index 3ab13ca..de602e5 100644 --- a/include/utils.h +++ b/include/utils.h @@ -5,6 +5,11 @@ * * @brief Header file for the Utils module **/ + + +#ifndef UTILS_H +#define UTILS_H + //////////////////////////////////////////////////////////////////////////////// // // @@ -47,6 +52,10 @@ #define PauseMiliseconds(MILIS) do { _delay_ms((MILIS)); } while (false) #define PauseMicroseconds(MICROS) do { _delay_us((MICROS)); } while (false) -// Force inline for static functions +// Force inline for functions + +#define INLINE __attribute__((always_inline)) inline +#define STATIC_INLINE __attribute__((always_inline)) static inline + -#define STATIC_INLINE __attribute__((always_inline)) static inline \ No newline at end of file +#endif // UTILS_H diff --git a/include/vector.h b/include/vector.h index 7aefed3..13a874a 100644 --- a/include/vector.h +++ b/include/vector.h @@ -8,7 +8,7 @@ #ifndef VECTOR_H -#define VECTOR_H +#define VECTOR_H //////////////////////////////////////////////////////////////////////////////// @@ -185,4 +185,4 @@ uint64_t Vector_FirstQuadWord(vector_t const * const vector); uint64_t Vector_LastQuadWord(vector_t const * const vector); -#endif // VECTOR_H \ No newline at end of file +#endif // VECTOR_H diff --git a/src/bluetooth.c b/src/bluetooth.c index 0f062b9..90b6725 100644 --- a/src/bluetooth.c +++ b/src/bluetooth.c @@ -94,7 +94,7 @@ static bluetooth_error_code_t BLUETOOTH_CheckNull(bluetooth_device_t const * con * @param[in] bufferSize Size of the buffer * @return None **/ -__attribute__((always_inline)) inline static void BLUETOOTH_SendPreparedData(bluetooth_device_t const * const device, uint8_t const * const buffer, uint8_t const bufferSize); +STATIC_INLINE void BLUETOOTH_SendPreparedData(bluetooth_device_t const * const device, uint8_t const * const buffer, uint8_t const bufferSize); /** * @brief Waits for 500 miliseconds to receive a packet containing an ACK or @@ -123,13 +123,13 @@ static bluetooth_response_t BLUETOOTH_GetResponseReceived(void); * @retval true The byte is the last byte of the packet * @retval false The byte is not the last byte of the packet **/ -__attribute__((always_inline)) inline static bool BLUETOOTH_IsLastByte(void); +STATIC_INLINE bool BLUETOOTH_IsLastByte(void); /** * @brief Computes the number of reamining bytes to be received. * @return uint8_t Number of remaining bytes **/ -__attribute__((always_inline)) inline static uint8_t BLUETOOTH_GetNumberOfBytesToReceive(void); +STATIC_INLINE uint8_t BLUETOOTH_GetNumberOfBytesToReceive(void); /** * @brief Computes the checksum of the received packet. @@ -169,7 +169,7 @@ static void BLUETOOTH_SendNotAcknowledge(bluetooth_device_t const * const device * @param[in] response ACK or NACK * @return None **/ -__attribute__((always_inline)) inline static void BLUETOOTH_SendResponse(bluetooth_device_t const * const device, bluetooth_response_t const response); +STATIC_INLINE void BLUETOOTH_SendResponse(bluetooth_device_t const * const device, bluetooth_response_t const response); /** * @brief Computes the checksum of a byte buffer. @@ -177,14 +177,14 @@ __attribute__((always_inline)) inline static void BLUETOOTH_SendResponse(bluetoo * @param[in] dataLength Length of the byte buffer * @return uint8_t The CRC8 checksum **/ -__attribute__((always_inline)) inline static uint8_t BLUETOOTH_ComputeChecksum(uint8_t const * const data, uint8_t const dataLength); +STATIC_INLINE uint8_t BLUETOOTH_ComputeChecksum(uint8_t const * const data, uint8_t const dataLength); /** * @brief Ends the current transmission by clearing the vector and trasmission * flag. * @return None **/ -__attribute__((always_inline)) inline static void BLUETOOTH_EndTransmission(void); +STATIC_INLINE void BLUETOOTH_EndTransmission(void); //////////////////////////////////////////////////////////////////////////////// @@ -216,7 +216,7 @@ static bluetooth_error_code_t BLUETOOTH_CheckNull(bluetooth_device_t const * con } } -__attribute__((always_inline)) inline static void BLUETOOTH_SendPreparedData(bluetooth_device_t const * const device, uint8_t const * const buffer, uint8_t const bufferSize) +STATIC_INLINE void BLUETOOTH_SendPreparedData(bluetooth_device_t const * const device, uint8_t const * const buffer, uint8_t const bufferSize) { uint8_t const newLength = bufferSize + 2; @@ -270,12 +270,12 @@ static bluetooth_response_t BLUETOOTH_GetResponseReceived(void) } } -__attribute__((always_inline)) inline static bool BLUETOOTH_IsLastByte(void) +STATIC_INLINE bool BLUETOOTH_IsLastByte(void) { return BLUETOOTH_GetNumberOfBytesToReceive() == receiveBuffer.bufferSize; } -__attribute__((always_inline)) inline static uint8_t BLUETOOTH_GetNumberOfBytesToReceive(void) +STATIC_INLINE uint8_t BLUETOOTH_GetNumberOfBytesToReceive(void) { return Vector_FirstByte(&receiveBuffer) + 1; } @@ -317,7 +317,7 @@ static void BLUETOOTH_SendNotAcknowledge(bluetooth_device_t const * const device return; } -__attribute__((always_inline)) inline static void BLUETOOTH_SendResponse(bluetooth_device_t const * const device, bluetooth_response_t const response) +STATIC_INLINE void BLUETOOTH_SendResponse(bluetooth_device_t const * const device, bluetooth_response_t const response) { uint8_t packet[BLUETOOTH_ACK_NACK_SIZE] = { 0 }; @@ -330,12 +330,12 @@ __attribute__((always_inline)) inline static void BLUETOOTH_SendResponse(bluetoo return; } -__attribute__((always_inline)) inline static uint8_t BLUETOOTH_ComputeChecksum(uint8_t const * const data, uint8_t const dataLength) +STATIC_INLINE uint8_t BLUETOOTH_ComputeChecksum(uint8_t const * const data, uint8_t const dataLength) { return CRC8_Compute(data, dataLength + 1); } -__attribute__((always_inline)) inline static void BLUETOOTH_EndTransmission(void) +STATIC_INLINE void BLUETOOTH_EndTransmission(void) { transsmitionStatus = BLUETOOTH_IDLE; Vector_Clear(&receiveBuffer); diff --git a/src/bme280.c b/src/bme280.c index dcc26bf..9e7614c 100644 --- a/src/bme280.c +++ b/src/bme280.c @@ -137,7 +137,7 @@ typedef struct BME280_UNCOMPENSATED_DATA * @retval BME280_OK If the device is valid * @retval BME280_NULL_POINTER If a NULL pointer was found **/ -__attribute__((always_inline)) inline static bme280_error_code_t BME280_CheckNull(bme280_device_t const * const device); +STATIC_INLINE bme280_error_code_t BME280_CheckNull(bme280_device_t const * const device); /** * @brief Reads a number of one byte registers from the device using I2C and @@ -361,7 +361,7 @@ static bme280_error_code_t BME280_WritePowerMode(bme280_device_t * const device, // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline static bme280_error_code_t BME280_CheckNull(bme280_device_t const * const device) +STATIC_INLINE bme280_error_code_t BME280_CheckNull(bme280_device_t const * const device) { if (device == NULL || device->handler == NULL || device->i2cDevice == NULL) { @@ -1066,4 +1066,4 @@ void BME280_SerializeSensorData(bme280_device_t const * const device, uint8_t * bme280_handler_t const BME280_I2C_Handler = { .I2C_Read = BME280_I2C_ReadRegisters, .I2C_Write = BME280_I2C_WriteRegisters, -}; \ No newline at end of file +}; diff --git a/src/config.c b/src/config.c index d0f6b8b..070f57c 100644 --- a/src/config.c +++ b/src/config.c @@ -16,6 +16,7 @@ #include "config.h" #include "uart.h" +#include "utils.h" #include #include @@ -29,7 +30,7 @@ // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline void SetClockFrequencyWithPrescaler(uint8_t const frequency, uint8_t const prescaler) +INLINE void SetClockFrequencyWithPrescaler(uint8_t const frequency, uint8_t const prescaler) { SetClockFrequency(frequency); @@ -39,7 +40,7 @@ __attribute__((always_inline)) inline void SetClockFrequencyWithPrescaler(uint8_ return; } -__attribute__((always_inline)) inline void SetClockFrequency(uint8_t const frequency) +INLINE void SetClockFrequency(uint8_t const frequency) { // Enable external crystal oscillator _PROTECTED_WRITE(CLKCTRL.XOSC32KCTRLA, CLKCTRL_ENABLE_bm); @@ -53,12 +54,12 @@ __attribute__((always_inline)) inline void SetClockFrequency(uint8_t const frequ return; } -__attribute__((always_inline)) inline void TightLoopContents(void) +INLINE void TightLoopContents(void) { return; } -__attribute__((always_inline)) inline void PrintForLogging(char const * const message) +INLINE void PrintForLogging(char const * const message) { #if defined __AVR128DA48__ uart1.Print(message); diff --git a/src/i2c.c b/src/i2c.c index 90acd22..c258899 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -14,6 +14,8 @@ #include "i2c.h" +#include "utils.h" + #include #include @@ -63,7 +65,7 @@ typedef enum I2C_DATA_DIRECTION * @param[in] mode The mode of the I2C bus: Standard, Fast or Fast Plus * @return None **/ -__attribute__((always_inline)) inline static void I2C0_Inititialize(i2c_mode_t const mode); +STATIC_INLINE void I2C0_Inititialize(i2c_mode_t const mode); /** * @brief Sends a specific number of bytes to the device on the I2C bus. @@ -132,7 +134,7 @@ static uint8_t I2C0_SetAdressDirectionBit(uint8_t const deviceAddress, i2c_data_ * @brief Ends the I2C communication by sending a stop condition. * @return None **/ -__attribute__((always_inline)) inline static void I2C0_EndTransation(void); +STATIC_INLINE void I2C0_EndTransation(void); //////////////////////////////////////////////////////////////////////////////// @@ -141,7 +143,7 @@ __attribute__((always_inline)) inline static void I2C0_EndTransation(void); // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline static void I2C0_Inititialize(i2c_mode_t const mode) +STATIC_INLINE void I2C0_Inititialize(i2c_mode_t const mode) { #if defined __AVR128DA48__ // Select I2C pins to PC2 - SDA and PC3 - SCL @@ -349,7 +351,7 @@ static bool I2C0_ClientAvailable(uint8_t const clientAddress) return ( returnValue == I2C_OK ); } -__attribute__((always_inline)) inline static void I2C0_EndTransation(void) +STATIC_INLINE void I2C0_EndTransation(void) { // Sends a STOP condition on the bus and clears the internal state TWI0.MCTRLB = TWI_MCMD_STOP_gc; diff --git a/src/uart.c b/src/uart.c index 6d7ade0..cdcf08a 100644 --- a/src/uart.c +++ b/src/uart.c @@ -16,6 +16,7 @@ #include "uart.h" #include "config.h" +#include "utils.h" #include #include @@ -62,7 +63,7 @@ * received * @return None **/ -__attribute__((always_inline)) inline static void UART0_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback); +STATIC_INLINE void UART0_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback); /** * @brief Initializes the UART0 module by setting the baud rate and enabling the @@ -71,7 +72,7 @@ __attribute__((always_inline)) inline static void UART0_InitializeWithReceive(ui * @param[in] baudRate The baud rate * @return None **/ -__attribute__((always_inline)) inline static void UART0_Initialize(uint32_t const baudRate); +STATIC_INLINE void UART0_Initialize(uint32_t const baudRate); /** * @brief Sends a null-terminated string over UART0. @@ -85,7 +86,7 @@ static void UART0_Print(char const * const string); * @param[in] character The character to be sent * @return None */ -__attribute__((always_inline)) inline static void UART0_PrintChar(char const character); +STATIC_INLINE void UART0_PrintChar(char const character); /** * @brief Sends a number of bytes over UART0. @@ -108,7 +109,7 @@ static void UART0_SendByte(uint8_t const dataByte); * @retval true The UART1 module is busy. * @retval false The UART1 module is ready. **/ -__attribute__((always_inline)) inline static bool UART0_TXBusy(void); +STATIC_INLINE bool UART0_TXBusy(void); /** * @brief Registers a callback function to be called when a byte is received @@ -116,7 +117,7 @@ __attribute__((always_inline)) inline static bool UART0_TXBusy(void); * @param[in] callback The callback function to be registered * @return None **/ -__attribute__((always_inline)) inline static void UART0_RegisterCallback(uart_callback_t const callback); +STATIC_INLINE void UART0_RegisterCallback(uart_callback_t const callback); #if ( defined UART_PRINTF ) && ( defined __AVR64DD32__ ) @@ -127,7 +128,7 @@ __attribute__((always_inline)) inline static void UART0_RegisterCallback(uart_ca * @param[in] stream The stream used to send the character * @return int8_t Always returns 0 **/ -__attribute__((always_inline)) inline static int8_t UART0_SendChar(char const character, FILE * const stream); +STATIC_INLINE int8_t UART0_SendChar(char const character, FILE * const stream); #endif // UART_PRINTF && __AVR64DD32__ @@ -147,7 +148,7 @@ __attribute__((always_inline)) inline static int8_t UART0_SendChar(char const ch * received * @return None **/ -__attribute__((always_inline)) inline static void UART1_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback); +STATIC_INLINE void UART1_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback); /** * @brief Initializes the UART1 module by setting the baud rate and enabling the @@ -156,7 +157,7 @@ __attribute__((always_inline)) inline static void UART1_InitializeWithReceive(ui * @param[in] baudRate The baud rate * @return None **/ -__attribute__((always_inline)) inline static void UART1_Initialize(uint32_t const baudRate); +STATIC_INLINE void UART1_Initialize(uint32_t const baudRate); /** * @brief Sends a null-terminated string over UART1. @@ -170,7 +171,7 @@ static void UART1_Print(char const * const string); * @param[in] character The character to be sent * @return None */ -__attribute__((always_inline)) inline static void UART1_PrintChar(char const character); +STATIC_INLINE void UART1_PrintChar(char const character); /** * @brief Sends a number of bytes over UART1. @@ -193,7 +194,7 @@ static void UART1_SendByte(uint8_t const dataByte); * @retval true The UART1 module is busy. * @retval false The UART1 module is ready. **/ -__attribute__((always_inline)) inline static bool UART1_TXBusy(void); +STATIC_INLINE bool UART1_TXBusy(void); /** * @brief Registers a callback function to be called when a byte is received @@ -201,7 +202,7 @@ __attribute__((always_inline)) inline static bool UART1_TXBusy(void); * @param[in] callback The callback function to be registered * @return None **/ -__attribute__((always_inline)) inline static void UART1_RegisterCallback(uart_callback_t const callback); +STATIC_INLINE void UART1_RegisterCallback(uart_callback_t const callback); #if ( defined UART_PRINTF ) && ( defined __AVR128DA48__ ) @@ -212,7 +213,7 @@ __attribute__((always_inline)) inline static void UART1_RegisterCallback(uart_ca * @param[in] stream The stream used to send the character * @return int8_t Always returns 0 **/ -__attribute__((always_inline)) inline static int8_t UART1_SendChar(char const character, FILE * const stream); +STATIC_INLINE int8_t UART1_SendChar(char const character, FILE * const stream); #endif // UART_PRINTF && __AVR128DA48__ @@ -231,7 +232,7 @@ __attribute__((always_inline)) inline static int8_t UART1_SendChar(char const ch static uart_callback_t uart0Callback = NULL; -__attribute__((always_inline)) inline static void UART0_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback) +STATIC_INLINE void UART0_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback) { UART0_RegisterCallback(receiveCallback); @@ -254,7 +255,7 @@ __attribute__((always_inline)) inline static void UART0_InitializeWithReceive(ui #if ( defined UART_PRINTF ) && ( defined __AVR64DD32__ ) -__attribute__((always_inline)) inline static int8_t UART0_SendChar(char const character, __attribute__((unused)) FILE * const stream) +STATIC_INLINE int8_t UART0_SendChar(char const character, __attribute__((unused)) FILE * const stream) { UART0_PrintChar(character); @@ -265,7 +266,7 @@ static FILE uart0Stream = FDEV_SETUP_STREAM(UART0_SendChar, NULL, _FDEV_SETUP_WR #endif // UART_PRINTF && __AVR64DD32__ -__attribute__((always_inline)) inline static void UART0_Initialize(uint32_t const baudRate) +STATIC_INLINE void UART0_Initialize(uint32_t const baudRate) { #if ( defined UART_PRINTF ) && ( defined __AVR64DD32__ ) @@ -311,7 +312,7 @@ static void UART0_Print(char const * const string) return; } -__attribute__((always_inline)) inline static void UART0_PrintChar(char const character) +STATIC_INLINE void UART0_PrintChar(char const character) { UART0_SendByte((char) character); @@ -340,12 +341,12 @@ static void UART0_SendByte(uint8_t const dataByte) return; } -__attribute__((always_inline)) inline static inline bool UART0_TXBusy(void) +STATIC_INLINE inline bool UART0_TXBusy(void) { return !(USART0.STATUS & USART_DREIF_bm); } -__attribute__((always_inline)) inline static void UART0_RegisterCallback(uart_callback_t const callback) +STATIC_INLINE void UART0_RegisterCallback(uart_callback_t const callback) { uart0Callback = callback; @@ -361,7 +362,7 @@ __attribute__((always_inline)) inline static void UART0_RegisterCallback(uart_ca static uart_callback_t uart1Callback = NULL; -__attribute__((always_inline)) inline static void UART1_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback) +STATIC_INLINE void UART1_InitializeWithReceive(uint32_t const baudRate, uart_callback_t const receiveCallback) { UART1_RegisterCallback(receiveCallback); @@ -378,7 +379,7 @@ __attribute__((always_inline)) inline static void UART1_InitializeWithReceive(ui #if ( defined UART_PRINTF ) && ( defined __AVR128DA48__ ) -__attribute__((always_inline)) inline static int8_t UART1_SendChar(char const character, __attribute__((unused)) FILE * const stream) +STATIC_INLINE int8_t UART1_SendChar(char const character, __attribute__((unused)) FILE * const stream) { UART1_PrintChar(character); @@ -389,7 +390,7 @@ static FILE uart1Stream = FDEV_SETUP_STREAM(UART1_SendChar, NULL, _FDEV_SETUP_WR #endif // UART_PRINTF && __AVR128DA48__ -__attribute__((always_inline)) inline static void UART1_Initialize(uint32_t const baudRate) +STATIC_INLINE void UART1_Initialize(uint32_t const baudRate) { #if ( defined UART_PRINTF ) && ( defined __AVR128DA48__ ) @@ -427,7 +428,7 @@ static void UART1_Print(char const * const string) return; } -__attribute__((always_inline)) inline static void UART1_PrintChar(char const character) +STATIC_INLINE void UART1_PrintChar(char const character) { UART1_SendByte((char) character); @@ -456,12 +457,12 @@ static void UART1_SendByte(uint8_t const dataByte) return; } -__attribute__((always_inline)) inline static inline bool UART1_TXBusy(void) +STATIC_INLINE inline bool UART1_TXBusy(void) { return !(USART1.STATUS & USART_DREIF_bm); } -__attribute__((always_inline)) inline static void UART1_RegisterCallback(uart_callback_t const callback) +STATIC_INLINE void UART1_RegisterCallback(uart_callback_t const callback) { uart1Callback = callback; diff --git a/src/vector.c b/src/vector.c index 04f128e..c543e07 100644 --- a/src/vector.c +++ b/src/vector.c @@ -133,14 +133,14 @@ static void Vector_CheckAvailableSpace(vector_t * const vector, uint8_t const nu // // //////////////////////////////////////////////////////////////////////////////// -__attribute__((always_inline)) inline void Vector_Initialize(vector_t * const vector) +INLINE void Vector_Initialize(vector_t * const vector) { Vector_Clear(vector); return; } -__attribute__((always_inline)) inline void Vector_Clear(vector_t * const vector) +INLINE void Vector_Clear(vector_t * const vector) { vector->bufferSize = 0;