This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NRF52832 spi slave

Hello,

As a lot of person, I have a problem for use nrf52832(pca10040 board) with spi as slave. I check my master with salae probe tool and this part is correct. Chip select is enable low, data on 8 bits... Very simple configuration. I use the softdevice s132 (example application ble_app_hrs_c) where I add simple spi functions. There is my code :

static const nrf_drv_spis_t spis = NRF_DRV_SPIS_INSTANCE(0); 
static volatile bool spis_xfer_done = false;
#define BLE_MAX_PACKET_SIZE 20

static uint8_t gRxBuffer[BLE_MAX_PACKET_SIZE + 1];
static uint8_t gTxBuffer[BLE_MAX_PACKET_SIZE + 1];

void spis_event_handler(nrf_drv_spis_event_t event)
{
    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {
        spis_xfer_done = true;
        NRF_LOG_INFO("Transfer completed. Received: %s\r\n",(uint32_t)gRxBuffer);
    }
}

void spi_init()
{

	nrf_drv_spis_config_t spis_config =NRF_DRV_SPIS_DEFAULT_CONFIG;

	ret_code_t ret = 0;

	spis_config.csn_pin               = 29; // P0.24
	spis_config.miso_pin              = 28; // P0.23
	spis_config.mosi_pin              = 4; // P0.2
	spis_config.sck_pin               = 14; // P0.11 

	ret = nrf_drv_spis_init(&spis, &spis_config, spis_event_handler);
	NRF_LOG_INFO("Config for SPI %d\r\n",ret); // return 0

	gTxBuffer[0] = 4;
	strcpy(&gTxBuffer[1], "test", 4);
	ret = nrf_drv_spis_buffers_set(&spis, gTxBuffer, 5, gRxBuffer, 5);
}

I never fall in the handler ...

In the makefile,

CFLAGS += -DNRF_LOG_ENABLED
CFLAGS += -DPERIPHERAL_RESOURCE_SHARING_ENABLED
CFLAGS += -DSPIS_ENABLED
CFLAGS += -DSPIS0_ENABLED
CFLAGS += -DSPIS_CONFIG_LOG_ENABLED

In the logs :

nrf_drv_spis_init, error code: NRF_SUCCESS. :Function: nrf_drv_spis_buffers_set, error code: NRF_SUCCESS.

Any idea for me please ??

Thanks in advance

Regards,

Mickael

Related