From 81c2b08d9b4d82e2d0838deee7cd4792aefd2035 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 28 Apr 2020 11:53:27 +0200 Subject: [PATCH] drivers/disp_dev: use const qualifier --- drivers/disp_dev/disp_dev.c | 15 ++++++++------- drivers/ili9341/ili9341_disp_dev.c | 10 +++++----- drivers/include/disp_dev.h | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/disp_dev/disp_dev.c b/drivers/disp_dev/disp_dev.c index ae791d374f..acd716239e 100644 --- a/drivers/disp_dev/disp_dev.c +++ b/drivers/disp_dev/disp_dev.c @@ -19,41 +19,42 @@ */ #include +#include #include #include "disp_dev.h" -void disp_dev_map(disp_dev_t *dev, - uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, - const uint16_t *color) +void disp_dev_map(const disp_dev_t *dev, + uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, + const uint16_t *color) { assert(dev); dev->driver->map(dev, x1, x2, y1, y2, color); } -uint16_t disp_dev_height(disp_dev_t *dev) +uint16_t disp_dev_height(const disp_dev_t *dev) { assert(dev); return dev->driver->height(dev); } -uint16_t disp_dev_width(disp_dev_t *dev) +uint16_t disp_dev_width(const disp_dev_t *dev) { assert(dev); return dev->driver->width(dev); } -uint8_t disp_dev_color_depth(disp_dev_t *dev) +uint8_t disp_dev_color_depth(const disp_dev_t *dev) { assert(dev); return dev->driver->color_depth(dev); } -void disp_dev_set_invert(disp_dev_t *dev, bool invert) +void disp_dev_set_invert(const disp_dev_t *dev, bool invert) { assert(dev); diff --git a/drivers/ili9341/ili9341_disp_dev.c b/drivers/ili9341/ili9341_disp_dev.c index ab682e1ece..66d3e124eb 100644 --- a/drivers/ili9341/ili9341_disp_dev.c +++ b/drivers/ili9341/ili9341_disp_dev.c @@ -31,20 +31,20 @@ #define ILI9341_DISP_COLOR_DEPTH (16U) #endif -static void _ili9341_map(disp_dev_t *dev, uint16_t x1, uint16_t x2, +static void _ili9341_map(const disp_dev_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const uint16_t *color) { ili9341_t *ili9341 = (ili9341_t *)dev; ili9341_pixmap(ili9341, x1, x2, y1, y2, color); } -static uint16_t _ili9341_height(disp_dev_t *disp_dev) +static uint16_t _ili9341_height(const disp_dev_t *disp_dev) { (void)disp_dev; return ILI9341_DISP_DEV_HEIGHT; } -static uint16_t _ili9341_width(disp_dev_t *disp_dev) +static uint16_t _ili9341_width(const disp_dev_t *disp_dev) { const ili9341_t *dev = (ili9341_t *)disp_dev; assert(dev); @@ -52,13 +52,13 @@ static uint16_t _ili9341_width(disp_dev_t *disp_dev) return dev->params->lines; } -static uint8_t _ili9341_color_depth(disp_dev_t *disp_dev) +static uint8_t _ili9341_color_depth(const disp_dev_t *disp_dev) { (void)disp_dev; return ILI9341_DISP_COLOR_DEPTH; } -static void _ili9341_set_invert(disp_dev_t *disp_dev, bool invert) +static void _ili9341_set_invert(const disp_dev_t *disp_dev, bool invert) { const ili9341_t *dev = (ili9341_t *)disp_dev; diff --git a/drivers/include/disp_dev.h b/drivers/include/disp_dev.h index 9f5d0942a3..c5c21f7b9a 100644 --- a/drivers/include/disp_dev.h +++ b/drivers/include/disp_dev.h @@ -56,7 +56,7 @@ typedef struct { * @param[in] y2 Bottom coordinate * @param[in] color Array of color to map to the display */ - void (*map)(disp_dev_t *dev, + void (*map)(const disp_dev_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const uint16_t *color); @@ -67,7 +67,7 @@ typedef struct { * * @return Height in pixels */ - uint16_t (*height)(disp_dev_t *dev); + uint16_t (*height)(const disp_dev_t *dev); /** * @brief Get the width of the display device @@ -76,14 +76,14 @@ typedef struct { * * @return Width in pixels */ - uint16_t (*width)(disp_dev_t *dev); + uint16_t (*width)(const disp_dev_t *dev); /** * @brief Get the color depth of the display device * * @return The color depth */ - uint8_t (*color_depth)(disp_dev_t *dev); + uint8_t (*color_depth)(const disp_dev_t *dev); /** * @brief Invert the display device colors @@ -91,7 +91,7 @@ typedef struct { * @param[in] dev Network device descriptor * @param[in] invert Invert mode (true if invert, false otherwise) */ - void (*set_invert)(disp_dev_t *dev, bool invert); + void (*set_invert)(const disp_dev_t *dev, bool invert); } disp_dev_driver_t; /** @@ -111,9 +111,9 @@ struct disp_dev { * @param[in] y2 Bottom coordinate * @param[in] color Array of color to map to the display */ -void disp_dev_map(disp_dev_t *dev, - uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, - const uint16_t *color); +void disp_dev_map(const disp_dev_t *dev, + uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, + const uint16_t *color); /** * @brief Get the height of the display device @@ -122,7 +122,7 @@ void disp_dev_map(disp_dev_t *dev, * * @return Height in pixels */ -uint16_t disp_dev_height(disp_dev_t *dev); +uint16_t disp_dev_height(const disp_dev_t *dev); /** * @brief Get the width of the display device @@ -131,14 +131,14 @@ uint16_t disp_dev_height(disp_dev_t *dev); * * @return Width in pixels */ -uint16_t disp_dev_width(disp_dev_t *dev); +uint16_t disp_dev_width(const disp_dev_t *dev); /** * @brief Get the color depth of the display device * * @return The color depth */ -uint8_t disp_dev_color_depth(disp_dev_t *dev); +uint8_t disp_dev_color_depth(const disp_dev_t *dev); /** * @brief Invert the display device colors @@ -146,7 +146,7 @@ uint8_t disp_dev_color_depth(disp_dev_t *dev); * @param[in] dev Pointer to the display device * @param[in] invert Invert mode (true if invert, false otherwise) */ -void disp_dev_set_invert(disp_dev_t *dev, bool invert); +void disp_dev_set_invert(const disp_dev_t *dev, bool invert); /** * @brief Enable the backlight pin