1 /**
2   ******************************************************************************
3   * @file    stm32u5xx_hal_jpeg.h
4   * @author  MCD Application Team
5   * @brief   Header file of JPEG HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2021 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32U5xx_HAL_JPEG_H
21 #define STM32U5xx_HAL_JPEG_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32u5xx_hal_def.h"
29 
30 #if defined (JPEG)
31 
32 /** @addtogroup STM32U5xx_HAL_Driver
33   * @{
34   */
35 
36 /** @addtogroup JPEG
37   * @{
38   */
39 
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup JPEG_Exported_Types JPEG Exported Types
42   * @{
43   */
44 
45 /** @defgroup JPEG_Configuration_Structure_definition JPEG Configuration for encoding Structure definition
46   * @brief  JPEG encoding configuration Structure definition
47   * @{
48   */
49 typedef struct
50 {
51   uint32_t ColorSpace;               /*!< Image Color space : gray-scale, YCBCR, RGB or CMYK
52                                            This parameter can be a value of @ref JPEG_ColorSpace */
53 
54   uint32_t ChromaSubsampling;        /*!< Chroma Subsampling in case of YCBCR or CMYK color space, 0-> 4:4:4 , 1-> 4:2:2, 2 -> 4:1:1, 3 -> 4:2:0
55                                            This parameter can be a value of @ref JPEG_ChromaSubsampling */
56 
57   uint32_t ImageHeight;              /*!< Image height : number of lines */
58 
59   uint32_t ImageWidth;               /*!< Image width : number of pixels per line */
60 
61   uint32_t ImageQuality;             /*!< Quality of the JPEG encoding : from 1 to 100 */
62 
63 } JPEG_ConfTypeDef;
64 /**
65   * @}
66   */
67 
68 /** @defgroup HAL_JPEG_state_structure_definition HAL JPEG state structure definition
69   * @brief  HAL JPEG State structure definition
70   * @{
71   */
72 typedef enum
73 {
74   HAL_JPEG_STATE_RESET              = 0x00U,  /*!< JPEG not yet initialized or disabled  */
75   HAL_JPEG_STATE_READY              = 0x01U,  /*!< JPEG initialized and ready for use    */
76   HAL_JPEG_STATE_BUSY               = 0x02U,  /*!< JPEG internal processing is ongoing   */
77   HAL_JPEG_STATE_BUSY_ENCODING      = 0x03U,  /*!< JPEG encoding processing is ongoing   */
78   HAL_JPEG_STATE_BUSY_DECODING      = 0x04U,  /*!< JPEG decoding processing is ongoing   */
79   HAL_JPEG_STATE_TIMEOUT            = 0x05U,  /*!< JPEG timeout state                    */
80   HAL_JPEG_STATE_ERROR              = 0x06U   /*!< JPEG error state                      */
81 } HAL_JPEG_STATETypeDef;
82 
83 /**
84   * @}
85   */
86 
87 
88 /** @defgroup JPEG_handle_Structure_definition JPEG handle Structure definition
89   * @brief  JPEG handle Structure definition
90   * @{
91   */
92 #if (USE_HAL_JPEG_REGISTER_CALLBACKS == 1)
93 typedef struct __JPEG_HandleTypeDef
94 #else
95 typedef struct
96 #endif /* (USE_HAL_JPEG_REGISTER_CALLBACKS) */
97 {
98   JPEG_TypeDef             *Instance;        /*!< JPEG peripheral register base address */
99 
100   JPEG_ConfTypeDef         Conf;             /*!< Current JPEG encoding/decoding parameters */
101 
102   uint8_t                  *pJpegInBuffPtr;  /*!< Pointer to JPEG processing (encoding, decoding,...) input buffer */
103 
104   uint8_t                  *pJpegOutBuffPtr; /*!< Pointer to JPEG processing (encoding, decoding,...) output buffer */
105 
106   __IO uint32_t            JpegInCount;      /*!< Internal Counter of input data */
107 
108   __IO uint32_t            JpegOutCount;     /*!< Internal Counter of output data */
109 
110   uint32_t                 InDataLength;     /*!< Input Buffer Length in Bytes */
111 
112   uint32_t                 OutDataLength;    /*!< Output Buffer Length in Bytes */
113 
114   DMA_HandleTypeDef        *hdmain;          /*!< JPEG In DMA handle parameters */
115 
116   DMA_HandleTypeDef        *hdmaout;         /*!< JPEG Out DMA handle parameters */
117 
118   uint8_t                  CustomQuanTable;  /*!< If set to 1 specify that user customized quantization tables are used */
119 
120   uint8_t                  *QuantTable0;     /*!< Basic Quantization Table for component 0 */
121 
122   uint8_t                  *QuantTable1;     /*!< Basic Quantization Table for component 1 */
123 
124   uint8_t                  *QuantTable2;     /*!< Basic Quantization Table for component 2 */
125 
126   uint8_t                  *QuantTable3;     /*!< Basic Quantization Table for component 3 */
127 
128   HAL_LockTypeDef          Lock;             /*!< JPEG locking object */
129 
130   __IO  HAL_JPEG_STATETypeDef State;         /*!< JPEG peripheral state */
131 
132   __IO  uint32_t           ErrorCode;        /*!< JPEG Error code */
133 
134   __IO uint32_t Context;                     /*!< JPEG Internal context */
135 
136 #if (USE_HAL_JPEG_REGISTER_CALLBACKS == 1)
137   void (*InfoReadyCallback)(struct __JPEG_HandleTypeDef *hjpeg,
138                             JPEG_ConfTypeDef *pInfo);  /*!< JPEG Info ready callback      */
139   void (*EncodeCpltCallback)(struct __JPEG_HandleTypeDef
140                              *hjpeg);                          /*!< JPEG Encode complete callback */
141   void (*DecodeCpltCallback)(struct __JPEG_HandleTypeDef
142                              *hjpeg);                          /*!< JPEG Decode complete callback */
143   void (*ErrorCallback)(struct __JPEG_HandleTypeDef
144                         *hjpeg);                               /*!< JPEG Error callback           */
145   void (*GetDataCallback)(struct __JPEG_HandleTypeDef *hjpeg,
146                           uint32_t NbDecodedData);     /*!< JPEG Get Data callback        */
147   void (*DataReadyCallback)(struct __JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOut,
148                             uint32_t OutDataLength);   /*!< JPEG Data ready callback */
149 
150   void (* MspInitCallback)(struct __JPEG_HandleTypeDef *hjpeg);                            /*!< JPEG Msp Init callback  */
151   void (* MspDeInitCallback)(struct __JPEG_HandleTypeDef
152                              *hjpeg);                          /*!< JPEG Msp DeInit callback  */
153 
154 
155 #endif /* (USE_HAL_JPEG_REGISTER_CALLBACKS) */
156 
157 
158 } JPEG_HandleTypeDef;
159 /**
160   * @}
161   */
162 
163 
164 #if (USE_HAL_JPEG_REGISTER_CALLBACKS == 1)
165 /** @defgroup HAL_JPEG_Callback_ID_enumeration_definition HAL JPEG Callback ID enumeration definition
166   * @brief  HAL JPEG Callback ID enumeration definition
167   * @{
168   */
169 typedef enum
170 {
171   HAL_JPEG_ENCODE_CPLT_CB_ID    = 0x01U,    /*!< JPEG Encode Complete callback ID */
172   HAL_JPEG_DECODE_CPLT_CB_ID    = 0x02U,    /*!< JPEG Decode Complete callback ID */
173   HAL_JPEG_ERROR_CB_ID          = 0x03U,    /*!< JPEG Error callback ID           */
174 
175   HAL_JPEG_MSPINIT_CB_ID        = 0x04U,    /*!< JPEG MspInit callback ID         */
176   HAL_JPEG_MSPDEINIT_CB_ID      = 0x05U     /*!< JPEG MspDeInit callback ID       */
177 
178 } HAL_JPEG_CallbackIDTypeDef;
179 /**
180   * @}
181   */
182 
183 /** @defgroup HAL_JPEG_Callback_pointer_definition HAL JPEG Callback pointer definition
184   * @brief  HAL JPEG Callback pointer definition
185   * @{
186   */
187 typedef  void (*pJPEG_CallbackTypeDef)(JPEG_HandleTypeDef *hjpeg);    /*!< pointer to a common JPEG callback function */
188 typedef  void (*pJPEG_InfoReadyCallbackTypeDef)(JPEG_HandleTypeDef *hjpeg,
189                                                 JPEG_ConfTypeDef *pInfo);  /*!< pointer to an Info ready JPEG callback function */
190 typedef  void (*pJPEG_GetDataCallbackTypeDef)(JPEG_HandleTypeDef *hjpeg,
191                                               uint32_t NbDecodedData);     /*!< pointer to a Get data JPEG callback function */
192 typedef  void (*pJPEG_DataReadyCallbackTypeDef)(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOut,
193                                                 uint32_t OutDataLength);  /*!< pointer to a Data ready JPEG callback function */
194 /**
195   * @}
196   */
197 
198 #endif /* USE_HAL_JPEG_REGISTER_CALLBACKS */
199 
200 /**
201   * @}
202   */
203 
204 /* Exported constants --------------------------------------------------------*/
205 
206 /** @defgroup JPEG_Exported_Constants JPEG Exported Constants
207   * @{
208   */
209 
210 /** @defgroup JPEG_Error_Code_definition JPEG Error Code definition
211   * @brief  JPEG Error Code definition
212   * @{
213   */
214 
215 #define  HAL_JPEG_ERROR_NONE        ((uint32_t)0x00000000U)    /*!< No error             */
216 #define  HAL_JPEG_ERROR_HUFF_TABLE  ((uint32_t)0x00000001U)    /*!< HUffman Table programming error */
217 #define  HAL_JPEG_ERROR_QUANT_TABLE ((uint32_t)0x00000002U)    /*!< Quantization Table programming error */
218 #define  HAL_JPEG_ERROR_DMA         ((uint32_t)0x00000004U)    /*!< DMA transfer error   */
219 #define  HAL_JPEG_ERROR_TIMEOUT     ((uint32_t)0x00000008U)    /*!< Timeout error        */
220 #if (USE_HAL_JPEG_REGISTER_CALLBACKS == 1)
221 #define  HAL_JPEG_ERROR_INVALID_CALLBACK ((uint32_t)0x00000010U)    /*!< Invalid Callback error  */
222 #endif /* USE_HAL_JPEG_REGISTER_CALLBACKS */
223 /**
224   * @}
225   */
226 
227 /** @defgroup JPEG_Quantization_Table_Size JPEG Quantization Table Size
228   * @brief  JPEG Quantization Table Size
229   * @{
230   */
231 #define JPEG_QUANT_TABLE_SIZE  ((uint32_t)64U) /*!< JPEG Quantization Table Size in bytes  */
232 /**
233   * @}
234   */
235 
236 
237 /** @defgroup JPEG_ColorSpace JPEG ColorSpace
238   * @brief  JPEG Color Space
239   * @{
240   */
241 #define JPEG_GRAYSCALE_COLORSPACE     ((uint32_t)0x00000000U)
242 #define JPEG_YCBCR_COLORSPACE         JPEG_CONFR1_COLORSPACE_0
243 #define JPEG_CMYK_COLORSPACE          JPEG_CONFR1_COLORSPACE
244 
245 
246 /**
247   * @}
248   */
249 
250 
251 /** @defgroup JPEG_ChromaSubsampling JPEG Chrominance Sampling
252   * @brief  JPEG Chrominance Sampling
253   * @{
254   */
255 #define JPEG_444_SUBSAMPLING     ((uint32_t)0x00000000U)   /*!< Chroma Subsampling 4:4:4 */
256 #define JPEG_420_SUBSAMPLING     ((uint32_t)0x00000001U)   /*!< Chroma Subsampling 4:2:0 */
257 #define JPEG_422_SUBSAMPLING     ((uint32_t)0x00000002U)   /*!< Chroma Subsampling 4:2:2 */
258 
259 /**
260   * @}
261   */
262 
263 /** @defgroup JPEG_ImageQuality JPEG Image Quality
264   * @brief  JPEG Min and Max Image Quality
265   * @{
266   */
267 #define JPEG_IMAGE_QUALITY_MIN     ((uint32_t)1U)     /*!< Minimum JPEG quality */
268 #define JPEG_IMAGE_QUALITY_MAX     ((uint32_t)100U)   /*!< Maximum JPEG quality */
269 
270 /**
271   * @}
272   */
273 
274 /** @defgroup JPEG_Interrupt_configuration_definition JPEG Interrupt configuration definition
275   * @brief JPEG Interrupt definition
276   * @{
277   */
278 #define JPEG_IT_IFT     ((uint32_t)JPEG_CR_IFTIE)   /*!< Input FIFO Threshold Interrupt */
279 #define JPEG_IT_IFNF    ((uint32_t)JPEG_CR_IFNFIE)  /*!< Input FIFO Not Full Interrupt */
280 #define JPEG_IT_OFT     ((uint32_t)JPEG_CR_OFTIE)   /*!< Output FIFO Threshold Interrupt */
281 #define JPEG_IT_OFNE    ((uint32_t)JPEG_CR_OFTIE)   /*!< Output FIFO Not Empty Interrupt */
282 #define JPEG_IT_EOC     ((uint32_t)JPEG_CR_EOCIE)   /*!< End of Conversion Interrupt */
283 #define JPEG_IT_HPD     ((uint32_t)JPEG_CR_HPDIE)   /*!< Header Parsing Done Interrupt */
284 /**
285   * @}
286   */
287 
288 /** @defgroup JPEG_Flag_definition JPEG Flag definition
289   * @brief JPEG Flags definition
290   * @{
291   */
292 #define JPEG_FLAG_IFTF     ((uint32_t)JPEG_SR_IFTF)   /*!< Input FIFO is not full and is below its threshold flag */
293 #define JPEG_FLAG_IFNFF    ((uint32_t)JPEG_SR_IFNFF)  /*!< Input FIFO Not Full Flag, a data can be written */
294 #define JPEG_FLAG_OFTF     ((uint32_t)JPEG_SR_OFTF)   /*!< Output FIFO is not empty and has reach its threshold */
295 #define JPEG_FLAG_OFNEF    ((uint32_t)JPEG_SR_OFNEF)  /*!< Output FIFO is not empty, a data is available  */
296 #define JPEG_FLAG_EOCF     ((uint32_t)JPEG_SR_EOCF)   /*!< JPEG Codec core has finished the encoding or the decoding process and than last data has been sent to the output FIFO  */
297 #define JPEG_FLAG_HPDF     ((uint32_t)JPEG_SR_HPDF)   /*!< JPEG Codec has finished the parsing of the headers and the internal registers have been updated  */
298 #define JPEG_FLAG_COF      ((uint32_t)JPEG_SR_COF)    /*!< JPEG Codec operation on going  flag*/
299 
300 #define JPEG_FLAG_ALL      ((uint32_t)0x000000FEU)     /*!< JPEG Codec All previous flag*/
301 /**
302   * @}
303   */
304 
305 /** @defgroup JPEG_PROCESS_PAUSE_RESUME_definition JPEG Process Pause Resume definition
306   * @brief JPEG process pause, resume definition
307   * @{
308   */
309 #define JPEG_PAUSE_RESUME_INPUT          ((uint32_t)0x00000001U)     /*!< Pause/Resume Input FIFO Xfer*/
310 #define JPEG_PAUSE_RESUME_OUTPUT         ((uint32_t)0x00000002U)     /*!< Pause/Resume Output FIFO Xfer*/
311 #define JPEG_PAUSE_RESUME_INPUT_OUTPUT   ((uint32_t)0x00000003U)     /*!< Pause/Resume Input and Output FIFO Xfer*/
312 /**
313   * @}
314   */
315 
316 /**
317   * @}
318   */
319 /* Exported macro ------------------------------------------------------------*/
320 
321 /** @defgroup JPEG_Exported_Macros JPEG Exported Macros
322   * @{
323   */
324 
325 /** @brief Reset JPEG handle state
326   * @param  __HANDLE__ specifies the JPEG handle.
327   * @retval None
328   */
329 #if (USE_HAL_JPEG_REGISTER_CALLBACKS == 1)
330 #define __HAL_JPEG_RESET_HANDLE_STATE(__HANDLE__) do{\
331                                                       (__HANDLE__)->State = HAL_JPEG_STATE_RESET;\
332                                                       (__HANDLE__)->MspInitCallback = NULL;\
333                                                       (__HANDLE__)->MspDeInitCallback = NULL;\
334                                                       }while(0)
335 #else
336 #define __HAL_JPEG_RESET_HANDLE_STATE(__HANDLE__) ( (__HANDLE__)->State = HAL_JPEG_STATE_RESET)
337 #endif /* USE_HAL_JPEG_REGISTER_CALLBACKS */
338 
339 
340 /**
341   * @brief  Enable the JPEG peripheral.
342   * @param  __HANDLE__ specifies the JPEG handle.
343   * @retval None
344   */
345 #define __HAL_JPEG_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR |=  JPEG_CR_JCEN)
346 
347 /**
348   * @brief Disable the JPEG peripheral.
349   * @param  __HANDLE__ specifies the JPEG handle.
350   * @retval None
351   */
352 #define __HAL_JPEG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &=  ~JPEG_CR_JCEN)
353 
354 
355 /**
356   * @brief  Check the specified JPEG status flag.
357   * @param  __HANDLE__ specifies the JPEG handle.
358   * @param  __FLAG__  specifies the flag to check
359   *         This parameter can be one of the following values:
360   *         @arg JPEG_FLAG_IFTF  : The input FIFO is not full and is below its threshold flag
361   *         @arg JPEG_FLAG_IFNFF : The input FIFO Not Full Flag, a data can be written
362   *         @arg JPEG_FLAG_OFTF  : The output FIFO is not empty and has reach its threshold
363   *         @arg JPEG_FLAG_OFNEF : The output FIFO is not empty, a data is available
364   *         @arg JPEG_FLAG_EOCF  : JPEG Codec core has finished the encoding or the decoding process
365   *                                and than last data has been sent to the output FIFO
366   *         @arg JPEG_FLAG_HPDF  : JPEG Codec has finished the parsing of the headers
367   *                                and the internal registers have been updated
368   *         @arg JPEG_FLAG_COF   : JPEG Codec operation on going  flag
369   *
370   * @retval __HAL_JPEG_GET_FLAG : returns The new state of __FLAG__ (TRUE or FALSE)
371   */
372 
373 #define __HAL_JPEG_GET_FLAG(__HANDLE__,__FLAG__)  (((__HANDLE__)->Instance->SR & (__FLAG__)))
374 
375 /**
376   * @brief  Clear the specified JPEG status flag.
377   * @param  __HANDLE__ specifies the JPEG handle.
378   * @param  __FLAG__  specifies the flag to clear
379   *         This parameter can be one of the following values:
380   *         @arg JPEG_FLAG_EOCF  : JPEG Codec core has finished the encoding or the decoding process
381   *                                and than last data has been sent to the output FIFO
382   *         @arg JPEG_FLAG_HPDF  : JPEG Codec has finished the parsing of the headers
383   * @retval None
384   */
385 
386 #define __HAL_JPEG_CLEAR_FLAG(__HANDLE__,__FLAG__)  (((__HANDLE__)->Instance->CFR |= ((__FLAG__) &\
387                                                       (JPEG_FLAG_EOCF | JPEG_FLAG_HPDF))))
388 
389 
390 /**
391   * @brief  Enable Interrupt.
392   * @param   __HANDLE__ specifies the JPEG handle.
393   * @param  __INTERRUPT__  specifies the interrupt to enable
394   *         This parameter can be one of the following values:
395   *         @arg JPEG_IT_IFT   : Input FIFO Threshold Interrupt
396   *         @arg JPEG_IT_IFNF  : Input FIFO Not Full Interrupt
397   *         @arg JPEG_IT_OFT   : Output FIFO Threshold Interrupt
398   *         @arg JPEG_IT_OFNE  : Output FIFO Not empty Interrupt
399   *         @arg JPEG_IT_EOC   : End of Conversion Interrupt
400   *         @arg JPEG_IT_HPD   : Header Parsing Done Interrupt
401   *
402   * @retval No return
403   */
404 #define __HAL_JPEG_ENABLE_IT(__HANDLE__,__INTERRUPT__)  ((__HANDLE__)->Instance->CR |= (__INTERRUPT__) )
405 
406 /**
407   * @brief  Disable Interrupt.
408   * @param   __HANDLE__ specifies the JPEG handle.
409   * @param  __INTERRUPT__ specifies the interrupt to disable
410   *         This parameter can be one of the following values:
411   *         @arg JPEG_IT_IFT   : Input FIFO Threshold Interrupt
412   *         @arg JPEG_IT_IFNF  : Input FIFO Not Full Interrupt
413   *         @arg JPEG_IT_OFT   : Output FIFO Threshold Interrupt
414   *         @arg JPEG_IT_OFNE  : Output FIFO Not empty Interrupt
415   *         @arg JPEG_IT_EOC   : End of Conversion Interrupt
416   *         @arg JPEG_IT_HPD   : Header Parsing Done Interrupt
417   *
418   * @note    To disable an IT we must use MODIFY_REG macro to avoid writing "1" to the FIFO flush bits
419   *          located in the same IT enable register (CR register).
420   * @retval  No return
421   */
422 #define __HAL_JPEG_DISABLE_IT(__HANDLE__,__INTERRUPT__) MODIFY_REG((__HANDLE__)->Instance->CR, (__INTERRUPT__), 0UL)
423 
424 
425 /**
426   * @brief  Get Interrupt state.
427   * @param   __HANDLE__ specifies the JPEG handle.
428   * @param  __INTERRUPT__  specifies the interrupt to check
429   *         This parameter can be one of the following values:
430   *         @arg JPEG_IT_IFT   : Input FIFO Threshold Interrupt
431   *         @arg JPEG_IT_IFNF  : Input FIFO Not Full Interrupt
432   *         @arg JPEG_IT_OFT   : Output FIFO Threshold Interrupt
433   *         @arg JPEG_IT_OFNE  : Output FIFO Not empty Interrupt
434   *         @arg JPEG_IT_EOC   : End of Conversion Interrupt
435   *         @arg JPEG_IT_HPD   : Header Parsing Done Interrupt
436   *
437   * @retval returns The new state of __INTERRUPT__ (Enabled or disabled)
438   */
439 #define __HAL_JPEG_GET_IT_SOURCE(__HANDLE__,__INTERRUPT__)     ((__HANDLE__)->Instance->CR & (__INTERRUPT__))
440 
441 /**
442   * @}
443   */
444 
445 /* Exported functions --------------------------------------------------------*/
446 /** @addtogroup JPEG_Exported_Functions
447   * @{
448   */
449 
450 /** @addtogroup JPEG_Exported_Functions_Group1
451   * @{
452   */
453 /* Initialization/de-initialization functions  ********************************/
454 HAL_StatusTypeDef HAL_JPEG_Init(JPEG_HandleTypeDef *hjpeg);
455 HAL_StatusTypeDef HAL_JPEG_DeInit(JPEG_HandleTypeDef *hjpeg);
456 void HAL_JPEG_MspInit(JPEG_HandleTypeDef *hjpeg);
457 void HAL_JPEG_MspDeInit(JPEG_HandleTypeDef *hjpeg);
458 
459 #if (USE_HAL_JPEG_REGISTER_CALLBACKS == 1)
460 HAL_StatusTypeDef HAL_JPEG_RegisterCallback(JPEG_HandleTypeDef *hjpeg, HAL_JPEG_CallbackIDTypeDef CallbackID,
461                                             pJPEG_CallbackTypeDef pCallback);
462 HAL_StatusTypeDef HAL_JPEG_UnRegisterCallback(JPEG_HandleTypeDef *hjpeg, HAL_JPEG_CallbackIDTypeDef CallbackID);
463 
464 HAL_StatusTypeDef HAL_JPEG_RegisterInfoReadyCallback(JPEG_HandleTypeDef *hjpeg,
465                                                      pJPEG_InfoReadyCallbackTypeDef pCallback);
466 HAL_StatusTypeDef HAL_JPEG_UnRegisterInfoReadyCallback(JPEG_HandleTypeDef *hjpeg);
467 
468 HAL_StatusTypeDef HAL_JPEG_RegisterGetDataCallback(JPEG_HandleTypeDef *hjpeg, pJPEG_GetDataCallbackTypeDef pCallback);
469 HAL_StatusTypeDef HAL_JPEG_UnRegisterGetDataCallback(JPEG_HandleTypeDef *hjpeg);
470 
471 HAL_StatusTypeDef HAL_JPEG_RegisterDataReadyCallback(JPEG_HandleTypeDef *hjpeg,
472                                                      pJPEG_DataReadyCallbackTypeDef pCallback);
473 HAL_StatusTypeDef HAL_JPEG_UnRegisterDataReadyCallback(JPEG_HandleTypeDef *hjpeg);
474 
475 #endif /* USE_HAL_JPEG_REGISTER_CALLBACKS */
476 
477 /**
478   * @}
479   */
480 
481 /** @addtogroup JPEG_Exported_Functions_Group2
482   * @{
483   */
484 /* Encoding/Decoding Configuration functions  ********************************/
485 HAL_StatusTypeDef HAL_JPEG_ConfigEncoding(JPEG_HandleTypeDef *hjpeg, JPEG_ConfTypeDef *pConf);
486 HAL_StatusTypeDef HAL_JPEG_GetInfo(JPEG_HandleTypeDef *hjpeg, JPEG_ConfTypeDef *pInfo);
487 HAL_StatusTypeDef HAL_JPEG_EnableHeaderParsing(JPEG_HandleTypeDef *hjpeg);
488 HAL_StatusTypeDef HAL_JPEG_DisableHeaderParsing(JPEG_HandleTypeDef *hjpeg);
489 HAL_StatusTypeDef HAL_JPEG_SetUserQuantTables(JPEG_HandleTypeDef *hjpeg, uint8_t *QTable0, uint8_t *QTable1,
490                                               uint8_t *QTable2, uint8_t *QTable3);
491 
492 /**
493   * @}
494   */
495 
496 /** @addtogroup JPEG_Exported_Functions_Group3
497   * @{
498   */
499 /* JPEG processing functions  **************************************/
500 HAL_StatusTypeDef  HAL_JPEG_Encode(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataInMCU, uint32_t InDataLength,
501                                    uint8_t *pDataOut, uint32_t OutDataLength, uint32_t Timeout);
502 HAL_StatusTypeDef  HAL_JPEG_Decode(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataIn, uint32_t InDataLength,
503                                    uint8_t *pDataOutMCU, uint32_t OutDataLength, uint32_t Timeout);
504 HAL_StatusTypeDef  HAL_JPEG_Encode_IT(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataInMCU, uint32_t InDataLength,
505                                       uint8_t *pDataOut, uint32_t OutDataLength);
506 HAL_StatusTypeDef  HAL_JPEG_Decode_IT(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataIn, uint32_t InDataLength,
507                                       uint8_t *pDataOutMCU, uint32_t OutDataLength);
508 HAL_StatusTypeDef  HAL_JPEG_Encode_DMA(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataInMCU, uint32_t InDataLength,
509                                        uint8_t *pDataOut, uint32_t OutDataLength);
510 HAL_StatusTypeDef  HAL_JPEG_Decode_DMA(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataIn, uint32_t InDataLength,
511                                        uint8_t *pDataOutMCU, uint32_t OutDataLength);
512 HAL_StatusTypeDef  HAL_JPEG_Pause(JPEG_HandleTypeDef *hjpeg, uint32_t XferSelection);
513 HAL_StatusTypeDef  HAL_JPEG_Resume(JPEG_HandleTypeDef *hjpeg, uint32_t XferSelection);
514 void HAL_JPEG_ConfigInputBuffer(JPEG_HandleTypeDef *hjpeg, uint8_t *pNewInputBuffer, uint32_t InDataLength);
515 void HAL_JPEG_ConfigOutputBuffer(JPEG_HandleTypeDef *hjpeg, uint8_t *pNewOutputBuffer, uint32_t OutDataLength);
516 HAL_StatusTypeDef HAL_JPEG_Abort(JPEG_HandleTypeDef *hjpeg);
517 
518 /**
519   * @}
520   */
521 
522 /** @addtogroup JPEG_Exported_Functions_Group4
523   * @{
524   */
525 /* JPEG Decode/Encode callback functions  ********************************************************/
526 void HAL_JPEG_InfoReadyCallback(JPEG_HandleTypeDef *hjpeg, JPEG_ConfTypeDef *pInfo);
527 void HAL_JPEG_EncodeCpltCallback(JPEG_HandleTypeDef *hjpeg);
528 void HAL_JPEG_DecodeCpltCallback(JPEG_HandleTypeDef *hjpeg);
529 void HAL_JPEG_ErrorCallback(JPEG_HandleTypeDef *hjpeg);
530 void HAL_JPEG_GetDataCallback(JPEG_HandleTypeDef *hjpeg, uint32_t NbDecodedData);
531 void HAL_JPEG_DataReadyCallback(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOut, uint32_t OutDataLength);
532 
533 /**
534   * @}
535   */
536 
537 /** @addtogroup JPEG_Exported_Functions_Group5
538   * @{
539   */
540 /* JPEG IRQ handler management  ******************************************************/
541 void HAL_JPEG_IRQHandler(JPEG_HandleTypeDef *hjpeg);
542 
543 /**
544   * @}
545   */
546 
547 /** @addtogroup JPEG_Exported_Functions_Group6
548   * @{
549   */
550 /* Peripheral State and Error functions  ************************************************/
551 HAL_JPEG_STATETypeDef  HAL_JPEG_GetState(const JPEG_HandleTypeDef *hjpeg);
552 uint32_t               HAL_JPEG_GetError(const JPEG_HandleTypeDef *hjpeg);
553 
554 /**
555   * @}
556   */
557 
558 /**
559   * @}
560   */
561 
562 /* Private types -------------------------------------------------------------*/
563 /** @defgroup JPEG_Private_Types JPEG Private Types
564   * @{
565   */
566 
567 /**
568   * @}
569   */
570 
571 /* Private defines -----------------------------------------------------------*/
572 /** @defgroup JPEG_Private_Defines JPEG Private Defines
573   * @{
574   */
575 
576 /**
577   * @}
578   */
579 
580 /* Private variables ---------------------------------------------------------*/
581 /** @defgroup JPEG_Private_Variables JPEG Private Variables
582   * @{
583   */
584 
585 /**
586   * @}
587   */
588 
589 /* Private constants ---------------------------------------------------------*/
590 /** @defgroup JPEG_Private_Constants JPEG Private Constants
591   * @{
592   */
593 
594 /**
595   * @}
596   */
597 
598 /* Private macros ------------------------------------------------------------*/
599 /** @defgroup JPEG_Private_Macros JPEG Private Macros
600   * @{
601   */
602 
603 #define IS_JPEG_CHROMASUBSAMPLING(SUBSAMPLING) (((SUBSAMPLING) == JPEG_444_SUBSAMPLING) || \
604                                                 ((SUBSAMPLING) == JPEG_420_SUBSAMPLING) || \
605                                                 ((SUBSAMPLING) == JPEG_422_SUBSAMPLING))
606 
607 #define IS_JPEG_IMAGE_QUALITY(NUMBER) (((NUMBER) >= JPEG_IMAGE_QUALITY_MIN) && ((NUMBER) <= JPEG_IMAGE_QUALITY_MAX))
608 
609 #define IS_JPEG_COLORSPACE(COLORSPACE) (((COLORSPACE) == JPEG_GRAYSCALE_COLORSPACE) || \
610                                         ((COLORSPACE) == JPEG_YCBCR_COLORSPACE)     || \
611                                         ((COLORSPACE) == JPEG_CMYK_COLORSPACE))
612 
613 #define IS_JPEG_PAUSE_RESUME_STATE(VALUE) (((VALUE) == JPEG_PAUSE_RESUME_INPUT) || \
614                                            ((VALUE) == JPEG_PAUSE_RESUME_OUTPUT)|| \
615                                            ((VALUE) == JPEG_PAUSE_RESUME_INPUT_OUTPUT))
616 
617 /**
618   * @}
619   */
620 
621 /* Private functions prototypes ----------------------------------------------*/
622 /** @defgroup JPEG_Private_Functions_Prototypes JPEG Private Functions Prototypes
623   * @{
624   */
625 
626 /**
627   * @}
628   */
629 
630 /* Private functions ---------------------------------------------------------*/
631 /** @defgroup JPEG_Private_Functions JPEG Private Functions
632   * @{
633   */
634 
635 /**
636   * @}
637   */
638 
639 /**
640   * @}
641   */
642 
643 /**
644   * @}
645   */
646 
647 #endif /* JPEG */
648 
649 #ifdef __cplusplus
650 }
651 #endif
652 
653 #endif /* STM32U5xx_HAL_JPEG_H */
654