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

Error of use TWI and SPI with different instances?

Hello,

I try to declare two instrances of TWI0 and SPI1, and I include the both sdk_config (sdk_config_spi and sdk_config_twi) in the same file, but I always get the error:

multiple definition of `SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler'

there is my code:

#include "spi.hpp" #include "nrf_drv_spi.h"

#define CS_PIN 6 #define DQ0 22 #define DQ1 19 #define DQ2 20 #define DQ3 24 #define CLK 23

#define SPI1_USE_EASY_DMA 1 #define SPI_INSTANCE 1 static const nrf_drv_spi_t spi1 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);
static bool spi_xfer_done; /**< Flag used to indicate that SPI instance completed the transfer. */

void spi_event_handler(nrf_drv_spi_evt_t const *p_event) { spi_xfer_done = 1; }

void initSPI() { nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;

// spi_config.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
spi_config.ss_pin   = CS_PIN;
spi_config.miso_pin = DQ1;
spi_config.mosi_pin = DQ0 ;
spi_config.sck_pin  = CLK;

nrf_drv_spi_init(&spi1, &spi_config, spi_event_handler);

}

void spiRead(uint8_t *rx_payload, uint8_t size_rx) {

}

void spiWrite(uint8_t const *tx_payload, uint8_t size_tx) {

}

void spiWriteRead(uint8_t const *tx_payload, uint8_t size_tx, uint8_t *rx_payload, uint8_t size_rx) {

}

Thanks you for help !

Related