This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

simple example of SPI + S110 (on SDK 8.x) ?

Hello,

I wrote a firmware for my project, based on the UART over BLE example, so using the softdevice, establishing connections, etc. It works.

I'd now like to use a sensor connected via SPI. I have looked at the spi_master_with_spi_slave example, but it does not use the softdevice, and I suspect it won't "just work" if I do the same thing, as the softdevice might interfere with interrupts for example. Am I right ?

Does anyone have a simple example of reading and writing data using SPI with SoftDevice enabled (and a BLE connection running) ?

The main problem I'm affraid of is that in some test code I have done with this sensor and without SoftDevice, I have this function :

/**
 * Reads a byte from the specified register in the MFRC522 chip.
 * The interface is described in the datasheet section 8.1.2.
 */
uint8_t PCD_ReadRegister1(	uint8_t reg ) {
	uint32_t err_code;

	m_tx_data[0] = 0x80 | (reg << 1);
	m_tx_data[1] = 0x00;

	m_transfer_done = false;
	err_code = spi_master_send_recv(SPI_MASTER_HW, m_tx_data, 2, m_rx_data, 2);
	APP_ERROR_CHECK(err_code);

	while (!m_transfer_done)
		;

	return m_rx_data[1];
} // End PCD_ReadRegister()

but it ends with a "while (!m_transfer_done), and so it blocks the rest of the execution. How should I rewrite this, but be able to do stuff like :

val = PCD_ReadRegister1(VersionReg);
sprintf(str, "version: 0x%02x\r\n", val);
simple_uart_putstring(str);

(that assumes that PCD_ReadRegister1 returns directly the value, but if I do that I will have a while loop that will block the SoftDevice and other stuff)

?

Thanks for your help

Parents Reply Children
No Data
Related