Ok, but why ? Do you try to step in into the fopen() function with the debugger to see, which code line causes this ? Can you show call stack ? Did you recompile the BSP and PSP projects, then the application ?
Hi Martin,
I tried rebuilding the bsp and psp libraries, and then the SPI applications, but no joy.
Here's some code inside io_fopen. dev_ptr is set to (pointer)&kernel_data->IO_DEVICES.NEXT, and then presumably IO_DEVICES.NEXT is supposed to change when _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->IO_LWSEM) is called, but it doesn't, so io_fopen returns null.
_lwsem_wait((LWSEM_STRUCT_PTR)&kernel_data->IO_LWSEM);
dev_ptr = (IO_DEVICE_STRUCT_PTR)((pointer)kernel_data->IO_DEVICES.NEXT);
while (dev_ptr != (pointer)&kernel_data->IO_DEVICES.NEXT) {
dev_name_ptr = dev_ptr->IDENTIFIER;
tmp_ptr = (char _PTR_)open_type_ptr;
while (*tmp_ptr && *dev_name_ptr &&
(*tmp_ptr == *dev_name_ptr))
{
++tmp_ptr;
++dev_name_ptr;
} /* Endwhile */
if (*dev_name_ptr == '\0') {
/* Match */
break;
} /* Endif */
dev_ptr = (IO_DEVICE_STRUCT_PTR)((pointer)dev_ptr->QUEUE_ELEMENT.NEXT);
} /* Endwhile */
_lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->IO_LWSEM);
if (dev_ptr == (pointer)&kernel_data->IO_DEVICES.NEXT) {
return(NULL);
} /* Endif */
Inside lwsem, there's some code that would change IO_DEVICES.NEXT, but the if statement isn't true, so that code there doesn't execute.
if ((sem_ptr->VALUE >= 0) && (_QUEUE_GET_SIZE(&sem_ptr->TD_QUEUE)))
{
_QUEUE_DEQUEUE(&sem_ptr->TD_QUEUE, td_ptr);
_BACKUP_POINTER(td_ptr, TD_STRUCT, AUX_QUEUE);
_TIME_DEQUEUE(td_ptr, kernel_data);
td_ptr->INFO = 0; /* Signal that post is activating the task */
_TASK_READY(td_ptr, kernel_data);
_CHECK_RUN_SCHEDULER(); /* Let higher priority task run */
}
then it seems "spi0:" device is not installed. try to to debug _bsp_enable_card(). step into _io_spi_install("spi0:", &_bsp_spi0_init); is this working ?
also you say you debug spi_vybrid_autoevb_a5 ? this BSP will be supported by MQX 4.0.2 which has not been released yet. you can wait for MQX 4.0.2 release in August.
Hi Martin,
Thanks for your advice. I'm running MQX 4.0.2 Beta1, which should (according to the release notes) support SPI. I stepped through the code and didn't see a reference to _bsp_enable_card. Stepping into _io_spi_install, I hit an error at the line below, right after the program initializes the low level driver:
error_code = driver_data->DEVIF->INIT(init_data_ptr->DEVIF_INIT, &(driver_data->DEVIF_DATA));
The error code returned is SPI_ERROR_CHANNEL_INVALID (0xA705).
SPI is supported, but Vybrid AutoEVB BSP is not fully supported in the 4.0.2 Beta1 version.
There are multiple code lines in the spi low lever driver that can return SPI_ERROR_CHANNEL_INVALID. Which one do you hit ? Why don't you debug down to the lowest level until you see the return SPI_ERROR_CHANNEL_INVALID statement ?
By looking into the code I can see IO_ERROR returned by _bsp_dspi_io_init() in
\mqx\source\bsp\vybrid_autoevb_a5\init_gpio.c
compare to the same function in:
\mqx\source\bsp\twrvf65gs10_a5\init_gpio.c
you will see that you need to implement the pin routing in the _bsp_dspi_io_init() on your own.