I am starting a new project that uses the RTL8720CM SoC and the goal is for it to be used as a SPI slave device. Because the master will be a low end MCU with not as much RAM (compared to RTL8720CM) to work with it will be performing variable byte length SPI transactions. I need to know when the SPI transaction is completed. Most MCUs I have worked with provide such an event by a chip/salve select (CS / SS) inactive/deassert interrupt.
I am not seeing a SPI slave SS deassert event callback in the ambz2_sdk’s SPI library. I only see
spi_bus_tx_done_irq_hook() callback register functions are provided but neither cause my handler function to be called upon SPI SS deassert. Only when DMA buffers are empty (transmit) or full (receive) for former and looks like SPI transmit FIFO is empty for the latter.
It does look like there is SPI slave deassert interrupt as described by the memory mapped register definition structure
SSI0_Type but apparently not used by the SPI library. And unfortunately there does not appear to be a way to install my own SSI/SPI interrupt service routine so I can handle the
SSI0_Type.isr_b.ssris interrupt on my own in order to workaround the current SPI library limitations.
I looked through the ambd_sdk and come to find out it offers two APIs for working with the peripheral controllers. One the same mbed API that Ameba ZII SDK offers and a raw API. Raw SPI is exactly what I could use to resolve the issue, but unfortunately raw API does not appear to be available in the Ameba ZII SDK.
Alternatively I have looked into using the GPIO external interrupt hook to get SPI slave deassert. However the
gpio_irq API refuses to operate with the pin when it is already assigned for SPI CS. Even though all other SoC and MCUs I have worked with (ARM9, Cortex-M, Blackfin, AVR) are commonly designed in such a way that the GPIO peripheral controller is always physically connected to all GPIO pins, with the exception when configured for analog input mode. Therefore having alt function set for a pin does not normally prevent from still using the GPIO input edge interrupt. However the ambz2_sdk API prevents such a configuration (Unless there is a workaround I am not aware of).
Also due to my project’s needs for all other peripheral ports and GPIOs it does not have a spare pin to externally tie together with the SPI CS pin.
Any help is appreciated. Thanks.