mbed library sources. Supersedes mbed-src. Fixed broken STM32F1xx RTC on rtc_api.c

Dependents:   Nucleo_F103RB_RTC_battery_bkup_pwr_off_okay

Fork of mbed-dev by mbed official

Revision:
150:02e0a0aed4ec
Parent:
149:156823d33999
Child:
160:d5399cc887bb
--- a/targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c	Fri Oct 28 11:17:30 2016 +0100
+++ b/targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c	Tue Nov 08 17:45:16 2016 +0000
@@ -107,6 +107,25 @@
     return (i2c_address >> 1);
 }
 
+void SPI0_TWI0_IRQHandler(void);
+void SPI1_TWI1_IRQHandler(void);
+
+static const peripheral_handler_desc_t twi_handlers[TWI_COUNT] =
+{
+    #if TWI0_ENABLED
+    {
+        SPI0_TWI0_IRQn,
+        (uint32_t) SPI0_TWI0_IRQHandler
+    },
+    #endif
+    #if TWI1_ENABLED
+    {
+        SPI1_TWI1_IRQn,
+        (uint32_t) SPI1_TWI1_IRQHandler
+    }
+    #endif 
+};
+
 void i2c_init(i2c_t *obj, PinName sda, PinName scl)
 {
     int i;
@@ -124,12 +143,20 @@
     nrf_drv_twi_config_t const config = {
         .scl                = scl,
         .sda                = sda,
-        .frequency          = NRF_TWI_FREQ_100K,
-        .interrupt_priority = APP_IRQ_PRIORITY_LOW,
+        .frequency          = NRF_TWI_FREQ_100K,  
+#ifdef NRF51
+        .interrupt_priority = APP_IRQ_PRIORITY_LOW
+#elif defined(NRF52)
+        .interrupt_priority = APP_IRQ_PRIORITY_LOWEST
+#endif
+        
     };
 
     for (i = 0; i < TWI_COUNT; ++i) {
         if (!m_twi_info[i].initialized) {
+
+            NVIC_SetVector(twi_handlers[i].IRQn, twi_handlers[i].vector);
+
             nrf_drv_twi_t const *twi = &m_twi_instances[i];
             ret_code_t ret_code =
                 nrf_drv_twi_init(twi, &config, twi_event_handler, obj);