Quick question I think. I'm using the NRF52 to program a PIC16 over SPI. The PIC16 switches it's line to output once it receives a particular command so as such I need to switch the MOSI/MISO line and then back once the data is read. My understanding is the SPI must be disabled when doing this. Does this look correct?
(CLK is configured as output so will drive low when SPI is disabled)
static void configureAsOutput (void) { NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos; NRF_GPIO->PIN_CNF[CFG_PIN_GLUE_DAT] = pinDisconnectInputBuffer | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); NRF_SPIM0->PSEL.MOSI = CFG_PIN_GLUE_DAT; NRF_SPIM0->PSEL.MISO = SPI_PSEL_MOSI_CONNECT_Disconnected << SPI_PSEL_MOSI_CONNECT_Pos; NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos; } static uint16_t fetch (void) { command(0xFE); // read nvm NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos; NRF_GPIO->PIN_CNF[CFG_PIN_GLUE_DAT] = (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); NRF_SPIM0->PSEL.MOSI = SPI_PSEL_MOSI_CONNECT_Disconnected << SPI_PSEL_MOSI_CONNECT_Pos; NRF_SPIM0->PSEL.MISO = CFG_PIN_GLUE_DAT; NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos; send(3); configureAsOutput(); return rxBuffer[0] << 15 | rxBuffer[1] << 7 | rxBuffer[2] >> 1; }