cancel
Showing results for 
Search instead for 
Did you mean: 

MFX_V3 How to use this module in stm32g474e eval board

10rajeshvr
Associate

Hi,

How to glow LED2 AND LED4 Which is connected through MFX_V3 in eval Board

any sample I2C format for that?

How to wakeup MFX_v3? 

 steps or sample code need to follow to glow Leds

please provide any examples or doc.

thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello @10rajeshvr and welcome to the community,

You can inspire from the BSP-LED example of STM32G474E-EVAL provided under this link:

https://github.com/STMicroelectronics/STM32CubeG4/blob/master/Projects/STM32G474E-EVAL/Examples/BSP/Src/led.c

int32_t Led_demo(void)
{
  int32_t  result = 0;

  printf("TEST OF LEDs\n");

  /* Initialize the LEDs */
  if (BSP_LED_Init(LED1) != BSP_ERROR_NONE) result--;
  if (BSP_LED_Init(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_Init(LED2) != BSP_ERROR_NONE) result--;
  if (BSP_LED_Init(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Switch on the LEDs */
  printf("Switch on LED1\n");
  if (BSP_LED_On(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch on LED3\n");
  if (BSP_LED_On(LED3) != BSP_ERROR_NONE) result--;

#if (USE_BSP_IO_CLASS == 1)
  printf("Switch on LED2\n");
  if (BSP_LED_On(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch on LED4\n");
  if (BSP_LED_On(LED4) != BSP_ERROR_NONE) result--;
#endif
  /* Check LEDs states */
  if (BSP_LED_GetState(LED1) != 1) result--;
  if (BSP_LED_GetState(LED3) != 1) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_GetState(LED2) != 1) result--;
  if (BSP_LED_GetState(LED4) != 1) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* Toggle the LEDs */
  printf("Switch off LED1\n");
  if (BSP_LED_Toggle(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch off LED3\n");
  if (BSP_LED_Toggle(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  printf("Switch off LED2\n");
  if (BSP_LED_Toggle(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch off LED4\n");
  if (BSP_LED_Toggle(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Check LEDs states */
  if (BSP_LED_GetState(LED1) != 0) result--;
  if (BSP_LED_GetState(LED3) != 0) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_GetState(LED2) != 0) result--;
  if (BSP_LED_GetState(LED4) != 0) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* Toggle the LEDs */
  printf("Switch on LED1\n");
  if (BSP_LED_Toggle(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch on LED3\n");
  if (BSP_LED_Toggle(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  printf("Switch on LED2\n");
  if (BSP_LED_Toggle(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch on LED4\n");
  if (BSP_LED_Toggle(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* Switch off the LEDs */
  printf("Switch off LED1\n");
  if (BSP_LED_Off(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch off LED3\n");
  if (BSP_LED_Off(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  printf("Switch off LED2\n");
  if (BSP_LED_Off(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch off LED4\n");
  if (BSP_LED_Off(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* De-Initialize the LEDs */
  if (BSP_LED_DeInit(LED1) != BSP_ERROR_NONE) result--;
  if (BSP_LED_DeInit(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_DeInit(LED2) != BSP_ERROR_NONE) result--;
  if (BSP_LED_DeInit(LED4) != BSP_ERROR_NONE) result--;
#endif

#if (USE_BSP_IO_CLASS == 1)
  /* Add a call of BSP_IO_DeInit for a clean exit of this test */
  if (BSP_IO_DeInit(0) != BSP_ERROR_NONE) result--;
#endif

  return result;
}

As you can see to use LED2 and LED4 you need to set the define USE_BSP_IO_CLASS to 1 in stm32g474e_eval_conf.h.

Also you need to define USE_IOEXPANDER in the Preprocessor in your IDE.

Hope it helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
SofLit
ST Employee

Hello @10rajeshvr and welcome to the community,

You can inspire from the BSP-LED example of STM32G474E-EVAL provided under this link:

https://github.com/STMicroelectronics/STM32CubeG4/blob/master/Projects/STM32G474E-EVAL/Examples/BSP/Src/led.c

int32_t Led_demo(void)
{
  int32_t  result = 0;

  printf("TEST OF LEDs\n");

  /* Initialize the LEDs */
  if (BSP_LED_Init(LED1) != BSP_ERROR_NONE) result--;
  if (BSP_LED_Init(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_Init(LED2) != BSP_ERROR_NONE) result--;
  if (BSP_LED_Init(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Switch on the LEDs */
  printf("Switch on LED1\n");
  if (BSP_LED_On(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch on LED3\n");
  if (BSP_LED_On(LED3) != BSP_ERROR_NONE) result--;

#if (USE_BSP_IO_CLASS == 1)
  printf("Switch on LED2\n");
  if (BSP_LED_On(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch on LED4\n");
  if (BSP_LED_On(LED4) != BSP_ERROR_NONE) result--;
#endif
  /* Check LEDs states */
  if (BSP_LED_GetState(LED1) != 1) result--;
  if (BSP_LED_GetState(LED3) != 1) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_GetState(LED2) != 1) result--;
  if (BSP_LED_GetState(LED4) != 1) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* Toggle the LEDs */
  printf("Switch off LED1\n");
  if (BSP_LED_Toggle(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch off LED3\n");
  if (BSP_LED_Toggle(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  printf("Switch off LED2\n");
  if (BSP_LED_Toggle(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch off LED4\n");
  if (BSP_LED_Toggle(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Check LEDs states */
  if (BSP_LED_GetState(LED1) != 0) result--;
  if (BSP_LED_GetState(LED3) != 0) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_GetState(LED2) != 0) result--;
  if (BSP_LED_GetState(LED4) != 0) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* Toggle the LEDs */
  printf("Switch on LED1\n");
  if (BSP_LED_Toggle(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch on LED3\n");
  if (BSP_LED_Toggle(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  printf("Switch on LED2\n");
  if (BSP_LED_Toggle(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch on LED4\n");
  if (BSP_LED_Toggle(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* Switch off the LEDs */
  printf("Switch off LED1\n");
  if (BSP_LED_Off(LED1) != BSP_ERROR_NONE) result--;
  printf("Switch off LED3\n");
  if (BSP_LED_Off(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  printf("Switch off LED2\n");
  if (BSP_LED_Off(LED2) != BSP_ERROR_NONE) result--;
  printf("Switch off LED4\n");
  if (BSP_LED_Off(LED4) != BSP_ERROR_NONE) result--;
#endif

  /* Check result */
  if (CheckResult() != 0U) result--;

  /* De-Initialize the LEDs */
  if (BSP_LED_DeInit(LED1) != BSP_ERROR_NONE) result--;
  if (BSP_LED_DeInit(LED3) != BSP_ERROR_NONE) result--;
#if (USE_BSP_IO_CLASS == 1)
  if (BSP_LED_DeInit(LED2) != BSP_ERROR_NONE) result--;
  if (BSP_LED_DeInit(LED4) != BSP_ERROR_NONE) result--;
#endif

#if (USE_BSP_IO_CLASS == 1)
  /* Add a call of BSP_IO_DeInit for a clean exit of this test */
  if (BSP_IO_DeInit(0) != BSP_ERROR_NONE) result--;
#endif

  return result;
}

As you can see to use LED2 and LED4 you need to set the define USE_BSP_IO_CLASS to 1 in stm32g474e_eval_conf.h.

Also you need to define USE_IOEXPANDER in the Preprocessor in your IDE.

Hope it helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
10rajeshvr
Associate

Hi ,

I have downloaded the example projects for stm32g474 eval board 

,I am unable to find in examples, Project load files for stmcubeide 

but for ,keil ,ewarm iproject load file is there.

,Then what steps  to follow inorder to  run Examples based on STMCUBEIDE, 

 


@10rajeshvr wrote:

Hi ,

I have downloaded the example projects for stm32g474 eval board 

,I am unable to find in examples, Project load files for stmcubeide 

but for ,keil ,ewarm iproject load file is there.

,Then what steps  to follow inorder to  run Examples based on STMCUBEIDE, 

 


Hello,

This is a new question, please post it a new thread.

Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.