I am using MQX_V5 for IAR IDE. I am using MQX package provided example spi_master.
I am using our own development board. External Data flash is connected to SPI3.
I did following changes.
1. added definitions of pins in BOARD_InitPins(); of BSP. these are right, because same pins working with NXP bare metal examples.
2.Enable SPI in user_conifg.h
#define BSPCFG_ENABLE_LPSPI3 1
3. Still TEST_CHANNEL is not assigned by "spi3:" by following code snipped.
#elif BSP_SPI_MEMORY_CHANNEL == 3
#if ! BSPCFG_ENABLE_SPI3
#error This application requires BSPCFG_ENABLE_SPI3 defined non-zero in user_config.h. Please recompile kernel with this option.
#define TEST_CHANNEL "spi3:"
4. so, I added #define BSPCFG_ENABLE_SPI3 1 in user_conifg.h
Now, it is assigned "spi3:" to TEST_CHANNEL
3. but finally at following code, not opening port. Execution reach at task_block() line.
/* Open the SPI driver */
spifd = fopen (TEST_CHANNEL, NULL);
_io_printf("channel = %d",channel);
if (NULL == spifd)
printf ("Error opening SPI driver!\n");
Is there any settings required to Open SPI Port?
Thanks for your guidance.
I traced it. fopen is taking "spi3:". but in init.bsp.c file, there is following code.
IF_FEATURE_ENABLED( BSPCFG_ENABLE_LPSPI3, _io_spi_install("lpspi3:", &_bsp_spi3_init); )
here, driver name is "lpspi3:". So, SPI3 driver was not installed.
I changed #define TEST_CHANNEL "spi3:" to #define TEST_CHANNEL "lpspi3:"
Now, driver is installed and SPI is working. This issue is resolved.
Just for for my knowledge, can you please tell me
is this right way of modification? can we interchange SPI and LPSPI like this? is there difference between SPI and LPSPI drivers?
I would suggest you check the MCU reference manual. whether the spi3 is a low power spi ? if yes, and it is working, I think it is right.
The difference between spi and lpspi is , lpspi supports low power feature. and spi not.