[examples-v2 commit] led.h: Add support for Raspberry Pi and BSPs using same SoC

Joel Sherrill joel at rtems.org
Thu Oct 24 23:20:00 UTC 2013


Module:    examples-v2
Branch:    master
Commit:    2df97c42db875513cc4bec8d4132281e9aa34b59
Changeset: http://git.rtems.org/examples-v2/commit/?id=2df97c42db875513cc4bec8d4132281e9aa34b59

Author:    Pierre Ficheux <pierre.ficheux at openwide.fr>
Date:      Thu Oct 24 18:26:24 2013 -0500

led.h: Add support for Raspberry Pi and BSPs using same SoC

---

 led/led.h |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/led/led.h b/led/led.h
index 63451bc..152b76a 100644
--- a/led/led.h
+++ b/led/led.h
@@ -61,13 +61,23 @@ uint8_t MPC8313_LED_Count;
 #define LED_ON() LED_ROTATE()
 #define LED_OFF() LED_ROTATE()
 
+#elif defined(BCM2835_GPIO_REGS_BASE)
+// Raspberry Pi
+#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3)) 
+#define OUT_GPIO(g) *(gpio+((g)/10)) |=  (1<<(((g)%10)*3)) 
+#define GPIO_SET *(gpio+7)   // sets   bits which are 1 ignores bits which are 0 
+#define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0
+
+#define LED_INIT()  do { unsigned int *gpio = (unsigned int *)BCM2835_GPIO_REGS_BASE; OUT_GPIO(16);} while(0)
+#define LED_ON()  do { unsigned int *gpio = (unsigned int *)BCM2835_GPIO_REGS_BASE; GPIO_CLR = 1 << 16;} while(0)
+#define LED_OFF()  do { unsigned int *gpio = (unsigned int *)BCM2835_GPIO_REGS_BASE; GPIO_SET = 1 << 16;} while(0)
+
 #else
 /* default case is to print */
 
 #define __LED_PRINTING 1
 #define LED_ON()  fputs( "LED ON\n", stderr )
 #define LED_OFF() fputs( "LED OFF\n", stderr )
-
 #endif
 
 #ifndef LED_INIT




More information about the vc mailing list