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

BLE with spi interrupt

Hi!!

I'm adding spi functionality to S132 and SDK 14.0.0 ble_app_uart now.

The communication which added the function of UART to SPI and the sample code of ble_app_uart are successful.

    for (;;)
    {
		if(0 == nrf_gpio_pin_read(30)){
			SPITxDummy(0x00); //Dummy_Data LOFFSTAT
			SPITxDummy(0x00); //Dummy_Data LOFFSTAT
			SPITxDummy1(0x00); //Dummy_Data CH1
			SPITxDummy(0x00); //Dummy_Data CH2
			SPITxDummy(0x00); //Dummy_Data CH2
			}
        power_manage();
    }

          code1:External interrupt handling


void SPITxDummy1(unsigned char Data)
{
	//uint8_t * p_data;
	nrf_gpio_pin_clear(22);  //CS pin low
	static uint8_t       m_rx_buf[2];
m_rx_buf[0] = 0;
	nrf_drv_spi_transfer(&spi, &Data, 1, m_rx_buf, 2);
//	p_data = *m_rx_buf;
	m_rx_buf[0] = *m_rx_buf;
	nrf_delay_us(100);
	//app_uart_put(m_rx_buf[0]);

}

  code2:ExternalDummy data output




I would like to output five dummy data when the pin 30 goes down, I want to transmit the data wirelessly and see it on the smartphone.

I have 2 questions.

When the 30th pin goes down, should 5 dummy data output instructions be placed in the for statement here?

I want to receive data with Dummy 1 and transfer the data over wireless,I want to receive data with Dummy 1, want to transfer data by radio, but how do I store the data received by SPI in p_data on nus_data_handler??

I sincerely wish to achieve this project from the bottom of my heart.

If you have something to know, please tell me!!!

thank you in advanced!!!

Parents
  • Hi,

    1. I do not understand this question. Can you please elaborate what you mean? You can trigger the transfer on pin change, but the data need to be present in the code.
    2. nus_data_handler is used for handling data received over NUS (wireless/BLE). If you want to send data, you need to use the function ble_nus_data_send. In ble_app_uart example, the use of his function is shown in uart_event_handle. You need to use the same method to send data from wherever you receive data from "Dummy1".

    Best regards,
    Jørgen

Reply
  • Hi,

    1. I do not understand this question. Can you please elaborate what you mean? You can trigger the transfer on pin change, but the data need to be present in the code.
    2. nus_data_handler is used for handling data received over NUS (wireless/BLE). If you want to send data, you need to use the function ble_nus_data_send. In ble_app_uart example, the use of his function is shown in uart_event_handle. You need to use the same method to send data from wherever you receive data from "Dummy1".

    Best regards,
    Jørgen

Children
Related