BSP driver for DISCO_L496AG

Dependents:   DISCO_L496AG-LCD-prova_1 DISCO_L496AG-LCD-prova_2 DISCO_L496AG-LCD-demo DISCO_L496AG-SRAM-demo

Committer:
Jerome Coutant
Date:
Wed Nov 20 16:48:24 2019 +0100
Revision:
2:106c7b82e064
Parent:
0:d83f1c8ca282
Update BSP files with CubeL4 V1.14.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:d83f1c8ca282 1 /**
bcostm 0:d83f1c8ca282 2 ******************************************************************************
bcostm 0:d83f1c8ca282 3 * @file stm32l496g_discovery_lcd.h
bcostm 0:d83f1c8ca282 4 * @author MCD Application Team
bcostm 0:d83f1c8ca282 5 * @brief This file contains the common defines and functions prototypes for
bcostm 0:d83f1c8ca282 6 * the stm32l496g_discovery_lcd.c driver.
bcostm 0:d83f1c8ca282 7 ******************************************************************************
bcostm 0:d83f1c8ca282 8 * @attention
bcostm 0:d83f1c8ca282 9 *
Jerome Coutant 2:106c7b82e064 10 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
Jerome Coutant 2:106c7b82e064 11 * All rights reserved.</center></h2>
bcostm 0:d83f1c8ca282 12 *
Jerome Coutant 2:106c7b82e064 13 * This software component is licensed by ST under BSD 3-Clause license,
Jerome Coutant 2:106c7b82e064 14 * the "License"; You may not use this file except in compliance with the
Jerome Coutant 2:106c7b82e064 15 * License. You may obtain a copy of the License at:
Jerome Coutant 2:106c7b82e064 16 * opensource.org/licenses/BSD-3-Clause
bcostm 0:d83f1c8ca282 17 *
bcostm 0:d83f1c8ca282 18 ******************************************************************************
bcostm 0:d83f1c8ca282 19 */
bcostm 0:d83f1c8ca282 20
bcostm 0:d83f1c8ca282 21 /* Define to prevent recursive inclusion -------------------------------------*/
bcostm 0:d83f1c8ca282 22 #ifndef __STM32L496G_DISCOVERY_LCD_H
bcostm 0:d83f1c8ca282 23 #define __STM32L496G_DISCOVERY_LCD_H
bcostm 0:d83f1c8ca282 24
bcostm 0:d83f1c8ca282 25 #ifdef __cplusplus
bcostm 0:d83f1c8ca282 26 extern "C" {
bcostm 0:d83f1c8ca282 27 #endif
bcostm 0:d83f1c8ca282 28
bcostm 0:d83f1c8ca282 29 /* Includes ------------------------------------------------------------------*/
bcostm 0:d83f1c8ca282 30 #include "stm32l496g_discovery.h"
bcostm 0:d83f1c8ca282 31 #include "stm32l496g_discovery_io.h"
bcostm 0:d83f1c8ca282 32 /*#include "../Components/ls016b8uy/ls016b8uy.h"*/
bcostm 0:d83f1c8ca282 33 #include "../Components/st7789h2/st7789h2.h"
bcostm 0:d83f1c8ca282 34 #include "../../../Utilities/Fonts/fonts.h"
bcostm 0:d83f1c8ca282 35
bcostm 0:d83f1c8ca282 36 /** @addtogroup BSP
bcostm 0:d83f1c8ca282 37 * @{
bcostm 0:d83f1c8ca282 38 */
bcostm 0:d83f1c8ca282 39
bcostm 0:d83f1c8ca282 40 /** @addtogroup STM32L496G_DISCOVERY
bcostm 0:d83f1c8ca282 41 * @{
bcostm 0:d83f1c8ca282 42 */
bcostm 0:d83f1c8ca282 43
bcostm 0:d83f1c8ca282 44 /** @defgroup STM32L496G_DISCOVERY_LCD STM32L496G-DISCOVERY LCD
bcostm 0:d83f1c8ca282 45 * @{
bcostm 0:d83f1c8ca282 46 */
bcostm 0:d83f1c8ca282 47
bcostm 0:d83f1c8ca282 48 /** @defgroup STM32L496G_DISCOVERY_LCD_Exported_Types STM32L496G DISCOVERY LCD Exported Types
bcostm 0:d83f1c8ca282 49 * @{
bcostm 0:d83f1c8ca282 50 */
bcostm 0:d83f1c8ca282 51 typedef struct
bcostm 0:d83f1c8ca282 52 {
bcostm 0:d83f1c8ca282 53 uint32_t TextColor;
bcostm 0:d83f1c8ca282 54 uint32_t BackColor;
bcostm 0:d83f1c8ca282 55 sFONT *pFont;
bcostm 0:d83f1c8ca282 56 } LCD_DrawPropTypeDef;
bcostm 0:d83f1c8ca282 57 /**
bcostm 0:d83f1c8ca282 58 * @}
bcostm 0:d83f1c8ca282 59 */
bcostm 0:d83f1c8ca282 60
bcostm 0:d83f1c8ca282 61 /** @defgroup STM32L496G_DISCOVERY_LCD_Exported_Constants STM32L496G DISCOVERY LCD Exported Constants
bcostm 0:d83f1c8ca282 62 * @{
bcostm 0:d83f1c8ca282 63 */
bcostm 0:d83f1c8ca282 64 /**
bcostm 0:d83f1c8ca282 65 * @brief LCD status structure definition
bcostm 0:d83f1c8ca282 66 */
bcostm 0:d83f1c8ca282 67 #define LCD_OK ((uint8_t)0x00)
bcostm 0:d83f1c8ca282 68 #define LCD_ERROR ((uint8_t)0x01)
bcostm 0:d83f1c8ca282 69 #define LCD_TIMEOUT ((uint8_t)0x02)
bcostm 0:d83f1c8ca282 70
bcostm 0:d83f1c8ca282 71 typedef struct
bcostm 0:d83f1c8ca282 72 {
bcostm 0:d83f1c8ca282 73 int16_t X;
bcostm 0:d83f1c8ca282 74 int16_t Y;
bcostm 0:d83f1c8ca282 75 } Point, * pPoint;
bcostm 0:d83f1c8ca282 76
bcostm 0:d83f1c8ca282 77 /**
bcostm 0:d83f1c8ca282 78 * @brief Line mode structures definition
bcostm 0:d83f1c8ca282 79 */
bcostm 0:d83f1c8ca282 80 typedef enum
bcostm 0:d83f1c8ca282 81 {
bcostm 0:d83f1c8ca282 82 CENTER_MODE = 0x01, /* Center mode */
bcostm 0:d83f1c8ca282 83 RIGHT_MODE = 0x02, /* Right mode */
bcostm 0:d83f1c8ca282 84 LEFT_MODE = 0x03 /* Left mode */
bcostm 0:d83f1c8ca282 85 } Line_ModeTypdef;
bcostm 0:d83f1c8ca282 86
bcostm 0:d83f1c8ca282 87
bcostm 0:d83f1c8ca282 88 #define LCD_ORIENTATION_PORTRAIT ((uint8_t)0x00) /*!< Portrait orientation choice of LCD screen */
bcostm 0:d83f1c8ca282 89 #define LCD_ORIENTATION_LANDSCAPE ((uint8_t)0x01) /*!< Landscape orientation choice of LCD screen */
bcostm 0:d83f1c8ca282 90 #define LCD_ORIENTATION_UNDEFINED ((uint8_t)0x02) /*!< Undefined LCD screen orientation */
bcostm 0:d83f1c8ca282 91
bcostm 0:d83f1c8ca282 92
bcostm 0:d83f1c8ca282 93 /**
bcostm 0:d83f1c8ca282 94 * @brief LCD color
bcostm 0:d83f1c8ca282 95 */
bcostm 0:d83f1c8ca282 96 #define LCD_COLOR_BLUE ((uint16_t)0x001F)
bcostm 0:d83f1c8ca282 97 #define LCD_COLOR_GREEN ((uint16_t)0x07E0)
bcostm 0:d83f1c8ca282 98 #define LCD_COLOR_RED ((uint16_t)0xF800)
bcostm 0:d83f1c8ca282 99 #define LCD_COLOR_CYAN ((uint16_t)0x07FF)
bcostm 0:d83f1c8ca282 100 #define LCD_COLOR_MAGENTA ((uint16_t)0xF81F)
bcostm 0:d83f1c8ca282 101 #define LCD_COLOR_YELLOW ((uint16_t)0xFFE0)
bcostm 0:d83f1c8ca282 102 #define LCD_COLOR_LIGHTBLUE ((uint16_t)0x841F)
bcostm 0:d83f1c8ca282 103 #define LCD_COLOR_LIGHTGREEN ((uint16_t)0x87F0)
bcostm 0:d83f1c8ca282 104 #define LCD_COLOR_LIGHTRED ((uint16_t)0xFC10)
bcostm 0:d83f1c8ca282 105 #define LCD_COLOR_LIGHTMAGENTA ((uint16_t)0xFC1F)
bcostm 0:d83f1c8ca282 106 #define LCD_COLOR_LIGHTYELLOW ((uint16_t)0xFFF0)
bcostm 0:d83f1c8ca282 107 #define LCD_COLOR_DARKBLUE ((uint16_t)0x0010)
bcostm 0:d83f1c8ca282 108 #define LCD_COLOR_DARKGREEN ((uint16_t)0x0400)
bcostm 0:d83f1c8ca282 109 #define LCD_COLOR_DARKRED ((uint16_t)0x8000)
bcostm 0:d83f1c8ca282 110 #define LCD_COLOR_DARKCYAN ((uint16_t)0x0410)
bcostm 0:d83f1c8ca282 111 #define LCD_COLOR_DARKMAGENTA ((uint16_t)0x8010)
bcostm 0:d83f1c8ca282 112 #define LCD_COLOR_DARKYELLOW ((uint16_t)0x8400)
bcostm 0:d83f1c8ca282 113 #define LCD_COLOR_WHITE ((uint16_t)0xFFFF)
bcostm 0:d83f1c8ca282 114 #define LCD_COLOR_LIGHTGRAY ((uint16_t)0xD69A)
bcostm 0:d83f1c8ca282 115 #define LCD_COLOR_GRAY ((uint16_t)0x8410)
bcostm 0:d83f1c8ca282 116 #define LCD_COLOR_DARKGRAY ((uint16_t)0x4208)
bcostm 0:d83f1c8ca282 117 #define LCD_COLOR_BLACK ((uint16_t)0x0000)
bcostm 0:d83f1c8ca282 118 #define LCD_COLOR_BROWN ((uint16_t)0xA145)
bcostm 0:d83f1c8ca282 119 #define LCD_COLOR_ORANGE ((uint16_t)0xFD20)
bcostm 0:d83f1c8ca282 120
bcostm 0:d83f1c8ca282 121 /**
bcostm 0:d83f1c8ca282 122 * @brief LCD default font
bcostm 0:d83f1c8ca282 123 */
bcostm 0:d83f1c8ca282 124 #define LCD_DEFAULT_FONT Font12
bcostm 0:d83f1c8ca282 125
bcostm 0:d83f1c8ca282 126 /**
bcostm 0:d83f1c8ca282 127 * @brief LCD special pins
bcostm 0:d83f1c8ca282 128 */
bcostm 0:d83f1c8ca282 129 /* LCD reset pin */
bcostm 0:d83f1c8ca282 130 /* LCD reset is accessed thru the MFX */
bcostm 0:d83f1c8ca282 131 #define LCD_RST_PIN IO1_PIN_2
bcostm 0:d83f1c8ca282 132
bcostm 0:d83f1c8ca282 133 /* LCD tearing effect pin */
bcostm 0:d83f1c8ca282 134 #define LCD_TE_PIN GPIO_PIN_7
bcostm 0:d83f1c8ca282 135 #define LCD_TE_GPIO_PORT GPIOH
bcostm 0:d83f1c8ca282 136 #define LCD_TE_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
bcostm 0:d83f1c8ca282 137 #define LCD_TE_GPIO_CLK_DISABLE() __HAL_RCC_GPIOH_CLK_DISABLE()
bcostm 0:d83f1c8ca282 138
bcostm 0:d83f1c8ca282 139 /* Backlight control pin */
bcostm 0:d83f1c8ca282 140 #if defined(LPTIMER_DIMMING)
bcostm 0:d83f1c8ca282 141 #define LCD_BL_CTRL_PIN GPIO_PIN_15
bcostm 0:d83f1c8ca282 142 #define LCD_BL_CTRL_GPIO_PORT GPIOG
bcostm 0:d83f1c8ca282 143 #define LCD_BL_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
bcostm 0:d83f1c8ca282 144 #define LCD_BL_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE()
bcostm 0:d83f1c8ca282 145 #else
bcostm 0:d83f1c8ca282 146 #define LCD_BL_CTRL_PIN GPIO_PIN_0
bcostm 0:d83f1c8ca282 147 #define LCD_BL_CTRL_GPIO_PORT GPIOI
bcostm 0:d83f1c8ca282 148 #define LCD_BL_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
bcostm 0:d83f1c8ca282 149 #define LCD_BL_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
bcostm 0:d83f1c8ca282 150 #endif
bcostm 0:d83f1c8ca282 151
bcostm 0:d83f1c8ca282 152
bcostm 0:d83f1c8ca282 153 /* Power on control pin */
bcostm 0:d83f1c8ca282 154 #define LCD_PWR_CTRL_PIN GPIO_PIN_0
bcostm 0:d83f1c8ca282 155 #define LCD_PWR_CTRL_GPIO_PORT GPIOH
bcostm 0:d83f1c8ca282 156 #define LCD_PWR_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
bcostm 0:d83f1c8ca282 157 #define LCD_PWR_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOH_CLK_DISABLE()
bcostm 0:d83f1c8ca282 158
bcostm 0:d83f1c8ca282 159 /* Use by application to not use backlight */
bcostm 0:d83f1c8ca282 160 extern FlagStatus WakeUpFromStandby;
bcostm 0:d83f1c8ca282 161 extern FlagStatus WakeUpFromShutdown;
bcostm 0:d83f1c8ca282 162
bcostm 0:d83f1c8ca282 163
bcostm 0:d83f1c8ca282 164 /* Screen dimming parameters */
bcostm 0:d83f1c8ca282 165 /* Definition for TIMx clock resources */
bcostm 0:d83f1c8ca282 166 #define TIMx TIM5
bcostm 0:d83f1c8ca282 167 #define TIMx_CLK_ENABLE() __HAL_RCC_TIM5_CLK_ENABLE()
bcostm 0:d83f1c8ca282 168 #define TIMx_CLK_DISABLE() __HAL_RCC_TIM5_CLK_DISABLE()
bcostm 0:d83f1c8ca282 169 #define TIMx_CHANNEL TIM_CHANNEL_4
bcostm 0:d83f1c8ca282 170 #define TIMx_CHANNEl_AF GPIO_AF2_TIM5
bcostm 0:d83f1c8ca282 171 #if defined(LPTIMER_DIMMING)
bcostm 0:d83f1c8ca282 172 #define PERIOD_VALUE (uint32_t)(99) /* Period Value */
bcostm 0:d83f1c8ca282 173 #define PULSE_VALUE (uint32_t)(95) /* 5% cycle */
bcostm 0:d83f1c8ca282 174 #define PULSE_DECREASE_START (uint32_t)(45) /* cycle start level when starting to dim the screen */
bcostm 0:d83f1c8ca282 175 #define PULSE_DECREASE_DELAY (uint32_t)(40) /* gradually decrease cycle level every 40 milliseconds */
bcostm 0:d83f1c8ca282 176 #else
bcostm 0:d83f1c8ca282 177 #define PERIOD_VALUE (uint32_t)(666 - 1) /* Period Value */
bcostm 0:d83f1c8ca282 178 #define PULSE_VALUE (uint32_t)((PERIOD_VALUE*5)/100) /* 5% cycle */
bcostm 0:d83f1c8ca282 179 #define PULSE_DECREASE_START (uint32_t)(PULSE_VALUE + 120) /* cycle start level when starting to dim the screen */
bcostm 0:d83f1c8ca282 180 #define PULSE_DECREASE_DELAY (uint32_t)(20) /* gradually decrease cycle level every 20 milliseconds */
bcostm 0:d83f1c8ca282 181 #endif
bcostm 0:d83f1c8ca282 182
bcostm 0:d83f1c8ca282 183 /**
bcostm 0:d83f1c8ca282 184 * @}
bcostm 0:d83f1c8ca282 185 */
bcostm 0:d83f1c8ca282 186
bcostm 0:d83f1c8ca282 187 /** @defgroup STM32L496G_DISCOVERY_LCD_Exported_Functions STM32L496G DISCOVERY LCD Exported Functions
bcostm 0:d83f1c8ca282 188 * @{
bcostm 0:d83f1c8ca282 189 */
bcostm 0:d83f1c8ca282 190 uint8_t BSP_LCD_Init(void);
bcostm 0:d83f1c8ca282 191 uint8_t BSP_LCD_InitEx(uint32_t orientation);
bcostm 0:d83f1c8ca282 192 void BSP_LCD_Reset(void);
bcostm 0:d83f1c8ca282 193 uint8_t BSP_LCD_DeInit(void);
bcostm 0:d83f1c8ca282 194 uint32_t BSP_LCD_GetXSize(void);
bcostm 0:d83f1c8ca282 195 uint32_t BSP_LCD_GetYSize(void);
bcostm 0:d83f1c8ca282 196
bcostm 0:d83f1c8ca282 197 uint16_t BSP_LCD_GetTextColor(void);
bcostm 0:d83f1c8ca282 198 uint16_t BSP_LCD_GetBackColor(void);
bcostm 0:d83f1c8ca282 199 void BSP_LCD_SetTextColor(__IO uint16_t Color);
bcostm 0:d83f1c8ca282 200 void BSP_LCD_SetBackColor(__IO uint16_t Color);
bcostm 0:d83f1c8ca282 201 void BSP_LCD_SetFont(sFONT *fonts);
bcostm 0:d83f1c8ca282 202 sFONT *BSP_LCD_GetFont(void);
bcostm 0:d83f1c8ca282 203
bcostm 0:d83f1c8ca282 204 void BSP_LCD_Clear(uint16_t Color);
bcostm 0:d83f1c8ca282 205 void BSP_LCD_ClearStringLine(uint16_t Line);
bcostm 0:d83f1c8ca282 206 void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr);
bcostm 0:d83f1c8ca282 207 void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode);
bcostm 0:d83f1c8ca282 208 void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii);
bcostm 0:d83f1c8ca282 209
bcostm 0:d83f1c8ca282 210 uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos);
bcostm 0:d83f1c8ca282 211 void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code);
bcostm 0:d83f1c8ca282 212 void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
bcostm 0:d83f1c8ca282 213 void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
bcostm 0:d83f1c8ca282 214 void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
bcostm 0:d83f1c8ca282 215 void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
bcostm 0:d83f1c8ca282 216 void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
bcostm 0:d83f1c8ca282 217 void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount);
bcostm 0:d83f1c8ca282 218 void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
bcostm 0:d83f1c8ca282 219 void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
bcostm 0:d83f1c8ca282 220 void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pbmp);
bcostm 0:d83f1c8ca282 221 void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
bcostm 0:d83f1c8ca282 222 void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
bcostm 0:d83f1c8ca282 223 void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount);
bcostm 0:d83f1c8ca282 224 void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
bcostm 0:d83f1c8ca282 225
bcostm 0:d83f1c8ca282 226 void BSP_LCD_DisplayOff(void);
bcostm 0:d83f1c8ca282 227 void BSP_LCD_DisplayOn(void);
bcostm 0:d83f1c8ca282 228
bcostm 0:d83f1c8ca282 229 void BSP_LCD_ScreenDimmingOn(void);
bcostm 0:d83f1c8ca282 230 void BSP_LCD_ScreenDimmingOff(void);
bcostm 0:d83f1c8ca282 231 void BSP_LCD_ScreenDimmingConfig(const uint8_t start, const uint8_t stop, const uint8_t step, const uint8_t delay);
bcostm 0:d83f1c8ca282 232
bcostm 0:d83f1c8ca282 233 uint8_t BSP_LCD_GetOrientation(void);
bcostm 0:d83f1c8ca282 234
bcostm 0:d83f1c8ca282 235 /* These functions can be modified in case the current settings
bcostm 0:d83f1c8ca282 236 need to be changed for specific application needs */
bcostm 0:d83f1c8ca282 237 __weak void BSP_LCD_MspInit(void);
bcostm 0:d83f1c8ca282 238 __weak void BSP_LCD_MspDeInit(void);
bcostm 0:d83f1c8ca282 239
bcostm 0:d83f1c8ca282 240 /**
bcostm 0:d83f1c8ca282 241 * @}
bcostm 0:d83f1c8ca282 242 */
bcostm 0:d83f1c8ca282 243
bcostm 0:d83f1c8ca282 244 /**
bcostm 0:d83f1c8ca282 245 * @}
bcostm 0:d83f1c8ca282 246 */
bcostm 0:d83f1c8ca282 247
bcostm 0:d83f1c8ca282 248 /**
bcostm 0:d83f1c8ca282 249 * @}
bcostm 0:d83f1c8ca282 250 */
bcostm 0:d83f1c8ca282 251
bcostm 0:d83f1c8ca282 252 /**
bcostm 0:d83f1c8ca282 253 * @}
bcostm 0:d83f1c8ca282 254 */
bcostm 0:d83f1c8ca282 255
bcostm 0:d83f1c8ca282 256 #ifdef __cplusplus
bcostm 0:d83f1c8ca282 257 }
bcostm 0:d83f1c8ca282 258 #endif
bcostm 0:d83f1c8ca282 259
bcostm 0:d83f1c8ca282 260 #endif /* __STM32L496G_DISCOVERY_LCD_H */
bcostm 0:d83f1c8ca282 261
bcostm 0:d83f1c8ca282 262 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/