K20
MQX 4.2
8 bit data
SLAVE SPI
spifd = fopen("spi1:1",(void*)SPI_FLAG_FULL_DUPLEX);
ioctrl(spifd,IOCTL_SPI_SET_TRANSFER_MODE, SPI_DEVICE_SLAVE_MODE);
rw.BUFFER_LENGH = 6;
rw.WRITE_BUFFER = (char *)send_buffer;
rw.READ_BUFFER = (char *)receive_buffer;
ioctl(spifd, IOCTL_SPI_READ_WRITE, &rw); -> _io_ioctl(..) -> _io_spi_ioctl(..) -> _io_spi_read_write(..) ->_dspi_dma_setparam(..)
_dspi_dma_setparam(...):
....
if ((params->ATT & SPI_ATTR_TRANSFER_MODE_MASK != SPI_ATTR_MASTER_MODE)
return SPI_ERROR_TRANSFER_MODE_INVALID; <--- I get here.
Question:
1) Does MQX 4.2 support slave SPI dma transfers? if so, how?
2) Does "_io_spi_read_write(...) support slave DMA transfer?
3) Why doesn't "_dspi_dma_setparam(..)" support slave mode transfers?
HI soledad/ NXP team,
Is there any documentation to integrate the PE generated codes to an already existing MQX application without PE?
Best regards
Sarma
HI soledad/ NXP team,
I got the SPI0 slave driver tested with interrupt and polling modes. attached is the step wise reference. Hope this help as a workaround untill NXP releases a solution. The blog is here:
https://community.nxp.com/community/uvp/projects-documentation/blog/2018/06/11/mqx-spi-slave-configu...
PS: The document is not properly indented. Pardon the coding style.
Best regards
Sarma
Hello Mark,
If we look into MQX 4.2.0 Release Notes.pdf, on page 11 it states:
----------------- SPI I/O Driver
This driver supports the operation master mode. If enabled in user configuration, the SPI device drivers are installed during the BSP startup code as “spi0:” (or “spiX:” where X is index of the SPI module used). The SPI driver is significantly rewritten in the MQX 4.0, so that there is no distinct interrupt or polled driver type. See I/O User Guide for details. On Kinetis and Vybrid platforms, the driver uses DMA to function.
------------------
For slave mode, you can use one of:
- ProcessorExpert bases spi driver
- spi_legacy driver (which is the one from MQX 3.8.1). Spi_legacy has slave mode. If you wish to use this one, you have to add the spi_legacy source files to the application or BSP build project.
- write your own driver for spi slave using direct accesses to DSPI module registers and call it from an MQX task.
Regarding DMA:
DMA support in device drivers has been extended
- Introduced new DMA device driver, supporting eDMA peripheral on Kinetis and Vybrid processor families
- The SPI device driver was updated to support the new DMA driver
- The SAI and eSAI audio drivers support DMA
- eSDHC drivers were reworked to fully leverage the ADMA peripheral module
However please check the DSPI issues related to the DMA usage:
When the DSPI uses the eDMA, it may transfer data incorrectly or fail when eDMA is used for another purpose. If the DSPI driver is the only user of eDMA, it should operate correctly. This behavior is a result of the silicon design of the DSPI. DMA usage can be disabled in the DSPI driver by redefining the macro BSPCFG_DSPIx_USE_DMA to 0 in user_config.h.
Please check more information at the next link:
https://community.freescale.com/thread/323538
I hope this helps,
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Soledad,
I the SPI slave available now or we have to go with the options you have given?
Hi markkalior, have you been able to run your SPI slave? can you share any reference code?
Best regards
Sarma
Hi @soledad
I got PE code generated for SPI SLave and tested my hadware. Now I am trying to integrate this code to my main MQX application which is not using PE.
I am looking for some references to import PE generated driver code(bare metal or MQX based) to an application without PE. I have done a quick search in the lists and couldn't find anything useful.
Best regards
Sarma
Thanks for your response.
As I suspected. A bit surprised MQX doesn't support SPI Slave mode. Wish documented that up front, instead of finding out by trying it. It doesn't seem like Slave support would be a major effort.
Does MQX support I2C Slave mode?
Hello Mark,
MQX provides a I2C driver, this driver supports the I2C interface in both master and slave mode. If enabled in user configuration, the I2C driver is
installed during the BSP startup code as the "i2cx" in polled mode and as the "ii2cx" in interrupt mode where "x" stands for a
specified I2C channel number). Example applications are provided in the MQX RTOS source tree for both master and slave
mode.
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------