• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  ****************************************************************************************
3  *
4  * @file    gr55xx_hal_hmac.h
5  * @author  BLE Driver Team
6  * @brief   Header file containing functions prototypes of HMAC HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10   #####Copyright (c) 2019 GOODIX
11   All rights reserved.
12 
13     Redistribution and use in source and binary forms, with or without
14     modification, are permitted provided that the following conditions are met:
15   * Redistributions of source code must retain the above copyright
16     notice, this list of conditions and the following disclaimer.
17   * Redistributions in binary form must reproduce the above copyright
18     notice, this list of conditions and the following disclaimer in the
19     documentation and/or other materials provided with the distribution.
20   * Neither the name of GOODIX nor the names of its contributors may be used
21     to endorse or promote products derived from this software without
22     specific prior written permission.
23 
24   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34   POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39   * @{
40   */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43   * @{
44   */
45 
46 /** @defgroup HAL_HMAC HMAC
47   * @brief HMAC HAL module driver.
48   * @{
49   */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_HMAC_H__
53 #define __GR55xx_HAL_HMAC_H__
54 
55 /* Includes ------------------------------------------------------------------*/
56 #include "gr55xx_ll_hmac.h"
57 #include "gr55xx_hal_def.h"
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_HMAC_ENUMERATIONS Enumerations
65   * @{
66   */
67 
68 /** @defgroup HAL_HMAC_state HAL HMAC state
69   * @{
70   */
71 
72 /**
73   * @brief HAL HMAC State enumerations definition
74   * @note  HAL HMAC State value is a combination of 2 different substates: gState and RxState.
75   */
76 typedef enum {
77     HAL_HMAC_STATE_RESET             = 0x00,    /**< Peripheral not initialized                            */
78     HAL_HMAC_STATE_READY             = 0x01,    /**< Peripheral initialized and ready for use              */
79     HAL_HMAC_STATE_BUSY              = 0x02,    /**< Peripheral in indirect mode and busy                  */
80     HAL_HMAC_STATE_ERROR             = 0x03,    /**< Peripheral in error                                   */
81     HAL_HMAC_STATE_TIMEOUT           = 0x04,    /**< Peripheral in timeout                                 */
82     HAL_HMAC_STATE_SUSPENDED         = 0x05,    /**< Peripheral in suspended                               */
83 } hal_hmac_state_t;
84 
85 /** @} */
86 
87 /** @} */
88 
89 /** @addtogroup HAL_HMAC_STRUCTURES Structures
90   * @{
91   */
92 
93 /** @defgroup HMAC_Configuration HMAC Configuration
94   * @{
95   */
96 
97 /**
98   * @brief HMAC init Structure definition
99   */
100 typedef struct _hmac_init {
101     uint32_t mode;              /**< Operating mode               */
102 
103     uint32_t *p_key;              /**< Encryption/Decryption Key  */
104 
105     uint32_t *p_user_hash;        /**< Initialization HASH value  */
106 
107     uint32_t key_fetch_type;      /**< @ref HAL_HMAC_KEYTYPE_MCU Fetch key from ram;
108                                      { Start_private
109                                      @ref HAL_HMAC_KEYTYPE_AHB Fetch key from AHB;
110                                      } End_private
111                                      @ref HAL_HMAC_KEYTYPE_KRAM Fetch key from keyport */
112     uint32_t dpa_mode;            /**< DPA Mode                   */
113 } hmac_init_t;
114 /** @} */
115 
116 /** @defgroup HMAC_handle HMAC handle
117   * @{
118   */
119 
120 /**
121   * @brief HMAC handle Structure definition
122   */
123 typedef struct _hmac_handle {
124     hmac_regs_t           *p_instance;        /**< HMAC registers base address            */
125 
126     hmac_init_t           init;             /**< HMAC operation parameters                */
127 
128     uint32_t              *p_message;         /**< Pointer to message input buffer        */
129 
130     uint32_t              *p_digest;          /**< Pointer to digest output buffer        */
131 
132     uint32_t              block_size;       /**< Data size in blocks (64 bytes per block) */
133 
134     uint32_t              block_count;      /**< Blocks count                             */
135 
136     uint32_t              is_last_trans;    /**< Flag for last transfer                   */
137 
138     __IO hal_lock_t       lock;             /**< Locking object                           */
139 
140     __IO hal_hmac_state_t state;            /**< HMAC operation state                     */
141 
142     __IO uint32_t         error_code;       /**< HMAC Error code                          */
143 
144     uint32_t              timeout;          /**< Timeout for the HMAC operation           */
145 
146     uint32_t              retention[17];    /**< HMAC important register information.     */
147 } hmac_handle_t;
148 
149 /** @} */
150 
151 /** @} */
152 
153 /** @addtogroup HAL_HMAC_CALLBACK_STRUCTURES Callback Structures
154   * @{
155   */
156 
157 /** @defgroup HAL_HMAC_Callback Callback
158   * @{
159   */
160 
161 /**
162   * @brief HAL_HMAC Callback function definition
163   */
164 
165 typedef struct _hal_hmac_callback {
166     void (*hmac_msp_init)(hmac_handle_t *p_hmac);               /**< HMAC init MSP callback             */
167     void (*hmac_msp_deinit)(hmac_handle_t *p_hmac);             /**< HMAC de-init MSP callback          */
168     void (*hmac_done_callback)(hmac_handle_t *p_hmac);          /**< HMAC digest done callback          */
169     void (*hmac_error_callback)(hmac_handle_t *p_hmac);         /**< HMAC error callback                */
170 } hal_hmac_callback_t;
171 
172 /** @} */
173 
174 /** @} */
175 
176 /**
177   * @defgroup  HAL_HMAC_MACRO Defines
178   * @{
179   */
180 
181 /* Exported constants --------------------------------------------------------*/
182 /** @defgroup HMAC_Exported_Constants HMAC Exported Constants
183   * @{
184   */
185 
186 /** @defgroup HMAC_Error_Code HMAC Error Code
187   * @{
188   */
189 #define HAL_HMAC_ERROR_NONE             ((uint32_t)0x00000000)          /**< No error           */
190 #define HAL_HMAC_ERROR_TIMEOUT          ((uint32_t)0x00000001)          /**< Timeout error      */
191 #define HAL_HMAC_ERROR_TRANSFER         ((uint32_t)0x00000002)          /**< Transfer error     */
192 #define HAL_HMAC_ERROR_INVALID_PARAM    ((uint32_t)0x00000004)          /**< Invalid parameters error */
193 /** @} */
194 
195 /** @defgroup HMAC_Mode HMAC Mode
196   * @{
197   */
198 #define HMAC_MODE_SHA                   LL_HMAC_CALCULATETYPE_SHA       /**< SHA mode  */
199 #define HMAC_MODE_HMAC                  LL_HMAC_CALCULATETYPE_HMAC      /**< HMAC mode */
200 /** @} */
201 
202 /** @defgroup HMAC_Block_Size HAMC Block Size
203   * @{
204   */
205 #define HMAC_BLOCK_MAX                  (512)                           /**< Block max size        */
206 #define HMAC_BLOCKSIZE_BITS             (512)                           /**< Block size in bits    */
207 #define HMAC_BLOCKSIZE_BYTES            (HMAC_BLOCKSIZE_BITS >> 3)      /**< Block size in bytes   */
208 #define HMAC_BLOCKSIZE_WORDS            (HMAC_BLOCKSIZE_BYTES >> 2)     /**< Block size in words   */
209 #define HMAC_DIGESTSIZE_BITS            (256)                           /**< Digest size in bits   */
210 #define HMAC_DIGESTSIZE_BYTES           (HMAC_DIGESTSIZE_BITS >> 3)     /**< Digest size in bytes  */
211 #define HMAC_DIGESTSIZE_WORDS           (HMAC_DIGESTSIZE_BYTES >> 2)    /**< Digest size in words  */
212 #define HMAC_DMA_BLOCK_MAX              (512)                           /**< DMA Block max size    */
213 /** @} */
214 
215 /** @defgroup HMAC_Flags_definition HAMC Flags Definition
216   * @{
217   */
218 #define HMAC_FLAG_DATAREADY_SHA         LL_HMAC_FLAG_DATAREADY_SHA      /**< HMAC data ready (SHA mode)  */
219 #define HMAC_FLAG_DATAREADY_HMAC        LL_HMAC_FLAG_DATAREADY_HMAC     /**< HMAC data ready (HAMC mode) */
220 #define HMAC_FLAG_DMA_MESSAGEDONE       LL_HMAC_FLAG_DMA_MESSAGEDONE    /**< HMAC DMA message done       */
221 #define HMAC_FLAG_DMA_DONE              LL_HMAC_FLAG_DMA_DONE           /**< HMAC DMA transfer done      */
222 #define HMAC_FLAG_DMA_ERR               LL_HMAC_FLAG_DMA_ERR            /**< HMAC DMA transfer error     */
223 #define HMAC_FLAG_KEY_VALID             LL_HMAC_FLAG_KEY_VALID          /**< HMAC has fetched key        */
224 /** @} */
225 
226 /** @defgroup HMAC_HAL_KEY_TYPE Key Type
227   * @{
228   */
229 #define HAL_HMAC_KEYTYPE_MCU            LL_HMAC_KEYTYPE_MCU                      /**< Key from MCU        */
230 /* { Start_private */
231 #define HAL_HMAC_KEYTYPE_AHB            LL_HMAC_KEYTYPE_AHB                      /**< Key from AHB master */
232 /* } End_private   */
233 #define HAL_HMAC_KEYTYPE_KRAM           LL_HMAC_KEYTYPE_KRAM                     /**< Key from Key Port   */
234 /** @} */
235 
236 /** @defgroup HMAC_Interrupt_definition HMAC Interrupt_definition
237   * @{
238   */
239 #define HMAC_IT_DONE                    ((uint32_t)0x00000001)          /**< Operation Done Interrupt source */
240 /** @} */
241 
242 /** @defgroup HMAC_Timeout_definition HMAC Timeout_definition
243   * @{
244   */
245 #define HAL_HMAC_TIMEOUT_DEFAULT_VALUE  ((uint32_t)5000)                /**< 5s */
246 /** @} */
247 
248 /** @} */
249 
250 /* Exported macro ------------------------------------------------------------*/
251 /** @defgroup HMAC_Exported_Macros HMAC Exported Macros
252   * @{
253   */
254 
255 /** @brief  Reset HMAC handle states.
256   * @param  __HANDLE__ HMAC handle.
257   * @retval None
258   */
259 #define __HAL_HMAC_RESET_HANDLE_STATE(__HANDLE__)         ((__HANDLE__)->state = HAL_HMAC_STATE_RESET)
260 
261 /** @brief  Enable the specified HMAC peripheral.
262   * @param  __HANDLE__ Specifies the HMAC Handle.
263   * @retval None
264   */
265 #define __HAL_HMAC_ENABLE(__HANDLE__)                     SET_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_ENABLE)
266 
267 /** @brief  Disable the specified HMAC peripheral.
268   * @param  __HANDLE__ Specifies the HMAC Handle.
269   * @retval None
270   */
271 #define __HAL_HMAC_DISABLE(__HANDLE__)                    CLEAR_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_ENABLE)
272 
273 /** @brief  Enable the HMAC interrupt.
274   * @param  __HANDLE__ Specifies the HMAC Handle.
275   * @retval None
276   */
277 #define __HAL_HMAC_ENABLE_IT(__HANDLE__)                  ll_hmac_enable_it_done((__HANDLE__)->p_instance)
278 
279 /** @brief  Disable the HMAC interrupt.
280   * @param  __HANDLE__ Specifies the HMAC Handle.
281   * @retval None
282   */
283 #define __HAL_HMAC_DISABLE_IT(__HANDLE__)                 ll_hmac_disable_it_done((__HANDLE__)->p_instance)
284 
285 /** @brief  Check whether the specified HMAC interrupt flag is set or not.
286   * @param  __HANDLE__  Specifies the HMAC Handle.
287   * @param  __FLAG__    Specifies the interrupt flag to check.
288   *         This parameter can be one of the following values:
289   *            @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
290   * @retval The new state of __FLAG__ (TRUE or FALSE).
291   */
292 #define __HAL_HMAC_GET_FLAG_IT(__HANDLE__, __FLAG__) \
293     (READ_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__)) == (__FLAG__))
294 
295 /** @brief  Clear the specified HMAC interrupt flag.
296   * @param  __HANDLE__  Specifies the HMAC interrupt Handle.
297   * @param  __FLAG__    Specifies the flag to clear.
298   *         This parameter can be one of the following values:
299   *            @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
300   * @retval None
301   */
302 #define __HAL_HMAC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__)    SET_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__))
303 
304 /** @brief  Check whether the specified HMAC flag is set or not.
305   * @param  __HANDLE__  Specifies the HMAC Handle.
306   * @param  __FLAG__    Specifies the flag to check.
307   *         This parameter can be one of the following values:
308   *            @arg @ref HMAC_FLAG_DATAREADY_SHA Data ready (SHA mode) flag
309   *            @arg @ref HMAC_FLAG_DATAREADY_HMAC Data ready (HMAC mode) flag
310   *            @arg @ref HMAC_FLAG_DMA_DONE DMA transfer done flag
311   *            @arg @ref HMAC_FLAG_DMA_ERR DMA transfer error flag
312   *            @arg @ref HMAC_FLAG_KEY_VALID Key valid flag
313   * @retval The new state of __FLAG__ (TRUE or FALSE).
314   */
315 #define __HAL_HMAC_GET_FLAG(__HANDLE__, __FLAG__) \
316     ((READ_BITS((__HANDLE__)->p_instance->STATUS, (__FLAG__)) != 0) ? SET : RESET)
317 
318 /** @} */
319 
320 /** @} */
321 
322 /* Exported functions --------------------------------------------------------*/
323 /** @addtogroup HAL_HMAC_DRIVER_FUNCTIONS Functions
324   * @{
325   */
326 
327 /** @addtogroup HMAC_Exported_Functions_Group1 Initialization and de-initialization functions
328   * @brief    Initialization and de-initialization functions
329  *
330 @verbatim
331  ===============================================================================
332               ##### Initialization and de-initialization functions #####
333  ===============================================================================
334     [..]  This subsection provides a set of functions allowing to initialize and
335           de-initialize the HMACx peripheral.
336 
337       (+) User must implement hal_hmac_msp_init() function in which he configures
338           all related peripherals resources (GPIO, DMA, IT and NVIC ).
339 
340       (+) Call the function hal_hmac_init() to configure the selected device with
341           the selected configuration:
342         (++) mode
343         (++) key
344         (++) user_hash
345         (++) dpa_mode
346 
347       (+) Call the function hal_hmac_deinit() to restore the default configuration
348           of the selected HMACx peripheral.
349 
350 @endverbatim
351   * @{
352   */
353 
354 /**
355  ****************************************************************************************
356  * @brief  Initialize the HMAC according to the specified parameters
357  *         in the hmac_init_t and initialize the associated handle.
358  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
359  *             for the specified HMAC module.
360  * @retval ::HAL_OK: Operation is OK.
361  * @retval ::HAL_ERROR: Parameter error or operation not supported.
362  * @retval ::HAL_BUSY: Driver is busy.
363  * @retval ::HAL_TIMEOUT: Timeout occurred.
364  ****************************************************************************************
365  */
366 hal_status_t hal_hmac_init(hmac_handle_t *p_hmac);
367 
368 /**
369  ****************************************************************************************
370  * @brief  De-initialize the HMAC peripheral.
371  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
372  *             for the specified HMAC module.
373  * @retval ::HAL_OK: Operation is OK.
374  * @retval ::HAL_ERROR: Parameter error or operation not supported.
375  * @retval ::HAL_BUSY: Driver is busy.
376  * @retval ::HAL_TIMEOUT: Timeout occurred.
377  ****************************************************************************************
378  */
379 hal_status_t hal_hmac_deinit(hmac_handle_t *p_hmac);
380 
381 /**
382  ****************************************************************************************
383  * @brief  Initialize the HMAC MSP.
384  * @note   This function should not be modified. When the callback is needed,
385             the hal_hmac_msp_deinit can be implemented in the user file.
386  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
387  *             for the specified HMAC module.
388  ****************************************************************************************
389  */
390 void hal_hmac_msp_init(hmac_handle_t *p_hmac);
391 
392 /**
393  ****************************************************************************************
394  * @brief  De-initialize the HMAC MSP.
395  * @note   This function should not be modified. When the callback is needed,
396             the HAL_HMAC_MspDeInit can be implemented in the user file.
397  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
398  *             for the specified HMAC module.
399  ****************************************************************************************
400  */
401 void hal_hmac_msp_deinit(hmac_handle_t *p_hmac);
402 
403 /** @} */
404 
405 /** @addtogroup HMAC_Exported_Functions_Group2 IO operation functions
406   * @brief HMAC Encrypt/Decrypt functions
407   *
408 @verbatim
409  ===============================================================================
410                       ##### IO operation functions #####
411  ===============================================================================
412     This subsection provides a set of functions allowing to manage the HMAC encrypt or decrypt.
413 
414     (#) There are two mode of transfer:
415        (++) Blocking mode: The communication is performed in polling mode.
416            The HAL status of all data processing is returned by the same function
417            after finishing transfer.
418        (++) Non-Blocking mode: The communication is performed using Interrupts
419            or DMA, These API's return the HAL status.
420            The end of the data processing will be indicated through the
421            dedicated HMAC IRQ when using Interrupt mode or the DMA IRQ when
422            using DMA mode.
423            The hal_hmac_done_callback() user callbacks will be executed respectively
424            at the end of the encrypt or decrypt process
425            The hal_hmac_error_callback() user callback will be executed when a error is detected
426 
427     (#) Blocking mode API's are :
428         (++) hal_hmac_sha256_digest()
429 
430     (#) Non-Blocking mode API's with Interrupt are :
431         (++) hal_hmac_sha256_digest_it()
432 
433     (#) Non-Blocking mode API's with DMA are :
434         (++) hal_hmac_sha256_digest_dma()
435 
436     (#) A set of encrypt or decrypt Callbacks are provided in Non_Blocking mode:
437         (++) hal_hmac_done_callback()
438         (++) hal_hmac_error_callback()
439 
440 @endverbatim
441   * @{
442   */
443 
444 /**
445  ****************************************************************************************
446  * @brief  xxx in blocking mode in SHA/HMAC mode.
447  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
448  *             for the specified HMAC module.
449  * @param[in]  p_message: Pointer to message buffer
450  * @param[in]  number: Amount of data
451  * @param[out] p_digest: Pointer to digest buffer
452  * @param[in]  timeout: Timeout duration
453  * @retval ::HAL_OK: Operation is OK.
454  * @retval ::HAL_ERROR: Parameter error or operation not supported.
455  * @retval ::HAL_BUSY: Driver is busy.
456  * @retval ::HAL_TIMEOUT: Timeout occurred.
457  ****************************************************************************************
458  */
459 hal_status_t hal_hmac_sha256_digest(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number,
460                                     uint32_t *p_digest, uint32_t timeout);
461 
462 /**
463  ****************************************************************************************
464  * @brief  xxx in non-blocking mode with interrupt in SHA/HMAC mode.
465  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
466  *             for the specified HMAC module.
467  * @param[in]  p_message: Pointer to message buffer
468  * @param[in]  number: Amount of data
469  * @param[out] p_digest: Pointer to digest buffer
470  * @retval ::HAL_OK: Operation is OK.
471  * @retval ::HAL_ERROR: Parameter error or operation not supported.
472  * @retval ::HAL_BUSY: Driver is busy.
473  * @retval ::HAL_TIMEOUT: Timeout occurred.
474  ****************************************************************************************
475  */
476 hal_status_t hal_hmac_sha256_digest_it(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
477 
478 /**
479  ****************************************************************************************
480  * @brief  xxx in non-blocking mode with DMA in SHA/HMAC mode.
481  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
482  *             for the specified HMAC module.
483  * @param[in]  p_message: Pointer to massage buffer
484  * @param[in]  number: Amount of data
485  * @param[out] p_digest: Pointer to digest buffer
486  * @retval ::HAL_OK: Operation is OK.
487  * @retval ::HAL_ERROR: Parameter error or operation not supported.
488  * @retval ::HAL_BUSY: Driver is busy.
489  * @retval ::HAL_TIMEOUT: Timeout occurred.
490  ****************************************************************************************
491  */
492 hal_status_t hal_hmac_sha256_digest_dma(hmac_handle_t *p_hmac, uint32_t *p_message,
493                                         uint32_t number, uint32_t *p_digest);
494 
495 /** @} */
496 
497 /** @addtogroup HMAC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
498   * @brief    IRQ Handler and Callbacks functions
499  * @{
500  */
501 
502 /**
503  ****************************************************************************************
504  * @brief  Handle HMAC interrupt request.
505  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
506  *             for the specified HMAC module.
507  ****************************************************************************************
508  */
509 void hal_hmac_irq_handler(hmac_handle_t *p_hmac);
510 
511 /**
512  ****************************************************************************************
513  * @brief  Digest Done callback.
514  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
515  *             for the specified HMAC module.
516  ****************************************************************************************
517  */
518 void hal_hmac_done_callback(hmac_handle_t *p_hmac);
519 
520 /**
521  ****************************************************************************************
522  * @brief  HMAC error callback.
523  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
524  *             for the specified HMAC module.
525  ****************************************************************************************
526  */
527 void hal_hmac_error_callback(hmac_handle_t *p_hmac);
528 
529 /** @} */
530 
531 /** @defgroup HMAC_Exported_Functions_Group3 Peripheral State and Errors functions
532   * @brief   HMAC control functions
533   *
534 @verbatim
535  ===============================================================================
536                       ##### Peripheral State and Errors functions #####
537  ===============================================================================
538     [..]
539     This subsection provides a set of functions allowing to control the HMAC.
540      (+) hal_hmac_get_state() API can be helpful to check in run-time the state of the HMAC peripheral.
541      (+) hal_hmac_get_error() check in run-time Errors occurring during communication.
542      (+) hal_hmac_set_timeout() set the timeout during internal process.
543 @endverbatim
544   * @{
545   */
546 
547 /**
548  ****************************************************************************************
549  * @brief  Return the HMAC handle state.
550  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
551  *             for the specified HMAC module.
552  * @retval ::HAL_HMAC_STATE_RESET: Peripheral not initialized.
553  * @retval ::HAL_HMAC_STATE_READY: Peripheral initialized and ready for use.
554  * @retval ::HAL_HMAC_STATE_BUSY: Peripheral in indirect mode and busy.
555  * @retval ::HAL_HMAC_STATE_ERROR: Peripheral in error.
556  * @retval ::HAL_HMAC_STATE_TIMEOUT: Peripheral in timeout.
557  * @retval ::HAL_HMAC_STATE_SUSPENDED: Peripheral in suspended.
558  ****************************************************************************************
559  */
560 hal_hmac_state_t hal_hmac_get_state(hmac_handle_t *p_hmac);
561 
562 /**
563  ****************************************************************************************
564  * @brief  Return the HMAC error code.
565  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
566  *             for the specified HMAC module.
567  * @return HMAC error code in bitmap format
568  ****************************************************************************************
569  */
570 uint32_t hal_hmac_get_error(hmac_handle_t *p_hmac);
571 
572 /**
573  ****************************************************************************************
574  * @brief  Set the HMAC internal process timeout value.
575  * @param[in]  p_hmac: Pointer to a HMAC handle which contains the configuration information
576  *             for the specified HMAC module.
577  * @param[in]  timeout: Internal process timeout value.
578  ****************************************************************************************
579  */
580 void hal_hmac_set_timeout(hmac_handle_t *p_hmac, uint32_t timeout);
581 
582 
583 /**
584  ****************************************************************************************
585  * @brief  Suspend some registers related to HMAC configuration before sleep.
586  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration
587  *                 information for the specified HMAC module.
588  * @retval ::HAL_OK: Operation is OK.
589  * @retval ::HAL_ERROR: Parameter error or operation not supported.
590  * @retval ::HAL_BUSY: Driver is busy.
591  * @retval ::HAL_TIMEOUT: Timeout occurred.
592  ****************************************************************************************
593  */
594 hal_status_t hal_hmac_suspend_reg(hmac_handle_t *p_hmac);
595 
596 /**
597  ****************************************************************************************
598  * @brief  Restore some registers related to HMAC configuration after sleep.
599  *         This function must be used in conjunction with the hal_hmac_suspend_reg().
600  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration
601  *                 information for the specified HMAC module.
602  * @retval ::HAL_OK: Operation is OK.
603  * @retval ::HAL_ERROR: Parameter error or operation not supported.
604  * @retval ::HAL_BUSY: Driver is busy.
605  * @retval ::HAL_TIMEOUT: Timeout occurred.
606  ****************************************************************************************
607  */
608 hal_status_t hal_hmac_resume_reg(hmac_handle_t *p_hmac);
609 
610 /** @} */
611 
612 /** @} */
613 
614 #ifdef __cplusplus
615 }
616 #endif
617 
618 #endif /* __GR55xx_HAL_HMAC_H__ */
619 
620 /** @} */
621 
622 /** @} */
623 
624 /** @} */
625