STM32 blinky through bit banding

Dependencies:   mbed

Fork of mbed_blinky by Mbed

Files at this revision

API Documentation at this revision

Comitter:
crazyafrican
Date:
Wed Jan 27 02:48:46 2016 +0000
Parent:
9:0d1a88e54782
Commit message:
Initial

Changed in this revision

main.cpp 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 0d1a88e54782 -r 3a480c091e52 main.cpp
--- a/main.cpp	Thu Oct 29 12:28:39 2015 +0000
+++ b/main.cpp	Wed Jan 27 02:48:46 2016 +0000
@@ -1,12 +1,34 @@
 #include "mbed.h"
 
+//{/*** Bit Banding *******************************************************/
+/* base address for bit banding */
+#define BITBAND_SRAM_REF                    (0x20000000)
+/* base address for bit banding */
+#define BITBAND_SRAM_BASE                   (0x22000000)
+/* base address for bit banding */
+#define BITBAND_PERIPH_REF                  (0x40000000)
+/* base address for bit banding */
+#define BITBAND_PERIPH_BASE                 (0x42000000)
+
+/* sram bit band */
+#define BITBAND_SRAM(address, bit)   ((void*)(BITBAND_SRAM_BASE + (((uint32_t)address) - BITBAND_SRAM_REF) * 32 + (bit) * 4))
+
+/* periph bit band */
+#define BITBAND_PERIPH(address, bit) ((void*)(BITBAND_PERIPH_BASE + (((uint32_t)address) - BITBAND_PERIPH_REF) * 32 + (bit) * 4))
+//}/***********************************************************************/
+
+
+// Initialise LED1 gpio
 DigitalOut myled(LED1);
 
+/* bit-band definition, LED1 is PA_5 */
+#define LED_BB *((volatile unsigned char *)BITBAND_PERIPH(&GPIOA->ODR, 5))
+
 int main() {
     while(1) {
-        myled = 1;
+        LED_BB = 1; // set led on
         wait(0.2);
-        myled = 0;
+        LED_BB = 0; // clear led
         wait(0.2);
     }
 }
diff -r 0d1a88e54782 -r 3a480c091e52 mbed.bld
--- a/mbed.bld	Thu Oct 29 12:28:39 2015 +0000
+++ b/mbed.bld	Wed Jan 27 02:48:46 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file