TUKS MCU Introductory course / TUKS-COURSE-2-LED

main.c

Committer:
elmot
Date:
2017-02-24
Revision:
2:8c4e755038ce
Parent:
0:a9bbfbd216e8
Child:
3:858ea360dbbe

File content as of revision 2:8c4e755038ce:

#define USE_STM32L476G_DISCO_REVC
#include "stm32l476g_discovery.h"

// main() runs in its own thread in the OS
// (note the calls to wait below for delays)


/*************** TODO ***************
    Joystik up=> LED4 ON
    Joystik down=> LED5 ON

    Hint: Use UP_JOY_xxx definitions
*/
int main() {

    LED4_GPIO_CLK_ENABLE();
    LED5_GPIO_CLK_ENABLE();
    
    GPIO_InitTypeDef gpio;
    gpio.Mode = GPIO_MODE_OUTPUT_PP;
    gpio.Pull = GPIO_NOPULL;
    gpio.Speed = GPIO_SPEED_FREQ_LOW;
    gpio.Pin = LED4_PIN;
    HAL_GPIO_Init(LED4_GPIO_PORT, &gpio);

    gpio.Pin = LED5_PIN;
    HAL_GPIO_Init(LED5_GPIO_PORT, &gpio);

    while (1) {
        HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN);
        HAL_Delay(300);
        HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN);
    }
}