Peripheral State functions.
More...
Peripheral State functions.
===============================================================================
##### Peripheral State methods #####
===============================================================================
[..]
This section permits to get in run-time the state and the peripheral handle
status of the peripheral:
(+) HAL_HASH_GetState()
(+) HAL_HASH_GetStatus()
[..]
Additionally, this subsection provides functions allowing to save and restore
the HASH or HMAC processing context in case of calculation suspension:
(+) HAL_HASH_ContextSaving()
(+) HAL_HASH_ContextRestoring()
[..]
This subsection provides functions allowing to suspend the HASH processing
(+) when input are fed to the Peripheral by software
(++) HAL_HASH_SwFeed_ProcessSuspend()
(+) when input are fed to the Peripheral by DMA
(++) HAL_HASH_DMAFeed_ProcessSuspend()
◆ HAL_HASH_ContextRestoring()
Restore the HASH context in case of processing resumption.
- Parameters
-
| hhash | HASH handle. |
| pMemBuffer | pointer to the memory buffer where the HASH context is stored. |
- Note
- The IMR, STR, CR then all the CSR registers are restored in that order. Only the r/w bits are restored.
-
By default, all the context swap registers (HASH_NUMBER_OF_CSR_REGISTERS of those) are restored (all of them have been saved by default beforehand).
- Return values
-
Definition at line 1359 of file stm32l4xx_hal_hash.c.
1361 uint32_t mem_ptr = (uint32_t)pMemBuffer;
1362 uint32_t csr_ptr = (uint32_t)HASH->CSR;
1369 WRITE_REG(HASH->IMR, (*(uint32_t*)(mem_ptr)));
1372 WRITE_REG(HASH->STR, (*(uint32_t*)(mem_ptr)));
1375 WRITE_REG(HASH->CR, (*(uint32_t*)(mem_ptr)));
1383 for (i = HASH_NUMBER_OF_CSR_REGISTERS; i >0U; i--)
1385 WRITE_REG((*(uint32_t*)(csr_ptr)), (*(uint32_t*)(mem_ptr)));
◆ HAL_HASH_ContextSaving()
Save the HASH context in case of processing suspension.
- Parameters
-
| hhash | HASH handle. |
| pMemBuffer | pointer to the memory buffer where the HASH context is saved. |
- Note
- The IMR, STR, CR then all the CSR registers are saved in that order. Only the r/w bits are read to be restored later on.
-
By default, all the context swap registers (there are HASH_NUMBER_OF_CSR_REGISTERS of those) are saved.
-
pMemBuffer points to a buffer allocated by the user. The buffer size must be at least (HASH_NUMBER_OF_CSR_REGISTERS + 3) * 4 uint8 long.
- Return values
-
Definition at line 1319 of file stm32l4xx_hal_hash.c.
1321 uint32_t mem_ptr = (uint32_t)pMemBuffer;
1322 uint32_t csr_ptr = (uint32_t)HASH->CSR;
1329 *(uint32_t*)(mem_ptr) = READ_BIT(HASH->IMR,HASH_IT_DINI|HASH_IT_DCI);
1332 *(uint32_t*)(mem_ptr) = READ_BIT(HASH->STR,HASH_STR_NBLW);
1335 *(uint32_t*)(mem_ptr) = READ_BIT(HASH->CR,HASH_CR_DMAE|HASH_CR_DATATYPE|HASH_CR_MODE|HASH_CR_ALGO|HASH_CR_LKEY|HASH_CR_MDMAT);
1338 for (i = HASH_NUMBER_OF_CSR_REGISTERS; i >0U; i--)
1340 *(uint32_t*)(mem_ptr) = *(uint32_t*)(csr_ptr);
◆ HAL_HASH_DMAFeed_ProcessSuspend()
Suspend the HASH processing when in DMA mode.
- Parameters
-
- Note
- When suspension attempt occurs at the very end of a DMA transfer and all the data have already been entered in the Peripheral, hhash->State is set to HAL_HASH_STATE_READY and the API returns HAL_ERROR. It is recommended to wrap-up the processing in reading the digest as usual.
- Return values
-
Definition at line 1417 of file stm32l4xx_hal_hash.c.
1419 uint32_t tmp_remaining_DMATransferSize_inWords;
1420 uint32_t tmp_initial_DMATransferSize_inWords;
1421 uint32_t tmp_words_already_pushed;
1431 tmp_remaining_DMATransferSize_inWords = ((DMA_Channel_TypeDef *)hhash->hdmain->Instance)->CNDTR;
1433 if (tmp_remaining_DMATransferSize_inWords <= HASH_DMA_SUSPENSION_WORDS_LIMIT)
1446 if (__HAL_HASH_GET_FLAG(HASH_FLAG_DCIS) != RESET)
1477 if (__HAL_HASH_GET_FLAG(HASH_FLAG_DCIS) != RESET)
1484 tmp_remaining_DMATransferSize_inWords = ((DMA_Channel_TypeDef *)hhash->hdmain->Instance)->CNDTR;
1486 if (tmp_remaining_DMATransferSize_inWords == 0U)
1503 tmp_initial_DMATransferSize_inWords = (((hhash->HashInCount%4U)!=0U) ? ((hhash->HashInCount+3U)/4U): (hhash->HashInCount/4U));
1509 tmp_words_already_pushed = hhash->NbWordsAlreadyPushed;
1510 if (((tmp_words_already_pushed + tmp_initial_DMATransferSize_inWords - tmp_remaining_DMATransferSize_inWords) %16U) != HASH_NBW_PUSHED())
1512 tmp_remaining_DMATransferSize_inWords--;
1516 hhash->pHashInBuffPtr += 4U * (tmp_initial_DMATransferSize_inWords - tmp_remaining_DMATransferSize_inWords) ;
1519 hhash->HashInCount = 4U * tmp_remaining_DMATransferSize_inWords;
static HAL_StatusTypeDef HASH_WaitOnFlagUntilTimeout(HASH_HandleTypeDef *hhash, uint32_t Flag, FlagStatus Status, uint32_t Timeout)
Handle HASH processing Timeout.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
◆ HAL_HASH_GetError()
Return the HASH handle error code.
- Parameters
-
| hhash | pointer to a HASH_HandleTypeDef structure. |
- Return values
-
Definition at line 1536 of file stm32l4xx_hal_hash.c.
1539 return hhash->ErrorCode;
◆ HAL_HASH_GetState()
Return the HASH handle state.
- Note
- The API yields the current state of the handle (BUSY, READY,...).
- Parameters
-
- Return values
-
Definition at line 1288 of file stm32l4xx_hal_hash.c.
1290 return hhash->State;
◆ HAL_HASH_GetStatus()
Return the HASH HAL status.
- Note
- The API yields the HAL status of the handle: it is the result of the latest HASH processing and allows to report any issue (e.g. HAL_TIMEOUT).
- Parameters
-
- Return values
-
Definition at line 1301 of file stm32l4xx_hal_hash.c.
1303 return hhash->Status;
◆ HAL_HASH_SwFeed_ProcessSuspend()
Initiate HASH processing suspension when in polling or interruption mode.
- Parameters
-
- Note
- Set the handle field SuspendRequest to the appropriate value so that the on-going HASH processing is suspended as soon as the required conditions are met. Note that the actual suspension is carried out by the functions HASH_WriteData() in polling mode and HASH_IT() in interruption mode.
- Return values
-
Definition at line 1402 of file stm32l4xx_hal_hash.c.