fopen always return NULL (AN3905)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

fopen always return NULL (AN3905)

Jump to solution
844 Views
Seitec
Contributor III

Hi,

I would like to learn how to work with MQX. I am trying write basic example  "Writing your first application AN3905".

I have problem in the function InitializeIO(); fopen function always return NULL. It is doesn't make sense continue.

What are reasons (What can be) to return NULL in the function fopen?

const uint_32 output_set[] =

  {

  LED_1 | GPIO_PIN_STATUS_0,

  LED_2 | GPIO_PIN_STATUS_0,

  LED_3 | GPIO_PIN_STATUS_0,

  LED_4 | GPIO_PIN_STATUS_0,

  GPIO_LIST_END

  };

  output_port = fopen("gpio:write", (char_ptr) &output_set);

Thank you.

Ondra

0 Kudos
1 Solution
437 Views
Martin_
NXP Employee
NXP Employee

Hi Ondra,

MQX fopen() returns NULL when an I/O driver with the given name can't be found, means it has not been installed with MQX I/O subsystem. Typically this can happen when the driver is not enabled by the build time user configuration, user_config.h file for your BSP.

Are you trying to use this with MQX 4.0 ? The "gpio:write" driver is considered as legacy, it is kept in MQX 4.0 for backward compatibility. To enable it, user_config.h has to define:

#define BSPCFG_ENABLE_GPIODEV 1

and rebuild your BSP project.

There is lightweight version of gpio driver, called lwgpio, and MQX 4.0 has an example for it under

/mqx/examples/gpio/gpio.c

View solution in original post

0 Kudos
2 Replies
438 Views
Martin_
NXP Employee
NXP Employee

Hi Ondra,

MQX fopen() returns NULL when an I/O driver with the given name can't be found, means it has not been installed with MQX I/O subsystem. Typically this can happen when the driver is not enabled by the build time user configuration, user_config.h file for your BSP.

Are you trying to use this with MQX 4.0 ? The "gpio:write" driver is considered as legacy, it is kept in MQX 4.0 for backward compatibility. To enable it, user_config.h has to define:

#define BSPCFG_ENABLE_GPIODEV 1

and rebuild your BSP project.

There is lightweight version of gpio driver, called lwgpio, and MQX 4.0 has an example for it under

/mqx/examples/gpio/gpio.c

0 Kudos
437 Views
Seitec
Contributor III

Hi Martin,

Yes I am using MQX 4.0.

I have tried lwgpio and it works.

Thank you very much.

Ondra

0 Kudos