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.
Diff: targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_hash_ex.c
- Revision:
- 613:bc40b8d2aec4
- Parent:
- 532:fe11edbda85c
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_hash_ex.c Tue Aug 18 15:00:09 2015 +0100 +++ b/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_hash_ex.c Thu Aug 20 10:45:13 2015 +0100 @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash_ex.c * @author MCD Application Team - * @version V1.3.0 - * @date 09-March-2015 + * @version V1.3.2 + * @date 26-June-2015 * @brief HASH HAL Extension module driver. * This file provides firmware functions to manage the following * functionalities of HASH peripheral: @@ -265,7 +265,7 @@ buffersize = hhash->Init.KeySize; } /* Configure the number of valid bits in last word of the message */ - HASH->STR |= 8 * (buffersize % 4); + MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8 * (buffersize % 4)); /* Set the HASH DMA transfer complete */ hhash->hdmain->XferCpltCallback = HASHEx_DMAXferCplt; @@ -926,14 +926,6 @@ /* Process Locked */ __HAL_LOCK(hhash); - if(hhash->HashITCounter == 0) - { - hhash->HashITCounter = 1; - } - else - { - hhash->HashITCounter = 0; - } if(hhash->State == HAL_HASH_STATE_READY) { /* Change the HASH state */ @@ -953,6 +945,9 @@ HASH->CR |= HASH_CR_INIT; } + /* Reset interrupt counter */ + hhash->HashITCounter = 0; + /* Set the phase */ hhash->Phase = HAL_HASH_PHASE_PROCESS; @@ -977,11 +972,17 @@ hhash->State = HAL_HASH_STATE_READY; /* Call digest computation complete callback */ HAL_HASH_DgstCpltCallback(hhash); + + /* Process Unlocked */ + __HAL_UNLOCK(hhash); + + /* Return function status */ + return HAL_OK; } } if(__HAL_HASH_GET_FLAG(HASH_FLAG_DINIS)) { - if(hhash->HashInCount > 64) + if(hhash->HashInCount >= 68) { inputaddr = (uint32_t)hhash->pHashInBuffPtr; /* Write the Input block in the Data IN register */ @@ -993,6 +994,7 @@ if(hhash->HashITCounter == 0) { HASH->DIN = *(uint32_t*)inputaddr; + if(hhash->HashInCount >= 68) { /* Decrement buffer counter */ @@ -1001,8 +1003,11 @@ } else { - hhash->HashInCount -= 64; + hhash->HashInCount = 0; + hhash->pHashInBuffPtr+= hhash->HashInCount; } + /* Set Interrupt counter */ + hhash->HashITCounter = 1; } else { @@ -1026,7 +1031,10 @@ { inputcounter = (inputcounter+4-inputcounter%4); } - + else if ((inputcounter < 4) && (inputcounter != 0)) + { + inputcounter = 4; + } /* Write the Input block in the Data IN register */ for(buffercounter = 0; buffercounter < inputcounter/4; buffercounter++) { @@ -1037,9 +1045,10 @@ __HAL_HASH_START_DIGEST(); /* Reset buffer counter */ hhash->HashInCount = 0; + + /* Call Input data transfer complete callback */ + HAL_HASH_InCpltCallback(hhash); } - /* Call Input data transfer complete callback */ - HAL_HASH_InCpltCallback(hhash); } /* Process Unlocked */ @@ -1070,14 +1079,6 @@ /* Process Locked */ __HAL_LOCK(hhash); - if(hhash->HashITCounter == 0) - { - hhash->HashITCounter = 1; - } - else - { - hhash->HashITCounter = 0; - } if(hhash->State == HAL_HASH_STATE_READY) { /* Change the HASH state */ @@ -1097,6 +1098,9 @@ HASH->CR |= HASH_CR_INIT; } + /* Reset interrupt counter */ + hhash->HashITCounter = 0; + /* Set the phase */ hhash->Phase = HAL_HASH_PHASE_PROCESS; @@ -1121,11 +1125,17 @@ hhash->State = HAL_HASH_STATE_READY; /* Call digest computation complete callback */ HAL_HASH_DgstCpltCallback(hhash); + + /* Process Unlocked */ + __HAL_UNLOCK(hhash); + + /* Return function status */ + return HAL_OK; } } if(__HAL_HASH_GET_FLAG(HASH_FLAG_DINIS)) { - if(hhash->HashInCount > 64) + if(hhash->HashInCount >= 68) { inputaddr = (uint32_t)hhash->pHashInBuffPtr; /* Write the Input block in the Data IN register */ @@ -1137,7 +1147,7 @@ if(hhash->HashITCounter == 0) { HASH->DIN = *(uint32_t*)inputaddr; - + if(hhash->HashInCount >= 68) { /* Decrement buffer counter */ @@ -1146,8 +1156,11 @@ } else { - hhash->HashInCount -= 64; + hhash->HashInCount = 0; + hhash->pHashInBuffPtr+= hhash->HashInCount; } + /* Set Interrupt counter */ + hhash->HashITCounter = 1; } else { @@ -1171,7 +1184,10 @@ { inputcounter = (inputcounter+4-inputcounter%4); } - + else if ((inputcounter < 4) && (inputcounter != 0)) + { + inputcounter = 4; + } /* Write the Input block in the Data IN register */ for(buffercounter = 0; buffercounter < inputcounter/4; buffercounter++) { @@ -1182,9 +1198,10 @@ __HAL_HASH_START_DIGEST(); /* Reset buffer counter */ hhash->HashInCount = 0; + + /* Call Input data transfer complete callback */ + HAL_HASH_InCpltCallback(hhash); } - /* Call Input data transfer complete callback */ - HAL_HASH_InCpltCallback(hhash); } /* Process Unlocked */ @@ -1206,11 +1223,11 @@ { case HASH_ALGOSELECTION_SHA224: - HAL_HASHEx_SHA224_Start_IT(hhash, HAL_NULL, 0, HAL_NULL); + HAL_HASHEx_SHA224_Start_IT(hhash, NULL, 0, NULL); break; case HASH_ALGOSELECTION_SHA256: - HAL_HASHEx_SHA256_Start_IT(hhash, HAL_NULL, 0, HAL_NULL); + HAL_HASHEx_SHA256_Start_IT(hhash, NULL, 0, NULL); break; default: