2019-03-21 07:36 AM
HAL_StatusTypeDef HAL_Init( void )
{ HAL_StatusTypeDef statue;
/* Configure Instruction cache through ART accelerator */
#if (ART_ACCLERATOR_ENABLE != 0)
__HAL_FLASH_ART_ENABLE();
#endif /* ART_ACCLERATOR_ENABLE */
/* Configure Flash prefetch */
#if (PREFETCH_ENABLE != 0U)
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */
/* Set Interrupt Group Priority */
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
HAL_InitTick(TICK_INT_PRIORITY);
/* Init the low level hardware */
HAL_MspInit();
/* recuperer function status */
return HAL_OK ;
2019-03-21 10:01 AM
Sorry, what's the question?
2019-03-21 11:50 AM
i want recover the state of HAL_init i mean if HAL_Init () return ok or error i want recover this resulte
2019-03-21 01:56 PM
I understand your question.
That HAL function returns a "HAL_StatusTypeDef ", so you can call it like this:
if ( HAL_Init( void ) != HAL_OK )
{
/* HAL INIT Error */
Error_Handler();
}
Here is the types that you can use, from the header file stm32f4xx_hal.h:
typedef enum
{
HAL_OK = 0x00,
HAL_ERROR = 0x01,
HAL_BUSY = 0x02,
HAL_TIMEOUT = 0x03
} HAL_StatusTypeDef;
Hope that helps!
2019-03-21 02:41 PM
Ok, so that made me chuckle a bit.
For the most part Error_Handler() is where it rolls over and dies, rather than recovers. Like an Ambulance taking you to the morgue..
2019-03-21 04:23 PM
Funny. Or the morgue bringing you an ambulance.
2019-03-22 02:30 AM
i want use the instruction printf
i mea, declare variable state
and state print the state of HAL_Init ()
2019-03-22 12:12 PM
printf("Result if unit = %i\n", HAL_Init( ) );
It will return one of the 3 enumerate values, yes?
2019-03-22 01:21 PM
yes
2019-03-22 01:25 PM
main .c
int main(void)
{
/* Configure the MPU attributes as Device memory for ETH DMA descriptors */
MPU_Config();
/* Enable the CPU Cache */
CPU_CACHE_Enable();
/* STM32F7xx HAL library initialization:
- Configure the Flash ART accelerator on ITCM interface
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init () ;
stm32f7xx_hal.c :
HAL_StatusTypeDef HAL_Init( void )
{
/* Configure Instruction cache through ART accelerator */
#if (ART_ACCLERATOR_ENABLE != 0)
__HAL_FLASH_ART_ENABLE();
#endif /* ART_ACCLERATOR_ENABLE */
/* Configure Flash prefetch */
#if (PREFETCH_ENABLE != 0U)
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */
/* Set Interrupt Group Priority */
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
HAL_InitTick(TICK_INT_PRIORITY);
/* Init the low level hardware */
HAL_MspInit();
/* recuperer function status */
return HAL_OK ;
}