Fork of mbed-dev build 137, last build before FAT file system appears to be broken. Also reduced HSE timeout time in STM4XX HAL
Fork of mbed-dev by
Diff: targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c
- Revision:
- 150:02e0a0aed4ec
- Parent:
- 149:156823d33999
- Child:
- 160:d5399cc887bb
--- a/targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c Fri Oct 28 11:17:30 2016 +0100 +++ b/targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c Tue Nov 08 17:45:16 2016 +0000 @@ -85,25 +85,52 @@ nrf_drv_spi_t master; nrf_drv_spis_t slave; } sdk_driver_instances_t; + +void SPI0_TWI0_IRQHandler(void); +void SPI1_TWI1_IRQHandler(void); +void SPIM2_SPIS2_SPI2_IRQHandler(void); + +static const peripheral_handler_desc_t spi_hanlder_desc[SPI_COUNT] = { +#if SPI0_ENABLED + { + SPIS0_IRQ, + (uint32_t) SPI0_TWI0_IRQHandler + }, +#endif +#if SPI1_ENABLED + { + SPIS1_IRQ, + (uint32_t) SPI1_TWI1_IRQHandler + }, +#endif +#if SPI2_ENABLED + { + SPIS2_IRQ, + (uint32_t) SPIM2_SPIS2_SPI2_IRQHandler + }, +#endif +}; + + static sdk_driver_instances_t m_instances[SPI_COUNT] = { - #if SPI0_ENABLED +#if SPI0_ENABLED { NRF_DRV_SPI_INSTANCE(0), NRF_DRV_SPIS_INSTANCE(0) }, - #endif - #if SPI1_ENABLED +#endif +#if SPI1_ENABLED { NRF_DRV_SPI_INSTANCE(1), NRF_DRV_SPIS_INSTANCE(1) }, - #endif - #if SPI2_ENABLED +#endif +#if SPI2_ENABLED { NRF_DRV_SPI_INSTANCE(2), NRF_DRV_SPIS_INSTANCE(2) }, - #endif +#endif }; static void master_event_handler(uint8_t spi_idx, @@ -201,7 +228,7 @@ p_config->frequency = p_spi_info->frequency; p_config->mode = (nrf_drv_spi_mode_t)p_spi_info->spi_mode; - p_config->irq_priority = APP_IRQ_PRIORITY_LOW; + p_config->irq_priority = SPI1_CONFIG_IRQ_PRIORITY; p_config->orc = 0xFF; p_config->bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST; } @@ -215,7 +242,7 @@ p_config->csn_pin = p_spi_info->ss_pin; p_config->mode = (nrf_drv_spis_mode_t)p_spi_info->spi_mode; - p_config->irq_priority = APP_IRQ_PRIORITY_LOW; + p_config->irq_priority = SPIS1_CONFIG_IRQ_PRIORITY; p_config->orc = NRF_DRV_SPIS_DEFAULT_ORC; p_config->def = NRF_DRV_SPIS_DEFAULT_DEF; p_config->bit_order = NRF_DRV_SPIS_BIT_ORDER_MSB_FIRST; @@ -230,6 +257,9 @@ for (i = 0; i < SPI_COUNT; ++i) { spi_info_t *p_spi_info = &m_spi_info[i]; if (!p_spi_info->initialized) { + + NVIC_SetVector(spi_hanlder_desc[i].IRQn, spi_hanlder_desc[i].vector); + p_spi_info->sck_pin = (uint8_t)sclk; p_spi_info->mosi_pin = (mosi != NC) ? (uint8_t)mosi : NRF_DRV_SPI_PIN_NOT_USED;