cancel
Showing results for 
Search instead for 
Did you mean: 

how i can recover the state of HAL_Init () with stm32f4

sam123
Associate II

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 ;

   

9 REPLIES 9

Sorry, what's the question?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sam123
Associate II

i want recover the state of HAL_init i mean if HAL_Init () return ok or error i want recover this resulte

Rogers.Gary
Senior II

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!

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..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Rogers.Gary
Senior II

Funny. Or the morgue bringing you an ambulance.

sam123
Associate II

i want use the instruction printf

i mea, declare variable state

and state print the state of HAL_Init ()

Rogers.Gary
Senior II

printf("Result if unit = %i\n", HAL_Init( ) );

It will return one of the 3 enumerate values, yes?

sam123
Associate II

yes

sam123
Associate II

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 ;

}