Overview of HAL drivers
The following example shows how to use the timeout inside the polling functions:
HAL_PPP_StateTypeDef HAL_PPP_Poll (PPP_HandleTypeDef *hppp, uint32_t Timeout)
{
(...)
timeout = HAL_GetTick() + Timeout;
(...)
while(ProcessOngoing)
{
(...)
if(Timeout != HAL_MAX_DELAY)
{
if(HAL_GetTick() >= timeout)
{
/* Process unlocked */
__HAL_UNLOCK(hppp);
hppp->State= HAL_PPP_STATE_TIMEOUT;
return hppp->State;
}
}
(...)
}
2.12.4.2
Error management
The HAL drivers implement a check on the following items:
Valid parameters: for some process the used parameters should be valid and already
defined, otherwise the system may crash or go into an undefined state. These critical
parameters are checked before being used (see example below).
HAL_StatusTypeDef HAL_PPP_Process(PPP_HandleTypeDef* hppp, uint32_t *pdata, uint32
Size)
{
if ((pData == NULL ) || (Size == 0))
{ return HAL_ERROR;
}
}
Valid handle: the PPP peripheral handle is the most important argument since it keeps
the PPP driver vital parameters. It is always checked in the beginning of the
HAL_PPP_Init() function.
HAL_StatusTypeDef HAL_PPP_Init(PPP_HandleTypeDef* hppp
{
if (hppp == NULL) //the handle should be already allocated { return HAL_ERROR;
}
}
Timeout error: the following statement is used when a timeout error occurs:
{
timeout = HAL_GetTick() + Timeout; while (data processing is running)
{
if(timeout)
{ return HAL_TIMEOUT;
}
}
When an error occurs during a peripheral process, HAL_PPP_Process () returns with a
HAL_ERROR status. The HAL PPP driver implements the HAL_PPP_GetError () to allow
retrieving the origin of the error.
HAL_PPP_ErrorTypeDef HAL_PPP_GetError (PPP_HandleTypeDef *hppp);
58/1371
DocID028236 Rev 2
UM1940
Need help?
Do you have a question about the STM32F2 and is the answer not in the manual?
Questions and answers