drivers/disp_dev: use const qualifier

This commit is contained in:
Alexandre Abadie 2020-04-28 11:53:27 +02:00
parent 6105f223e3
commit 81c2b08d9b
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
3 changed files with 25 additions and 24 deletions

View File

@ -19,11 +19,12 @@
*/ */
#include <assert.h> #include <assert.h>
#include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include "disp_dev.h" #include "disp_dev.h"
void disp_dev_map(disp_dev_t *dev, void disp_dev_map(const disp_dev_t *dev,
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
const uint16_t *color) const uint16_t *color)
{ {
@ -32,28 +33,28 @@ void disp_dev_map(disp_dev_t *dev,
dev->driver->map(dev, x1, x2, y1, y2, color); 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); assert(dev);
return dev->driver->height(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); assert(dev);
return dev->driver->width(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); assert(dev);
return dev->driver->color_depth(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); assert(dev);

View File

@ -31,20 +31,20 @@
#define ILI9341_DISP_COLOR_DEPTH (16U) #define ILI9341_DISP_COLOR_DEPTH (16U)
#endif #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) uint16_t y1, uint16_t y2, const uint16_t *color)
{ {
ili9341_t *ili9341 = (ili9341_t *)dev; ili9341_t *ili9341 = (ili9341_t *)dev;
ili9341_pixmap(ili9341, x1, x2, y1, y2, color); 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; (void)disp_dev;
return ILI9341_DISP_DEV_HEIGHT; 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; const ili9341_t *dev = (ili9341_t *)disp_dev;
assert(dev); assert(dev);
@ -52,13 +52,13 @@ static uint16_t _ili9341_width(disp_dev_t *disp_dev)
return dev->params->lines; 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; (void)disp_dev;
return ILI9341_DISP_COLOR_DEPTH; 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; const ili9341_t *dev = (ili9341_t *)disp_dev;

View File

@ -56,7 +56,7 @@ typedef struct {
* @param[in] y2 Bottom coordinate * @param[in] y2 Bottom coordinate
* @param[in] color Array of color to map to the display * @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, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
const uint16_t *color); const uint16_t *color);
@ -67,7 +67,7 @@ typedef struct {
* *
* @return Height in pixels * @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 * @brief Get the width of the display device
@ -76,14 +76,14 @@ typedef struct {
* *
* @return Width in pixels * @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 * @brief Get the color depth of the display device
* *
* @return The color depth * @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 * @brief Invert the display device colors
@ -91,7 +91,7 @@ typedef struct {
* @param[in] dev Network device descriptor * @param[in] dev Network device descriptor
* @param[in] invert Invert mode (true if invert, false otherwise) * @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; } disp_dev_driver_t;
/** /**
@ -111,7 +111,7 @@ struct disp_dev {
* @param[in] y2 Bottom coordinate * @param[in] y2 Bottom coordinate
* @param[in] color Array of color to map to the display * @param[in] color Array of color to map to the display
*/ */
void disp_dev_map(disp_dev_t *dev, void disp_dev_map(const disp_dev_t *dev,
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
const uint16_t *color); const uint16_t *color);
@ -122,7 +122,7 @@ void disp_dev_map(disp_dev_t *dev,
* *
* @return Height in pixels * @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 * @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 * @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 * @brief Get the color depth of the display device
* *
* @return The color depth * @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 * @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] dev Pointer to the display device
* @param[in] invert Invert mode (true if invert, false otherwise) * @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 * @brief Enable the backlight pin