Hello
I am trying to configure the spis with the nrfx drivers. My code is as follows:
#include <zephyr.h> #include <sys/printk.h> #include "nrfx_spis.h" #define PIN_SCK 4 #define PIN_MOSI 5 #define PIN_MISO 6 #define PIN_CSN 7 #define SPIS_NR 3 nrfx_spis_t spis_t = NRFX_SPIS_INSTANCE(SPIS_NR); nrfx_spis_config_t spis_config_t = NRFX_SPIS_DEFAULT_CONFIG(PIN_SCK,PIN_MOSI,NRFX_SPIS_PIN_NOT_USED,PIN_CSN); uint8_t rx_buffer[2]; uint8_t tx_buffer[2]; void spis_event_handler_t(nrfx_spis_evt_t const *p_event, void *p_context){ printk("received\n"); int err; switch(p_event->evt_type){ case NRFX_SPIS_XFER_DONE: err = nrfx_spis_buffers_set(&spis_t, tx_buffer, sizeof(tx_buffer), rx_buffer, sizeof(rx_buffer)); if(err != NRFX_SUCCESS){ printk("Error with setting.\n"); } break; case NRFX_SPIS_BUFFERS_SET_DONE: printk("buffers set\n"); break; case NRFX_SPIS_EVT_TYPE_MAX: break; default: ; } } void init_spis(){ int err; err = nrfx_spis_init(&spis_t,&spis_config_t,spis_event_handler_t,NULL); if(err != NRFX_SUCCESS){ printk("Error with init.\n"); } else { printk("SPIS started.\n"); } err = nrfx_spis_buffers_set(&spis_t, tx_buffer, sizeof(tx_buffer), rx_buffer, sizeof(rx_buffer)); if(err != NRFX_SUCCESS){ printk("Error with setting.\n"); } } void main(void) { init_spis(); }
I enabled the nrfx SPIS driver and the nrfx SPIS3 instance via Segger Embedded and I am using ncs v1.4.0.
My serial output is:
*** Booting Zephyr OS build v2.4.0-ncs1 ***
SPIS started.
However, shouldn't the nrfx_spis_buffers_set trigger the NRFX_SPIS_BUFFERS_SET_DONE event and "received" and "buffers set" should also be sent to the serial output?
Did I do something wrong and my event handler function is not getting called?