Basic vanilla C boilerplate for STM32L100xC (Discovery L100C). Uses GCC. This was some class project without much practical use
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
931 B

8 years ago
#include <common.h>
#include "utils/usart.h"
#include "utils/timebase.h"
8 years ago
#include "init.h"
8 years ago
void blink_green(void)
{
GPIOC_ODR ^= BIT9;
8 years ago
}
// --- async delayed blue blink ---
bool blue_blink_pending = false;
void blue_off(void)
{
GPIOC_ODR &= ~BIT8;
blue_blink_pending = false;
}
void blink_blue(void)
{
GPIOC_ODR |= BIT8;
register_future_task(blue_off, 200);
}
// called every 1s
void say_hello(void)
{
usart_tx_string(USART3, "HELLO\r\n");
}
8 years ago
/** Called before main() */
void SystemInit(void)
{
init_clock();
init_systick();
8 years ago
init_gpios();
init_usart();
register_periodic_task(blink_green, 500);
register_periodic_task(say_hello, 1000);
8 years ago
}
int main(void)
{
int btn_c = 0;
8 years ago
while (1) {
bool btn = GPIOA_IDR & BIT0;
if (btn) {
if (btn_c++ > 20 && !blue_blink_pending) {
blue_blink_pending = true;
register_future_task(blink_blue, 1000);
}
} else {
btn_c = 0;
}
8 years ago
delay_ms(1);
8 years ago
}
}