mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Apr 22 13:30:06 2014 +0100
Parent:
161:09d8213f0000
Child:
163:995a0017c116
Commit message:
Synchronized with git revision 6b9fca177ab428a93a520d666ca5b4aeb921da51

Full URL: https://github.com/mbedmicro/mbed/commit/6b9fca177ab428a93a520d666ca5b4aeb921da51/

Update gpio_irq_api.c

Changed in this revision

targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.c	Tue Apr 22 13:30:06 2014 +0100
@@ -153,8 +153,6 @@
   * @{
   */
 
-void SetSysClock(void);
-
 #if (USE_PLL_HSE_XTAL != 0) || (USE_PLL_HSE_EXTC != 0)
 uint8_t SetSysClock_PLL_HSE(uint8_t bypass);
 #endif
@@ -208,10 +206,6 @@
   /* Disable all interrupts */
   RCC->CIR = 0x00000000;
 
-  /* Configure the System clock source, PLL Multiplier and Divider factors, 
-     AHB/APBx prescalers and Flash settings */
-  SetSysClock();
-
   /* Configure the Vector Table location add offset address ------------------*/
 #ifdef VECT_TAB_SRAM
   SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/system_stm32f30x.h	Tue Apr 22 13:30:06 2014 +0100
@@ -65,6 +65,7 @@
   
 extern void SystemInit(void);
 extern void SystemCoreClockUpdate(void);
+extern void SetSysClock(void);
 
 /**
   * @}
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_irq_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -39,11 +39,11 @@
 #define EDGE_FALL (2)
 #define EDGE_BOTH (3)
 
-#define CHANNEL_NUM (4)
+#define CHANNEL_NUM (7)
 
-static uint32_t channel_ids[CHANNEL_NUM]  = {0, 0, 0, 0};
-static uint32_t channel_gpio[CHANNEL_NUM] = {0, 0, 0, 0};
-static uint32_t channel_pin[CHANNEL_NUM]  = {0, 0, 0, 0};
+static uint32_t channel_ids[CHANNEL_NUM]  = {0, 0, 0, 0, 0, 0, 0};
+static uint32_t channel_gpio[CHANNEL_NUM] = {0, 0, 0, 0, 0, 0, 0};
+static uint32_t channel_pin[CHANNEL_NUM]  = {0, 0, 0, 0, 0, 0, 0};
 
 static gpio_irq_handler irq_handler;
 
@@ -51,7 +51,7 @@
     // Retrieve the gpio and pin that generate the irq
     GPIO_TypeDef *gpio = (GPIO_TypeDef *)(channel_gpio[irq_index]);
     uint32_t pin = (uint32_t)(1 << channel_pin[irq_index]);
-     
+
     // Clear interrupt flag
     if (EXTI_GetITStatus(pin) != RESET)
     {
@@ -70,10 +70,13 @@
 }
 
 // The irq_index is passed to the function
-static void gpio_irq0(void) {handle_interrupt_in(0);}
-static void gpio_irq1(void) {handle_interrupt_in(1);}
-static void gpio_irq2(void) {handle_interrupt_in(2);}
-static void gpio_irq3(void) {handle_interrupt_in(3);}
+static void gpio_irq0(void) {handle_interrupt_in(0);} // EXTI line 0
+static void gpio_irq1(void) {handle_interrupt_in(1);} // EXTI line 1
+static void gpio_irq2(void) {handle_interrupt_in(2);} // EXTI line 2
+static void gpio_irq3(void) {handle_interrupt_in(3);} // EXTI line 3
+static void gpio_irq4(void) {handle_interrupt_in(4);} // EXTI line 4
+static void gpio_irq5(void) {handle_interrupt_in(5);} // EXTI lines 5 to 9
+static void gpio_irq6(void) {handle_interrupt_in(6);} // EXTI lines 10 to 15
 
 extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
 
@@ -88,29 +91,53 @@
     uint32_t pin_index  = STM_PIN(pin);
 
     // Select irq number and interrupt routine
-    switch (pin) {
-        case PC_13: // User button
-            irq_n = EXTI15_10_IRQn;
+    switch (pin_index) {
+        case 0:
+            irq_n = EXTI0_IRQn;
             vector = (uint32_t)&gpio_irq0;
             irq_index = 0;
             break;
-        case PB_3:
-            irq_n = EXTI3_IRQn;
+        case 1:
+            irq_n = EXTI1_IRQn;
             vector = (uint32_t)&gpio_irq1;
             irq_index = 1;
             break;
-        case PB_4:
-            irq_n = EXTI4_IRQn;
+        case 2:
+            irq_n = EXTI2_IRQn;
             vector = (uint32_t)&gpio_irq2;
             irq_index = 2;
             break;
-        case PB_5:
-            irq_n = EXTI9_5_IRQn;
+        case 3:
+            irq_n = EXTI3_IRQn;
             vector = (uint32_t)&gpio_irq3;
             irq_index = 3;
             break;
+        case 4:
+            irq_n = EXTI4_IRQn;
+            vector = (uint32_t)&gpio_irq4;
+            irq_index = 4;
+            break;
+        case 5:
+        case 6:
+        case 7:
+        case 8:
+        case 9:
+            irq_n = EXTI9_5_IRQn;
+            vector = (uint32_t)&gpio_irq5;
+            irq_index = 5;
+            break;
+        case 10:
+        case 11:
+        case 12:
+        case 13:
+        case 14:
+        case 15:
+            irq_n = EXTI15_10_IRQn;
+            vector = (uint32_t)&gpio_irq6;
+            irq_index = 6;
+            break;
         default:
-            error("This pin is not supported with InterruptIn.");
+            error("InterruptIn error: pin not supported.\n");
             return -1;
     }
 
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/analogin_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -26,10 +26,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "analogin_api.h"
-#include "wait_api.h"
 
 #if DEVICE_ANALOGIN
 
+#include "wait_api.h"
 #include "cmsis.h"
 #include "pinmap.h"
 #include "error.h"
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/gpio_irq_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -29,7 +29,6 @@
  */
 #include <stddef.h>
 #include "cmsis.h"
-
 #include "gpio_irq_api.h"
 #include "pinmap.h"
 #include "error.h"
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/i2c_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -100,7 +100,7 @@
 void i2c_frequency(i2c_t *obj, int hz) {
     I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c);
     I2C_InitTypeDef I2C_InitStructure;
-    uint32_t tim;
+    uint32_t tim = 0;
 
     // Disable the Fast Mode Plus capability
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // Enable SYSCFG clock
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/mbed_overrides.c	Tue Apr 22 13:30:06 2014 +0100
@@ -25,11 +25,14 @@
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
-extern void SystemCoreClockUpdate(void); 
+#include "cmsis.h"
 
 // This function is called after RAM initialization and before main.
 void mbed_sdk_init() {
+    /* Configure the System clock source, PLL Multiplier and Divider factors,
+     AHB/APBx prescalers and Flash settings */
+    SetSysClock();
+
     // Update the SystemCoreClock variable.
     SystemCoreClockUpdate();
 }
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/pwmout_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -29,6 +29,8 @@
  */
 #include "pwmout_api.h"
 
+#if DEVICE_PWMOUT
+
 #include "cmsis.h"
 #include "pinmap.h"
 #include "error.h"
@@ -275,3 +277,5 @@
     float value = (float)us / (float)obj->period;
     pwmout_write(obj, value);
 }
+
+#endif
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/rtc_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -29,6 +29,8 @@
  */
 #include "rtc_api.h"
 
+#if DEVICE_RTC
+
 static int rtc_inited = 0;
 
 void rtc_init(void) {
@@ -136,3 +138,5 @@
     RTC_SetTime(RTC_Format_BIN, &timeStruct);
     PWR_BackupAccessCmd(DISABLE); // Disable access to RTC
 }
+
+#endif
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/serial_api.c	Tue Apr 22 13:30:06 2014 +0100
@@ -28,6 +28,9 @@
  *******************************************************************************
  */
 #include "serial_api.h"
+
+#if DEVICE_SERIAL
+
 #include "cmsis.h"
 #include "pinmap.h"
 #include "error.h"
@@ -309,3 +312,5 @@
     USART_RequestCmd(usart, USART_Request_SBKRQ, DISABLE);
     USART_ClearFlag(usart, USART_FLAG_SBK);
 }
+
+#endif
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c	Tue Apr 22 10:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/sleep.c	Tue Apr 22 13:30:06 2014 +0100
@@ -28,10 +28,10 @@
  *******************************************************************************
  */
 #include "sleep_api.h"
-#include "cmsis.h"
 
-// This function is in the system_stm32f30x.c file
-extern void SetSysClock(void);
+#if DEVICE_SLEEP
+
+#include "cmsis.h"
 
 // MCU SLEEP mode
 void sleep(void) {
@@ -53,3 +53,5 @@
     // After wake-up from STOP reconfigure the PLL
     SetSysClock();
 }
+
+#endif