TUKS MCU Introductory course / TUKS-COURSE-2-LED
Committer:
elmot
Date:
Fri Feb 24 22:46:53 2017 +0000
Revision:
2:8c4e755038ce
Parent:
0:a9bbfbd216e8
Child:
3:858ea360dbbe
Ready to show

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
elmot 0:a9bbfbd216e8 4 // main() runs in its own thread in the OS
elmot 0:a9bbfbd216e8 5 // (note the calls to wait below for delays)
elmot 2:8c4e755038ce 6
elmot 2:8c4e755038ce 7
elmot 2:8c4e755038ce 8 /*************** TODO ***************
elmot 2:8c4e755038ce 9 Joystik up=> LED4 ON
elmot 2:8c4e755038ce 10 Joystik down=> LED5 ON
elmot 2:8c4e755038ce 11
elmot 2:8c4e755038ce 12 Hint: Use UP_JOY_xxx definitions
elmot 2:8c4e755038ce 13 */
elmot 0:a9bbfbd216e8 14 int main() {
elmot 0:a9bbfbd216e8 15
elmot 0:a9bbfbd216e8 16 LED4_GPIO_CLK_ENABLE();
elmot 0:a9bbfbd216e8 17 LED5_GPIO_CLK_ENABLE();
elmot 0:a9bbfbd216e8 18
elmot 0:a9bbfbd216e8 19 GPIO_InitTypeDef gpio;
elmot 0:a9bbfbd216e8 20 gpio.Mode = GPIO_MODE_OUTPUT_PP;
elmot 0:a9bbfbd216e8 21 gpio.Pull = GPIO_NOPULL;
elmot 0:a9bbfbd216e8 22 gpio.Speed = GPIO_SPEED_FREQ_LOW;
elmot 0:a9bbfbd216e8 23 gpio.Pin = LED4_PIN;
elmot 0:a9bbfbd216e8 24 HAL_GPIO_Init(LED4_GPIO_PORT, &gpio);
elmot 0:a9bbfbd216e8 25
elmot 0:a9bbfbd216e8 26 gpio.Pin = LED5_PIN;
elmot 0:a9bbfbd216e8 27 HAL_GPIO_Init(LED5_GPIO_PORT, &gpio);
elmot 0:a9bbfbd216e8 28
elmot 0:a9bbfbd216e8 29 while (1) {
elmot 0:a9bbfbd216e8 30 HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN);
elmot 0:a9bbfbd216e8 31 HAL_Delay(300);
elmot 0:a9bbfbd216e8 32 HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN);
elmot 0:a9bbfbd216e8 33 }
elmot 0:a9bbfbd216e8 34 }
elmot 0:a9bbfbd216e8 35