Hi, I want to send data from arduino to nrf51dk which will then use uart service to send the data over bluetooth. I want to use SPI communication between the two microcontrollers. Can I get any working example combining SPI and nus-uart?
Hi, I want to send data from arduino to nrf51dk which will then use uart service to send the data over bluetooth. I want to use SPI communication between the two microcontrollers. Can I get any working example combining SPI and nus-uart?
You need to learn to break problems down into their constituent parts.
In this case, two parts should be immediately apparent:
It should be easy enough to find examples of each - so get each one working separately, and then bring the two together.
@awneil: Hi, i added the spi slave example to nus-uart but it is not working. I am not getting any error but spi section is not working though it works independently without nus(checked using spi-master). I added these two functions to nus-uart, and called spi_slave_init() in main() -
static void spi_slave_init (void)
{
nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG(SPIS_INSTANCE);
spis_config.csn_pin = SPIS_CS_PIN;
memset(m_rx_buf, 0, m_length);
APP_ERROR_CHECK(nrf_drv_spis_init(&spis, &spis_config, spis_event_handler));
spis_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, m_tx_buf, m_length, m_rx_buf, m_length));
while (!spis_xfer_done)
{
__WFE();
}
}
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_PRINTF(" Transfer completed. Received: %s\n",m_rx_buf);
if(SPI_BUFFER_SIZE <= 20)
{
ble_nus_string_send(&m_nus, &m_rx_buf[0], SPI_BUFFER_SIZE);
}
LEDS_INVERT(BSP_LED_3_MASK);
}
}