mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Oct 31 11:00:10 2014 +0000
Revision:
376:cb4d9db17537
Synchronized with git revision 07b49da75eac883fc8916d3d6b6962664b8db29e

Full URL: https://github.com/mbedmicro/mbed/commit/07b49da75eac883fc8916d3d6b6962664b8db29e/

Targets: DISCO_L053C8 - new platform - STM32L0 Discovery board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 376:cb4d9db17537 1 /**
mbed_official 376:cb4d9db17537 2 ******************************************************************************
mbed_official 376:cb4d9db17537 3 * @file stm32l0xx_hal_cryp_ex.c
mbed_official 376:cb4d9db17537 4 * @author MCD Application Team
mbed_official 376:cb4d9db17537 5 * @version V1.1.0
mbed_official 376:cb4d9db17537 6 * @date 18-June-2014
mbed_official 376:cb4d9db17537 7 * @brief CRYPEx HAL module driver.
mbed_official 376:cb4d9db17537 8 *
mbed_official 376:cb4d9db17537 9 * This file provides firmware functions to manage the following
mbed_official 376:cb4d9db17537 10 * functionalities of the Cryptography (CRYP) extension peripheral:
mbed_official 376:cb4d9db17537 11 * + Computation completed callback.
mbed_official 376:cb4d9db17537 12 *
mbed_official 376:cb4d9db17537 13 @verbatim
mbed_official 376:cb4d9db17537 14 ==============================================================================
mbed_official 376:cb4d9db17537 15 ##### How to use this driver #####
mbed_official 376:cb4d9db17537 16 ==============================================================================
mbed_official 376:cb4d9db17537 17 [..]
mbed_official 376:cb4d9db17537 18 The CRYP HAL driver can be used as follows:
mbed_official 376:cb4d9db17537 19
mbed_official 376:cb4d9db17537 20 (#)Initialize the CRYP low level resources by implementing the HAL_CRYP_MspInit():
mbed_official 376:cb4d9db17537 21 (##) Enable the CRYP interface clock using __CRYP_CLK_ENABLE()
mbed_official 376:cb4d9db17537 22 (##) In case of using interrupts (e.g. HAL_AES_ECB_Encrypt_IT())
mbed_official 376:cb4d9db17537 23 (+) Configure the CRYP interrupt priority using HAL_NVIC_SetPriority()
mbed_official 376:cb4d9db17537 24 (+) Enable the CRYP IRQ handler using HAL_NVIC_EnableIRQ()
mbed_official 376:cb4d9db17537 25 (+) In CRYP IRQ handler, call HAL_CRYP_IRQHandler()
mbed_official 376:cb4d9db17537 26 (##) In case of using DMA to control data transfer (e.g. HAL_AES_ECB_Encrypt_DMA())
mbed_official 376:cb4d9db17537 27 (+) Enable the DMA1 interface clock using
mbed_official 376:cb4d9db17537 28 (++) __DMA1_CLK_ENABLE()
mbed_official 376:cb4d9db17537 29 (+) Configure and enable two DMA Channels one for managing data transfer from
mbed_official 376:cb4d9db17537 30 memory to peripheral (input channel) and another channel for managing data
mbed_official 376:cb4d9db17537 31 transfer from peripheral to memory (output channel)
mbed_official 376:cb4d9db17537 32 (+) Associate the initilalized DMA handle to the CRYP DMA handle
mbed_official 376:cb4d9db17537 33 using __HAL_LINKDMA()
mbed_official 376:cb4d9db17537 34 (+) Configure the priority and enable the NVIC for the transfer complete
mbed_official 376:cb4d9db17537 35 interrupt on the two DMA Streams. The output stream should have higher
mbed_official 376:cb4d9db17537 36 priority than the input stream.
mbed_official 376:cb4d9db17537 37 (++) HAL_NVIC_SetPriority()
mbed_official 376:cb4d9db17537 38 (++) HAL_NVIC_EnableIRQ()
mbed_official 376:cb4d9db17537 39
mbed_official 376:cb4d9db17537 40 (#)Initialize the CRYP HAL using HAL_CRYP_Init(). This function configures mainly:
mbed_official 376:cb4d9db17537 41 (##) The data type: 1-bit, 8-bit, 16-bit and 32-bit
mbed_official 376:cb4d9db17537 42 (##) The encryption/decryption key.
mbed_official 376:cb4d9db17537 43 (##) The initialization vector (counter). It is not used ECB mode.
mbed_official 376:cb4d9db17537 44
mbed_official 376:cb4d9db17537 45 (#)Three processing (encryption/decryption) functions are available:
mbed_official 376:cb4d9db17537 46 (##) Polling mode: encryption and decryption APIs are blocking functions
mbed_official 376:cb4d9db17537 47 i.e. they process the data and wait till the processing is finished
mbed_official 376:cb4d9db17537 48 e.g. HAL_CRYP_AESCBC_Encrypt()
mbed_official 376:cb4d9db17537 49 (##) Interrupt mode: encryption and decryption APIs are not blocking functions
mbed_official 376:cb4d9db17537 50 i.e. they process the data under interrupt
mbed_official 376:cb4d9db17537 51 e.g. HAL_CRYP_AESCBC_Encrypt_IT()
mbed_official 376:cb4d9db17537 52 (##) DMA mode: encryption and decryption APIs are not blocking functions
mbed_official 376:cb4d9db17537 53 i.e. the data transfer is ensured by DMA
mbed_official 376:cb4d9db17537 54 e.g. HAL_CRYP_AESCBC_Encrypt_DMA()
mbed_official 376:cb4d9db17537 55
mbed_official 376:cb4d9db17537 56 (#)When the processing function is called at first time after HAL_CRYP_Init()
mbed_official 376:cb4d9db17537 57 the CRYP peripheral is initialized and processes the buffer in input.
mbed_official 376:cb4d9db17537 58 At second call, the processing function performs an append of the already
mbed_official 376:cb4d9db17537 59 processed buffer.
mbed_official 376:cb4d9db17537 60 When a new data block is to be processed, call HAL_CRYP_Init() then the
mbed_official 376:cb4d9db17537 61 processing function.
mbed_official 376:cb4d9db17537 62
mbed_official 376:cb4d9db17537 63 (#)Call HAL_CRYP_DeInit() to deinitialize the CRYP peripheral.
mbed_official 376:cb4d9db17537 64
mbed_official 376:cb4d9db17537 65 @endverbatim
mbed_official 376:cb4d9db17537 66 ******************************************************************************
mbed_official 376:cb4d9db17537 67 * @attention
mbed_official 376:cb4d9db17537 68 *
mbed_official 376:cb4d9db17537 69 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 376:cb4d9db17537 70 *
mbed_official 376:cb4d9db17537 71 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 376:cb4d9db17537 72 * are permitted provided that the following conditions are met:
mbed_official 376:cb4d9db17537 73 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 376:cb4d9db17537 74 * this list of conditions and the following disclaimer.
mbed_official 376:cb4d9db17537 75 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 376:cb4d9db17537 76 * this list of conditions and the following disclaimer in the documentation
mbed_official 376:cb4d9db17537 77 * and/or other materials provided with the distribution.
mbed_official 376:cb4d9db17537 78 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 376:cb4d9db17537 79 * may be used to endorse or promote products derived from this software
mbed_official 376:cb4d9db17537 80 * without specific prior written permission.
mbed_official 376:cb4d9db17537 81 *
mbed_official 376:cb4d9db17537 82 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 376:cb4d9db17537 83 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 376:cb4d9db17537 84 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 376:cb4d9db17537 85 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 376:cb4d9db17537 86 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 376:cb4d9db17537 87 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 376:cb4d9db17537 88 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 376:cb4d9db17537 89 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 376:cb4d9db17537 90 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 376:cb4d9db17537 91 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 376:cb4d9db17537 92 *
mbed_official 376:cb4d9db17537 93 ******************************************************************************
mbed_official 376:cb4d9db17537 94 */
mbed_official 376:cb4d9db17537 95
mbed_official 376:cb4d9db17537 96 /* Includes ------------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 97 #include "stm32l0xx_hal.h"
mbed_official 376:cb4d9db17537 98
mbed_official 376:cb4d9db17537 99 /** @addtogroup STM32L0xx_HAL_Driver
mbed_official 376:cb4d9db17537 100 * @{
mbed_official 376:cb4d9db17537 101 */
mbed_official 376:cb4d9db17537 102
mbed_official 376:cb4d9db17537 103 /** @defgroup CRYPEx
mbed_official 376:cb4d9db17537 104 * @brief CRYP HAL Extended module driver.
mbed_official 376:cb4d9db17537 105 * @{
mbed_official 376:cb4d9db17537 106 */
mbed_official 376:cb4d9db17537 107
mbed_official 376:cb4d9db17537 108 #ifdef HAL_CRYP_MODULE_ENABLED
mbed_official 376:cb4d9db17537 109 #if !defined (STM32L051xx) && !defined (STM32L052xx) && !defined (STM32L053xx)
mbed_official 376:cb4d9db17537 110
mbed_official 376:cb4d9db17537 111 /* Private typedef -----------------------------------------------------------*/
mbed_official 376:cb4d9db17537 112 /* Private define ------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 113 /* Private macro -------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 114 /* Private variables ---------------------------------------------------------*/
mbed_official 376:cb4d9db17537 115 /* Private function prototypes -----------------------------------------------*/
mbed_official 376:cb4d9db17537 116 /* Private functions ---------------------------------------------------------*/
mbed_official 376:cb4d9db17537 117
mbed_official 376:cb4d9db17537 118 /** @defgroup CRYPEx_Private_Functions
mbed_official 376:cb4d9db17537 119 * @{
mbed_official 376:cb4d9db17537 120 */
mbed_official 376:cb4d9db17537 121
mbed_official 376:cb4d9db17537 122
mbed_official 376:cb4d9db17537 123 /** @defgroup CRYPEX_Group1 Extended features functions
mbed_official 376:cb4d9db17537 124 * @brief Extended features functions.
mbed_official 376:cb4d9db17537 125 *
mbed_official 376:cb4d9db17537 126 @verbatim
mbed_official 376:cb4d9db17537 127 ===============================================================================
mbed_official 376:cb4d9db17537 128 ##### Extended features functions #####
mbed_official 376:cb4d9db17537 129 ===============================================================================
mbed_official 376:cb4d9db17537 130 [..] This section provides callback functions:
mbed_official 376:cb4d9db17537 131 (+) Computation completed.
mbed_official 376:cb4d9db17537 132
mbed_official 376:cb4d9db17537 133 @endverbatim
mbed_official 376:cb4d9db17537 134 * @{
mbed_official 376:cb4d9db17537 135 */
mbed_official 376:cb4d9db17537 136
mbed_official 376:cb4d9db17537 137 /**
mbed_official 376:cb4d9db17537 138 * @brief Computation completed callbacks.
mbed_official 376:cb4d9db17537 139 * @param hcryp: pointer to a CRYP_HandleTypeDef structure that contains
mbed_official 376:cb4d9db17537 140 * the configuration information for CRYP module
mbed_official 376:cb4d9db17537 141 * @retval None
mbed_official 376:cb4d9db17537 142 */
mbed_official 376:cb4d9db17537 143 __weak void HAL_CRYPEx_ComputationCpltCallback(CRYP_HandleTypeDef *hcryp)
mbed_official 376:cb4d9db17537 144 {
mbed_official 376:cb4d9db17537 145 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 376:cb4d9db17537 146 the HAL_CRYP_ComputationCpltCallback could be implemented in the user file
mbed_official 376:cb4d9db17537 147 */
mbed_official 376:cb4d9db17537 148 }
mbed_official 376:cb4d9db17537 149
mbed_official 376:cb4d9db17537 150 /**
mbed_official 376:cb4d9db17537 151 * @}
mbed_official 376:cb4d9db17537 152 */
mbed_official 376:cb4d9db17537 153
mbed_official 376:cb4d9db17537 154
mbed_official 376:cb4d9db17537 155 /**
mbed_official 376:cb4d9db17537 156 * @}
mbed_official 376:cb4d9db17537 157 */
mbed_official 376:cb4d9db17537 158 #endif /* STM32L051xx && STM32L052xx && STM32L053xx*/
mbed_official 376:cb4d9db17537 159 #endif /* HAL_CRYP_MODULE_ENABLED */
mbed_official 376:cb4d9db17537 160 /**
mbed_official 376:cb4d9db17537 161 * @}
mbed_official 376:cb4d9db17537 162 */
mbed_official 376:cb4d9db17537 163
mbed_official 376:cb4d9db17537 164 /**
mbed_official 376:cb4d9db17537 165 * @}
mbed_official 376:cb4d9db17537 166 */
mbed_official 376:cb4d9db17537 167
mbed_official 376:cb4d9db17537 168 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/