xref: /btstack/port/stm32-l451-miromico-sx1280/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_gfxmmu.h (revision 2fd737d36a1de5d778cacc671d4b4d8c4f3fed82)
1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_hal_gfxmmu.h
4   * @author  MCD Application Team
5   * @brief   Header file of GFXMMU HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10   * All rights reserved.</center></h2>
11   *
12   * This software component is licensed by ST under BSD 3-Clause license,
13   * the "License"; You may not use this file except in compliance with the
14   * License. You may obtain a copy of the License at:
15   *                        opensource.org/licenses/BSD-3-Clause
16   *
17   ******************************************************************************
18   */
19 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32L4xx_HAL_GFXMMU_H
22 #define STM32L4xx_HAL_GFXMMU_H
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32l4xx_hal_def.h"
30 
31 #if defined(GFXMMU)
32 
33 /** @addtogroup STM32L4xx_HAL_Driver
34   * @{
35   */
36 
37 /** @addtogroup GFXMMU
38   * @{
39   */
40 
41 /* Exported types ------------------------------------------------------------*/
42 /** @defgroup GFXMMU_Exported_Types GFXMMU Exported Types
43   * @{
44   */
45 
46 /**
47   * @brief  HAL GFXMMU states definition
48   */
49 typedef enum
50 {
51   HAL_GFXMMU_STATE_RESET = 0x00U, /*!< GFXMMU not initialized */
52   HAL_GFXMMU_STATE_READY = 0x01U, /*!< GFXMMU initialized and ready for use */
53 }HAL_GFXMMU_StateTypeDef;
54 
55 /**
56   * @brief  GFXMMU buffers structure definition
57   */
58 typedef struct
59 {
60   uint32_t Buf0Address; /*!< Physical address of buffer 0. */
61   uint32_t Buf1Address; /*!< Physical address of buffer 1. */
62   uint32_t Buf2Address; /*!< Physical address of buffer 2. */
63   uint32_t Buf3Address; /*!< Physical address of buffer 3. */
64 }GFXMMU_BuffersTypeDef;
65 
66 /**
67   * @brief  GFXMMU interrupts structure definition
68   */
69 typedef struct
70 {
71   FunctionalState Activation;     /*!< Interrupts enable/disable */
72   uint32_t        UsedInterrupts; /*!< Interrupts used.
73                                        This parameter can be a values combination of @ref GFXMMU_Interrupts.
74                                        @note: Usefull only when interrupts are enabled. */
75 }GFXMMU_InterruptsTypeDef;
76 
77 /**
78   * @brief  GFXMMU init structure definition
79   */
80 typedef struct
81 {
82   uint32_t                    BlocksPerLine; /*!< Number of blocks of 16 bytes per line.
83                                                   This parameter can be a value of @ref GFXMMU_BlocksPerLine. */
84   uint32_t                    DefaultValue;  /*!< Value returned when virtual memory location not physically mapped. */
85   GFXMMU_BuffersTypeDef       Buffers;       /*!< Physical buffers addresses. */
86   GFXMMU_InterruptsTypeDef    Interrupts;    /*!< Interrupts parameters. */
87 }GFXMMU_InitTypeDef;
88 
89 /**
90   * @brief  GFXMMU handle structure definition
91   */
92 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
93 typedef struct __GFXMMU_HandleTypeDef
94 #else
95 typedef struct
96 #endif
97 {
98   GFXMMU_TypeDef          *Instance; /*!< GFXMMU instance */
99   GFXMMU_InitTypeDef      Init;      /*!< GFXMMU init parameters */
100   HAL_GFXMMU_StateTypeDef State;     /*!< GFXMMU state */
101   __IO uint32_t           ErrorCode; /*!< GFXMMU error code */
102 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
103   void (*ErrorCallback)     (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU error callback */
104   void (*MspInitCallback)   (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP init callback */
105   void (*MspDeInitCallback) (struct __GFXMMU_HandleTypeDef *hgfxmmu); /*!< GFXMMU MSP de-init callback */
106 #endif
107 }GFXMMU_HandleTypeDef;
108 
109 /**
110   * @brief  GFXMMU LUT line structure definition
111   */
112 typedef struct
113 {
114   uint32_t LineNumber;        /*!< LUT line number.
115                                    This parameter must be a number between Min_Data = 0 and Max_Data = 1023. */
116   uint32_t LineStatus;        /*!< LUT line enable/disable.
117                                    This parameter can be a value of @ref GFXMMU_LutLineStatus. */
118   uint32_t FirstVisibleBlock; /*!< First visible block on this line.
119                                    This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
120   uint32_t LastVisibleBlock;  /*!< Last visible block on this line.
121                                    This parameter must be a number between Min_Data = 0 and Max_Data = 255. */
122   int32_t  LineOffset;        /*!< Offset of block 0 of the current line in physical buffer.
123                                    This parameter must be a number between Min_Data = -4080 and Max_Data = 4190208.
124                                    @note: Line offset has to be computed with the following formula:
125                                           LineOffset = [(Blocks already used) - (1st visible block)]*BlockSize. */
126 }GFXMMU_LutLineTypeDef;
127 
128 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
129 /**
130   * @brief  GFXMMU callback ID enumeration definition
131   */
132 typedef enum
133 {
134   HAL_GFXMMU_ERROR_CB_ID     = 0x00U, /*!< GFXMMU error callback ID */
135   HAL_GFXMMU_MSPINIT_CB_ID   = 0x01U, /*!< GFXMMU MSP init callback ID */
136   HAL_GFXMMU_MSPDEINIT_CB_ID = 0x02U  /*!< GFXMMU MSP de-init callback ID */
137 }HAL_GFXMMU_CallbackIDTypeDef;
138 
139 /**
140   * @brief  GFXMMU callback pointer definition
141   */
142 typedef void (*pGFXMMU_CallbackTypeDef)(GFXMMU_HandleTypeDef *hgfxmmu);
143 #endif
144 
145 /**
146   * @}
147   */
148 /* End of exported types -----------------------------------------------------*/
149 
150 /* Exported constants --------------------------------------------------------*/
151 /** @defgroup GFXMMU_Exported_Constants GFXMMU Exported Constants
152   * @{
153   */
154 
155 /** @defgroup GFXMMU_BlocksPerLine GFXMMU blocks per line
156   * @{
157   */
158 #define GFXMMU_256BLOCKS 0x00000000U     /*!< 256 blocks of 16 bytes per line */
159 #define GFXMMU_192BLOCKS GFXMMU_CR_192BM /*!< 192 blocks of 16 bytes per line */
160 /**
161   * @}
162   */
163 
164 /** @defgroup GFXMMU_Interrupts GFXMMU interrupts
165   * @{
166   */
167 #define GFXMMU_AHB_MASTER_ERROR_IT GFXMMU_CR_AMEIE /*!< AHB master error interrupt */
168 #define GFXMMU_BUFFER0_OVERFLOW_IT GFXMMU_CR_B0OIE /*!< Buffer 0 overflow interrupt */
169 #define GFXMMU_BUFFER1_OVERFLOW_IT GFXMMU_CR_B1OIE /*!< Buffer 1 overflow interrupt */
170 #define GFXMMU_BUFFER2_OVERFLOW_IT GFXMMU_CR_B2OIE /*!< Buffer 2 overflow interrupt */
171 #define GFXMMU_BUFFER3_OVERFLOW_IT GFXMMU_CR_B3OIE /*!< Buffer 3 overflow interrupt */
172 /**
173   * @}
174   */
175 
176 /** @defgroup GFXMMU_Error_Code GFXMMU Error Code
177   * @{
178   */
179 #define GFXMMU_ERROR_NONE             0x00000000U    /*!< No error */
180 #define GFXMMU_ERROR_BUFFER0_OVERFLOW GFXMMU_SR_B0OF /*!< Buffer 0 overflow */
181 #define GFXMMU_ERROR_BUFFER1_OVERFLOW GFXMMU_SR_B1OF /*!< Buffer 1 overflow */
182 #define GFXMMU_ERROR_BUFFER2_OVERFLOW GFXMMU_SR_B2OF /*!< Buffer 2 overflow */
183 #define GFXMMU_ERROR_BUFFER3_OVERFLOW GFXMMU_SR_B3OF /*!< Buffer 3 overflow */
184 #define GFXMMU_ERROR_AHB_MASTER       GFXMMU_SR_AMEF /*!< AHB master error */
185 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
186 #define GFXMMU_ERROR_INVALID_CALLBACK 0x00000100U    /*!< Invalid callback error */
187 #endif
188 /**
189   * @}
190   */
191 
192 /** @defgroup GFXMMU_LutLineStatus GFXMMU LUT line status
193   * @{
194   */
195 #define GFXMMU_LUT_LINE_DISABLE 0x00000000U     /*!< LUT line disabled */
196 #define GFXMMU_LUT_LINE_ENABLE  GFXMMU_LUTxL_EN /*!< LUT line enabled */
197 /**
198   * @}
199   */
200 
201 /**
202   * @}
203   */
204 /* End of exported constants -------------------------------------------------*/
205 
206 /* Exported macros -----------------------------------------------------------*/
207 /** @defgroup GFXMMU_Exported_Macros GFXMMU Exported Macros
208  * @{
209  */
210 
211 /** @brief  Reset GFXMMU handle state.
212   * @param  __HANDLE__ GFXMMU handle.
213   * @retval None
214   */
215 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
216 #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) do{                                               \
217                                                         (__HANDLE__)->State = HAL_GFXMMU_STATE_RESET; \
218                                                         (__HANDLE__)->MspInitCallback = NULL;         \
219                                                         (__HANDLE__)->MspDeInitCallback = NULL;       \
220                                                       } while(0)
221 #else
222 #define __HAL_GFXMMU_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_GFXMMU_STATE_RESET)
223 #endif
224 
225 /**
226   * @}
227   */
228 /* End of exported macros ----------------------------------------------------*/
229 
230 /* Exported functions --------------------------------------------------------*/
231 /** @addtogroup GFXMMU_Exported_Functions GFXMMU Exported Functions
232   * @{
233   */
234 
235 /** @addtogroup GFXMMU_Exported_Functions_Group1 Initialization and de-initialization functions
236   * @{
237   */
238 /* Initialization and de-initialization functions *****************************/
239 HAL_StatusTypeDef HAL_GFXMMU_Init(GFXMMU_HandleTypeDef *hgfxmmu);
240 HAL_StatusTypeDef HAL_GFXMMU_DeInit(GFXMMU_HandleTypeDef *hgfxmmu);
241 void HAL_GFXMMU_MspInit(GFXMMU_HandleTypeDef *hgfxmmu);
242 void HAL_GFXMMU_MspDeInit(GFXMMU_HandleTypeDef *hgfxmmu);
243 #if (USE_HAL_GFXMMU_REGISTER_CALLBACKS == 1)
244 /* GFXMMU callbacks register/unregister functions *****************************/
245 HAL_StatusTypeDef HAL_GFXMMU_RegisterCallback(GFXMMU_HandleTypeDef        *hgfxmmu,
246                                               HAL_GFXMMU_CallbackIDTypeDef CallbackID,
247                                               pGFXMMU_CallbackTypeDef      pCallback);
248 HAL_StatusTypeDef HAL_GFXMMU_UnRegisterCallback(GFXMMU_HandleTypeDef        *hgfxmmu,
249                                                 HAL_GFXMMU_CallbackIDTypeDef CallbackID);
250 #endif
251 /**
252   * @}
253   */
254 
255 /** @addtogroup GFXMMU_Exported_Functions_Group2 Operations functions
256   * @{
257   */
258 /* Operation functions ********************************************************/
259 HAL_StatusTypeDef HAL_GFXMMU_ConfigLut(GFXMMU_HandleTypeDef *hgfxmmu,
260                                        uint32_t FirstLine,
261                                        uint32_t LinesNumber,
262                                        uint32_t Address);
263 
264 HAL_StatusTypeDef HAL_GFXMMU_DisableLutLines(GFXMMU_HandleTypeDef *hgfxmmu,
265                                              uint32_t FirstLine,
266                                              uint32_t LinesNumber);
267 
268 HAL_StatusTypeDef HAL_GFXMMU_ConfigLutLine(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_LutLineTypeDef *lutLine);
269 
270 HAL_StatusTypeDef HAL_GFXMMU_ModifyBuffers(GFXMMU_HandleTypeDef *hgfxmmu, GFXMMU_BuffersTypeDef *Buffers);
271 
272 void HAL_GFXMMU_IRQHandler(GFXMMU_HandleTypeDef *hgfxmmu);
273 
274 void HAL_GFXMMU_ErrorCallback(GFXMMU_HandleTypeDef *hgfxmmu);
275 /**
276   * @}
277   */
278 
279 /** @defgroup GFXMMU_Exported_Functions_Group3 State functions
280   * @{
281   */
282 /* State function *************************************************************/
283 HAL_GFXMMU_StateTypeDef HAL_GFXMMU_GetState(GFXMMU_HandleTypeDef *hgfxmmu);
284 
285 uint32_t HAL_GFXMMU_GetError(GFXMMU_HandleTypeDef *hgfxmmu);
286 /**
287   * @}
288   */
289 
290 /**
291   * @}
292   */
293 /* End of exported functions -------------------------------------------------*/
294 
295 /* Private macros ------------------------------------------------------------*/
296 /** @defgroup GFXMMU_Private_Macros GFXMMU Private Macros
297 * @{
298 */
299 #define IS_GFXMMU_BLOCKS_PER_LINE(VALUE) (((VALUE) == GFXMMU_256BLOCKS) || \
300                                           ((VALUE) == GFXMMU_192BLOCKS))
301 
302 #define IS_GFXMMU_BUFFER_ADDRESS(VALUE) (((VALUE) & 0xFU) == 0U)
303 
304 #define IS_GFXMMU_INTERRUPTS(VALUE) (((VALUE) & 0x1FU) != 0U)
305 
306 #define IS_GFXMMU_LUT_LINE(VALUE) ((VALUE) < 1024U)
307 
308 #define IS_GFXMMU_LUT_LINES_NUMBER(VALUE) (((VALUE) > 0U) && ((VALUE) <= 1024U))
309 
310 #define IS_GFXMMU_LUT_LINE_STATUS(VALUE) (((VALUE) == GFXMMU_LUT_LINE_DISABLE) || \
311                                           ((VALUE) == GFXMMU_LUT_LINE_ENABLE))
312 
313 #define IS_GFXMMU_LUT_BLOCK(VALUE) ((VALUE) < 256U)
314 
315 #define IS_GFXMMU_LUT_LINE_OFFSET(VALUE) (((VALUE) >= -4080) && ((VALUE) <= 4190208))
316 /**
317   * @}
318   */
319 /* End of private macros -----------------------------------------------------*/
320 
321 /**
322   * @}
323   */
324 
325 /**
326   * @}
327   */
328 #endif /* GFXMMU */
329 #ifdef __cplusplus
330 }
331 #endif
332 
333 #endif /* STM32L4xx_HAL_GFXMMU_H */
334 
335 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
336