[examples-v2 commit] Added code to turn on and off LED for STM32F4 Discovery Board

Chris Johns chrisj at rtems.org
Tue Jul 11 00:54:37 UTC 2017


Module:    examples-v2
Branch:    refs/tags/4.11.2
Commit:    a0c21e019ce0d218fd89b644ee6770d995ed0fdc
Changeset: http://git.rtems.org/examples-v2/commit/?id=a0c21e019ce0d218fd89b644ee6770d995ed0fdc

Author:    SteveB <sbattazzo at gmail.com>
Date:      Wed May 27 15:59:57 2015 -0500

Added code to turn on and off LED for STM32F4 Discovery Board

---

 led/led.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/led/led.h b/led/led.h
index 3fee684..9675aa2 100644
--- a/led/led.h
+++ b/led/led.h
@@ -80,6 +80,29 @@ uint8_t MPC8313_LED_Count;
 #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)
 
+#elif defined(STM32F4_FAMILY_F4XXXX)
+
+#include <bsp/io.h> //Everything we need is in io.h
+
+//STM32F4 Discovery Board, LED4: PORTD, 12
+stm32f4_gpio_config led3config =
+{
+	.fields={
+		.pin_first = STM32F4_GPIO_PIN(3, 12),
+	.pin_last = STM32F4_GPIO_PIN(3, 12),
+	.mode = STM32F4_GPIO_MODE_OUTPUT,
+	.otype = STM32F4_GPIO_OTYPE_PUSH_PULL,
+	.ospeed = STM32F4_GPIO_OSPEED_2_MHZ,
+	.pupd = STM32F4_GPIO_NO_PULL,
+	.output = 1,
+	.af = 0
+   }
+};
+
+#define LED_INIT() stm32f4_gpio_set_config(&led3config)
+#define LED_ON() stm32f4_gpio_set_output(STM32F4_GPIO_PIN(3,12), 1)
+#define LED_OFF() stm32f4_gpio_set_output(STM32F4_GPIO_PIN(3,12), 0)
+
 #else
 /* default case is to print */
 



More information about the vc mailing list