RTEMS 6.1-rc2
|
OTFDEC HAL module driver. This file provides firmware functions to manage the following functionalities of the On-The-Fly Decryption (OTFDEC) peripheral: More...
#include "stm32h7xx_hal.h"
OTFDEC HAL module driver. This file provides firmware functions to manage the following functionalities of the On-The-Fly Decryption (OTFDEC) peripheral:
Copyright (c) 2018 STMicroelectronics. All rights reserved.
This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.
============================================================================== ##### How to use this driver ##### ============================================================================== [..] The OTFDEC HAL driver can be used as follows: (#) Declare an OTFDEC_HandleTypeDef handle structure (eg. OTFDEC_HandleTypeDef hotfdec). (#) Initialize the OTFDEC low level resources by implementing the HAL_OTFDEC_MspInit() API: (++) Enable the OTFDEC interface clock. (++) NVIC configuration if interrupts are used (+++) Configure the OTFDEC interrupt priority. (+++) Enable the NVIC OTFDEC IRQ handle. (#) Initialize the OTFDEC peripheral by calling the HAL_OTFDEC_Init() API. (#) For each region, (++) Configure the region deciphering mode by calling the HAL_OTFDEC_RegionSetMode() API. (++) Write the region Key by calling the HAL_OTFDEC_RegionSetKey() API. If desired, read the key CRC by calling HAL_OTFDEC_RegionGetKeyCRC() API and compare the result with the theoretically expected CRC. (++) Initialize the OTFDEC region config structure with the Nonce, protected region start and end addresses and firmware version, and wrap-up the region configuration by calling HAL_OTFDEC_RegionConfig() API. (#) At this point, the OTFDEC region configuration is done and the deciphering is enabled. The region can be deciphered on the fly after having made sure the OctoSPI is configured in memory-mapped mode. [..] (@) Warning: the OTFDEC deciphering is based on a different endianness compared to the AES-CTR as implemented in the AES peripheral. E.g., if the OTFEC resorts to the Key (B0, B1, B2, B3) where Bi are 32-bit longwords and B0 is the Least Significant Word, the AES has to be configured with the Key (B3, B2, B1, B0) to report the same result (with the same swapping applied to the Initialization Vector). [..] *** Callback registration *** ============================================= [..] The compilation flag USE_HAL_OTFDEC_REGISTER_CALLBACKS, when set to 1, allows the user to configure dynamically the driver callbacks. Use Functions HAL_OTFDEC_RegisterCallback() to register an interrupt callback. [..] Function HAL_OTFDEC_RegisterCallback() allows to register following callbacks: (+) ErrorCallback : OTFDEC error callback (+) MspInitCallback : OTFDEC Msp Init callback (+) MspDeInitCallback : OTFDEC Msp DeInit callback This function takes as parameters the HAL peripheral handle, the Callback ID and a pointer to the user callback function. [..] Use function HAL_OTFDEC_UnRegisterCallback to reset a callback to the default weak function. [..] HAL_OTFDEC_UnRegisterCallback takes as parameters the HAL peripheral handle, and the Callback ID. This function allows to reset following callbacks: (+) ErrorCallback : OTFDEC error callback (+) MspInitCallback : OTFDEC Msp Init callback (+) MspDeInitCallback : OTFDEC Msp DeInit callback [..] By default, after the HAL_OTFDEC_Init() and when the state is HAL_OTFDEC_STATE_RESET all callbacks are set to the corresponding weak functions: example HAL_OTFDEC_ErrorCallback(). Exception done for MspInit and MspDeInit functions that are reset to the legacy weak functions in the HAL_OTFDEC_Init()HAL_OTFDEC_DeInit() only when these callbacks are null (not registered beforehand). [..] If MspInit or MspDeInit are not null, the HAL_OTFDEC_Init()/HAL_OTFDEC_DeInit() keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. [..] Callbacks can be registered/unregistered in HAL_OTFDEC_STATE_READY state only. Exception done MspInit/MspDeInit functions that can be registered/unregistered in HAL_OTFDEC_STATE_READY or HAL_OTFDEC_STATE_RESET state, thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. [..] Then, the user first registers the MspInit/MspDeInit user callbacks using HAL_OTFDEC_RegisterCallback() before calling HAL_OTFDEC_DeInit() or HAL_OTFDEC_Init() function. [..] When the compilation flag USE_HAL_OTFDEC_REGISTER_CALLBACKS is set to 0 or not defined, the callback registration feature is not available and all callbacks are set to the corresponding weak functions.