Hello everyone,
I'm new to embedded system and I'm working with the NRF52 and more precisely with the DW1001 (NRF52 + DW1000).
The Decawave device (DW1000) is already configure to receive data from the NRF52 through the SPI
I'm trying to receive the exact same data on a second DW1000 which I cabled (to the DW1001) :
Then I followed the Nordic infocenter SPI Master tutorial :http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk52.v0.9.1%2Fhardware_driver_spi_master.html&cp=4_0_0_2_7
However, I got an issue when I'm using NRF_DRV_SPI_DEFAULT_CONFIG(0)
What I have done so far :
1- Switch SPI0_ENABLED to 1.
/* SPI */ #define SPI0_ENABLED 1 #if (SPI0_ENABLED == 1) #define SPI0_USE_EASY_DMA 0 #define SPI0_CONFIG_SCK_PIN 2 #define SPI0_CONFIG_MOSI_PIN 3 #define SPI0_CONFIG_MISO_PIN 4 #define SPI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
2- Create a master Instance
#define SPI0_INSTANCE 0 /**< First SPI instance index. */ static const nrf_drv_spi_t m_spi_master_0 = NRF_DRV_SPI_INSTANCE(0); /**< First SPI instance. */ static volatile bool spi0_xfer_done; /**< Flag used to indicate that SPI instance completed the transfer. */
3- Event handler to test
void spi0_event_handler(nrf_drv_spi_evt_t const * p_event) { spi0_xfer_done=true; if(spi0_xfer_done==true){printf("ok");} }
4- In main function :
nrf_drv_spi_config_t config = NRF_DRV_SPI_DEFAULT_CONFIG(0);
And this is my problem. When i'm checking the error, it expect NRF_DRV_SPI_DEFAULT_CONFIG without parameters. Then I have looked into the lib and I see that it's different from the SPI master example available. My function has no id :
#define NRF_DRV_SPI_DEFAULT_CONFIG \ { \ .sck_pin = NRF_DRV_SPI_PIN_NOT_USED, \ .mosi_pin = NRF_DRV_SPI_PIN_NOT_USED, \ .miso_pin = NRF_DRV_SPI_PIN_NOT_USED, \ .ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \ .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \ .orc = 0xFF, \ .frequency = NRF_DRV_SPI_FREQ_4M, \ .mode = NRF_DRV_SPI_MODE_0, \ .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST, \ } Instead of : /** * @brief SPI master instance default configuration. */ #define NRF_DRV_SPI_DEFAULT_CONFIG(id) \ { \ .sck_pin = CONCAT_3(SPI, id, _CONFIG_SCK_PIN), \ .mosi_pin = CONCAT_3(SPI, id, _CONFIG_MOSI_PIN), \ .miso_pin = CONCAT_3(SPI, id, _CONFIG_MISO_PIN), \ .ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \ .irq_priority = CONCAT_3(SPI, id, _CONFIG_IRQ_PRIORITY), \ .orc = 0xFF, \ .frequency = NRF_DRV_SPI_FREQ_4M, \ .mode = NRF_DRV_SPI_MODE_0, \ .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST, \ }
You can find more here : http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk51.v10.0.0%2Fhardware_driver_spi_master.html&cp=4_0_2_2_7
The exemple SPI master use :
* @brief SPI master instance default configuration. */ #define NRF_DRV_SPI_DEFAULT_CONFIG(id) \ { \ .sck_pin = CONCAT_3(SPI, id, _CONFIG_SCK_PIN), \ .mosi_pin = CONCAT_3(SPI, id, _CONFIG_MOSI_PIN), \ .miso_pin = CONCAT_3(SPI, id, _CONFIG_MISO_PIN), \ .ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \ .irq_priority = CONCAT_3(SPI, id, _CONFIG_IRQ_PRIORITY), \ .orc = 0xFF, \ .frequency = NRF_DRV_SPI_FREQ_4M, \ .mode = NRF_DRV_SPI_MODE_0, \ .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST, \ }
This is probably the issue but I have no clue how to fix it. Any help appreciate on this (Maybe I'm going the wrong way too)