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

main.c

Committer:
elmot
Date:
2017-02-24
Revision:
0:a9bbfbd216e8
Child:
2:8c4e755038ce

File content as of revision 0:a9bbfbd216e8:

#define USE_STM32L476G_DISCO_REVC
#include "stm32l476g_discovery.h"
#include "stm32l4xx_hal.h"


// main() runs in its own thread in the OS
// (note the calls to wait below for delays)
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);
    }
}