我想实现da14580 spi的奴隶,和use additional 2 pins for transfer flow control, 1pin for master to slave data irq(M2S_irq_pin) and 1pin for slave to master irq(S2M_sync_pin). Master or slave can start spi transfer at anytime. When Master to slave irq assert, it should wait the slave S2M_sync_pin assert to indicate the slave is ready to receive data.
1. Should I call arch_disable_sleep() when I have inited the da14580 spi as slave and waiting for the spi master to start SPI transfer, and call arch_set_extended_sleep() when the transfer has finished?
2. Does the wkupct_enable_irq works at anytime? Can the pin assigned to wakeup generate interrupt at any time(when the system is in sleep, idle ,active mode), ? Since when the spi master want to transfer data to da14580(assert M2S_irq), it does not know whether the da14580 is in active mode or sleep mode, but the slave should prepare for the spi data transfer at anytime when the spi master assert the m2s_irq_pin.
3. Should I enable the EXTERNAL_WAKEUP preprocessor since the M2S_irq_pin will wake the DA14580?
Hi cgha,
Thanks for your inquiry online. To be honest, I am not completely sure what you are you trying to accomplish. As far as I understand, you want to configure the DA14580 as SPI slave and wake it up through M2S_irq_pin? Be aware that when the device is in sleep mode, all the peripherals blocks are powered down, so the chip should operate n active mode. If you use the wake-up controller in order to catch the M2S_irq, this will work at any time. However, it would be very helpful to provide me more inputs for what you are doing.
Thanks, PM_Dialog
Yes, I want to use the M2S_irq_pin to wakeup the DA14580 when the spi master want to send data via spi(whether if the DA14580 is in sleep mode or active mode),when DA14580 is ready to receive data, it ack the external mcu with the S2M_irq_pin active, then the external mcu send data. The process is as following:
DA14580 is advertising or disconnected with no advertising or connected, app running with deep sleep enabled or ext sleep enabled:
1. SPI_MASTER(external mcu) want to send data, put the M2S_irq_pin high.
2. SPI_SLAVE(DA14580) get pin interrupt via M2S_irq_pin
3. SPI_SLAVE initialize it self as spi_slave and ack S2M_irq_pin with high.
4. SPI_MASTER check the S2M_irq_pin, detect high level on S2M_irq_pin, then send spi data to DA14580.
5. SPI_MASTER put the M2S_irq_pin low when data transfer finished.
6. SPI_SLAVE put S2M_irq_pin low.
现在我只能获得第一销中断the first packet of data, when the spi master want to send second packet, da14580 seems can not get the pin interrupt again.
Hi cgha,
Since you send the second interrupt, can you please add a breakpoint in the wake-up controller callback function in order to check if hits? For configuring a wake-up pin, please have a look at the ble_app_sleepmode example of the SDK> Are you using the same code architecture?
Thanks, PM_Dialog
Now it can enter the callback. I should call int_enable function after the pin get high again. But sometime the spi lost some byte after I send dozens of packets. The SPI_Handler seems can not get the bytes quickly enough. The master speed is about 250K bps.
Hi cgha,
To be honest, I could not understand how you would like to wake-up you device upon M2S_irq_pin interrupt detection. Did you configure the wake-up controller? Only the wake-up controller can wake-up the chip.
Thanks, PM_Dialog
Now the wakeup works, So do I need to call arch_disable_sleep() when the spi is transfering? Or should I keep the ble on when spi is transfering?
Hi cgha,
The arch_disable_sleep() disables all sleep modes, so the system operates in active / idle modes only. The DA14580 has 2 sleep modes available:
EXTENDED sleep mode: Only the SystemRAM 42kB & RetentionRAM remain switched on.
DEEP sleep mode: Only the RetentionRAM remains switched on. The OTP must be burnt to be able to measure the DEEP sleep current.
In both of the sleep modes, all the peripheral blocks including the SPI block and the RF block are powered off, so I would suggest to keep the device in active mode while interacting with the SPI block.
Thanks, PM_Dialog