test gpio and access low level arm registers

Dependencies:   libmDot mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
boddeke
Date:
Thu May 26 09:04:10 2016 +0000
Commit message:
low level register access

Changed in this revision

libmDot.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 111cba7b0520 libmDot.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmDot.lib	Thu May 26 09:04:10 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/MultiTech/code/libmDot/#121e4c454964
diff -r 000000000000 -r 111cba7b0520 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 26 09:04:10 2016 +0000
@@ -0,0 +1,71 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "mDot.h"
+
+
+#define GPIO_PORT   PA_0
+
+RawSerial pc(PA_2,NC);
+
+// results:
+//              default  pullup  pulldown  pullnone  open drain
+// battery + close 0.00    0.00      0.00      0.00        0.00
+// battery + open  1.55    3.01      0.01  drifting    drifting
+// mdk + open      0.00    0.00      0.00      0.00        0.00
+// mdk + close     3.30    3.21      2.26      3.12        3.30
+//
+// conclusion: mdk has something connected to PA_0
+
+// https://developer.mbed.org/users/n0tform3/code/HelloWorld_IKS01A1/docs/1c6281289d67/stm32f4xx_8h_source.html
+
+
+void print_gpio_pa0_config(void) {
+
+        pc.printf("MODER %x\r\n",GPIOA->MODER&0x3);
+        pc.printf("OTYPER %x\r\n",GPIOA->OTYPER&0x1);
+        pc.printf("OSPEEDR %x\r\n",GPIOA->OSPEEDR&0x3);
+        pc.printf("PUPDR %x\r\n",GPIOA->PUPDR&0x3);
+        pc.printf("IDR %x\r\n",GPIOA->IDR&0x1);
+        pc.printf("ODR %x\r\n",GPIOA->ODR&0x1);
+        pc.printf("BSRR %x\r\n",GPIOA->BSRR&0x1);
+        pc.printf("LCKR %x\r\n",GPIOA->LCKR&0x1);
+        pc.printf("AFR[0] %x\r\n",GPIOA->AFR[0]&0xf);
+}
+    
+main() {
+    
+   pc.baud(115200);
+    
+    pc.printf("Build: " __DATE__ ", " __TIME__"\r\n");
+    
+    DigitalIn gpio_sensor(GPIO_PORT);
+    pc.printf("pin mode: default\r\n");
+    print_gpio_pa0_config();
+    wait(10);
+    
+    // uint32_t lock = GPIOA->LCKR;
+    // pc.printf("Read %x\r\n",lock);
+    
+    while(1) {
+         
+         gpio_sensor.mode(PullUp);
+         pc.printf("pin mode: pullup\r\n");
+         print_gpio_pa0_config();
+         wait(10);
+        
+         gpio_sensor.mode(PullDown);
+         pc.printf("pin mode: pulldown\r\n");
+         print_gpio_pa0_config();
+         wait(10);
+         
+         gpio_sensor.mode(PullNone);
+         pc.printf("pin mode: pullnone\r\n");
+         print_gpio_pa0_config();
+         wait(10);
+         
+         gpio_sensor.mode(OpenDrain);
+         pc.printf("pin mode: opendrain\r\n");
+         print_gpio_pa0_config();
+         wait(10);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 111cba7b0520 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu May 26 09:04:10 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#4c105b8d7cae
diff -r 000000000000 -r 111cba7b0520 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 26 09:04:10 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e
\ No newline at end of file