summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ficheux <pierre.ficheux@openwide.fr>2014-08-29 08:16:23 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-08-29 13:33:34 -0500
commit944b4f1f73e8f173fd9c3efaaf79a4b542375106 (patch)
treee221973afeb3a0b9971dde5d45ecc8eddd033815
parent61d2a1f2e8ddb992f98e80cd503879226730eeec (diff)
example-v2 patch for RPi B+ (led)
Hi, Here is the patch for "example-v2" project to support Raspberry Pi B+ as led number is now 47 instead of 16 on RPi B. regards -- Pierre FICHEUX -/- CTO OW/OWI, France -\- pierre.ficheux@openwide.fr http://ingenierie.openwide.fr http://www.linuxembedded.fr I would love to change the world, but they won't give me the source code From e4d8edfb8650207641bc8e2716cf15ce958ede0f Mon Sep 17 00:00:00 2001 From: Pierre FICHEUX <pierre.ficheux@openwide.fr> Date: Fri, 29 Aug 2014 15:11:41 +0200 Subject: [PATCH] Added led blink support for RPi B+
-rw-r--r--led/led.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/led/led.h b/led/led.h
index 152b76a..3fee684 100644
--- a/led/led.h
+++ b/led/led.h
@@ -67,10 +67,18 @@ uint8_t MPC8313_LED_Count;
#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)
+// For GPIO# >= 32 (RPi B+)
+#define GPIO_SET_EXT *(gpio+8) // sets bits which are 1 ignores bits which are 0
+#define GPIO_CLR_EXT *(gpio+11) // clears bits which are 1 ignores bits which are 0
+
+// RPi B
+//#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)
+// RPi B+ => led 47
+#define LED_INIT() do { unsigned int *gpio = (unsigned int *)BCM2835_GPIO_REGS_BASE; OUT_GPIO(47);} while(0)
+#define LED_ON() do { unsigned int *gpio = (unsigned int *)BCM2835_GPIO_REGS_BASE; GPIO_CLR_EXT = 1 << (47 % 32);} while(0)
+#define LED_OFF() do { unsigned int *gpio = (unsigned int *)BCM2835_GPIO_REGS_BASE; GPIO_SET_EXT = 1 << (47 % 32);} while(0)
#else
/* default case is to print */