TUKS MCU Introductory course / TUKS-COURSE-2-LED
Committer:
elmot
Date:
Fri Feb 24 21:06:51 2017 +0000
Revision:
0:a9bbfbd216e8
Child:
2:8c4e755038ce
Two-Leds-Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 0:a9bbfbd216e8 1 #define USE_STM32L476G_DISCO_REVC
elmot 0:a9bbfbd216e8 2 #include "stm32l476g_discovery.h"
elmot 0:a9bbfbd216e8 3 #include "stm32l4xx_hal.h"
elmot 0:a9bbfbd216e8 4
elmot 0:a9bbfbd216e8 5
elmot 0:a9bbfbd216e8 6 // main() runs in its own thread in the OS
elmot 0:a9bbfbd216e8 7 // (note the calls to wait below for delays)
elmot 0:a9bbfbd216e8 8 int main() {
elmot 0:a9bbfbd216e8 9
elmot 0:a9bbfbd216e8 10 LED4_GPIO_CLK_ENABLE();
elmot 0:a9bbfbd216e8 11 LED5_GPIO_CLK_ENABLE();
elmot 0:a9bbfbd216e8 12
elmot 0:a9bbfbd216e8 13 GPIO_InitTypeDef gpio;
elmot 0:a9bbfbd216e8 14 gpio.Mode = GPIO_MODE_OUTPUT_PP;
elmot 0:a9bbfbd216e8 15 gpio.Pull = GPIO_NOPULL;
elmot 0:a9bbfbd216e8 16 gpio.Speed = GPIO_SPEED_FREQ_LOW;
elmot 0:a9bbfbd216e8 17 gpio.Pin = LED4_PIN;
elmot 0:a9bbfbd216e8 18 HAL_GPIO_Init(LED4_GPIO_PORT, &gpio);
elmot 0:a9bbfbd216e8 19
elmot 0:a9bbfbd216e8 20 gpio.Pin = LED5_PIN;
elmot 0:a9bbfbd216e8 21 HAL_GPIO_Init(LED5_GPIO_PORT, &gpio);
elmot 0:a9bbfbd216e8 22
elmot 0:a9bbfbd216e8 23 while (1) {
elmot 0:a9bbfbd216e8 24 HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN);
elmot 0:a9bbfbd216e8 25 HAL_Delay(300);
elmot 0:a9bbfbd216e8 26 HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN);
elmot 0:a9bbfbd216e8 27 }
elmot 0:a9bbfbd216e8 28 }
elmot 0:a9bbfbd216e8 29