- fix F411 F334 systeminit when HSI used - portinout always read IDR regardless of port direction

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
Geremia
Date:
Sat Sep 27 11:16:28 2014 +0000
Parent:
331:098575c6d2c8
Commit message:
- fix F411 F334 systeminit when HSI used; - STMs PortInOut port.read() always read input data register (real external pin state) even if direction is output (same as other platforms)

Changed in this revision

targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/system_stm32f3xx.c Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/system_stm32f4xx.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F051R8/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F100RB/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_DISCO_F303VC/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F3XX/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F407VG/port_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F4XX/port_api.c Show annotated file Show diff for this revision Revisions of this file
diff -r 098575c6d2c8 -r e299ae530e63 targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/system_stm32f3xx.c
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/system_stm32f3xx.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/system_stm32f3xx.c	Sat Sep 27 11:16:28 2014 +0000
@@ -144,7 +144,7 @@
   */
 uint32_t SystemCoreClock = 72000000;
 
-__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
 
 /**
   * @}
diff -r 098575c6d2c8 -r e299ae530e63 targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/system_stm32f4xx.c
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/system_stm32f4xx.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/system_stm32f4xx.c	Sat Sep 27 11:16:28 2014 +0000
@@ -157,7 +157,7 @@
                variable is updated automatically.
   */
 uint32_t SystemCoreClock = 16000000;
-__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
 
 /**
   * @}
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_DISCO_F051R8/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F051R8/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -88,11 +88,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_DISCO_F100RB/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -88,12 +88,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    }
-    else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_DISCO_F303VC/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -88,11 +88,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -88,11 +88,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F072RB/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -87,11 +87,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -88,11 +88,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F302R8/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -93,11 +93,7 @@
 
 int port_read(port_t *obj)
 {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -87,11 +87,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -93,11 +93,7 @@
 
 int port_read(port_t *obj)
 {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -87,11 +87,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -88,11 +88,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_STM32F3XX/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_STM32F3XX/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F3XX/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -87,11 +87,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_STM32F407VG/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_STM32F407VG/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F407VG/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -87,11 +87,7 @@
 }
 
 int port_read(port_t *obj) {
-    if (obj->direction == PIN_OUTPUT) {
-        return (*obj->reg_out & obj->mask);
-    } else { // PIN_INPUT
-        return (*obj->reg_in & obj->mask);
-    }
+    return (*obj->reg_in & obj->mask); // always read IDR, regardless of pin direction
 }
 
 #endif
diff -r 098575c6d2c8 -r e299ae530e63 targets/hal/TARGET_STM/TARGET_STM32F4XX/port_api.c
--- a/targets/hal/TARGET_STM/TARGET_STM32F4XX/port_api.c	Wed Sep 24 13:15:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F4XX/port_api.c	Sat Sep 27 11:16:28 2014 +0000
@@ -73,11 +73,7 @@
 }
 
 int port_read(port_t *obj) {
-    switch (obj->direction) {
-        case PIN_OUTPUT: return *obj->reg_out & obj->mask;
-        case PIN_INPUT: return *obj->reg_in & obj->mask;
-    }
-    return 0;
+    return *obj->reg_in & obj->mask;
 }
 
 #endif