mbed
Fork of mbed-dev by
Diff: targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c
- Revision:
- 169:e3b6fe271b81
- Parent:
- 167:e84263d55307
- Child:
- 171:19eb464bc2be
--- a/targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c Thu Jul 06 15:42:05 2017 +0100 +++ b/targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c Wed Jul 19 17:31:21 2017 +0100 @@ -277,9 +277,11 @@ } } - for (i = 0; i < SPI_COUNT; ++i) { + for (i = SPI_COUNT - 1; i >= 0; i--) { spi_info_t *p_spi_info = &m_spi_info[i]; + if (!p_spi_info->initialized) { + p_spi_info->sck_pin = (uint8_t)sclk; p_spi_info->mosi_pin = (mosi != NC) ? (uint8_t)mosi : NRF_DRV_SPI_PIN_NOT_USED; @@ -290,8 +292,6 @@ p_spi_info->spi_mode = (uint8_t)NRF_DRV_SPI_MODE_0; p_spi_info->frequency = NRF_DRV_SPI_FREQ_1M; - NVIC_SetVector(spi_handler_desc[i].IRQn, spi_handler_desc[i].vector); - // By default each SPI instance is initialized to work as a master. // Should the slave mode be used, the instance will be reconfigured // appropriately in 'spi_format'. @@ -305,11 +305,11 @@ p_spi_info->initialized = true; p_spi_info->master = true; p_spi_info->flag.busy = false; - #if DEVICE_SPI_ASYNCH +#if DEVICE_SPI_ASYNCH p_spi_info->handler = 0; - #endif +#endif SPI_IDX(obj) = i; - + NVIC_SetVector(spi_handler_desc[i].IRQn, spi_handler_desc[i].vector); return; } }