master
Ondřej Hruška 9 years ago
parent 6eb62a809f
commit f18e967dc4
  1. 1
      Makefile
  2. 22
      blink.c
  3. 12
      blink.h
  4. 20
      main.c
  5. 6
      proj.pro
  6. 4
      utils/timebase.c

@ -21,6 +21,7 @@ OBJS += utils/usart.o
OBJS += utils/timebase.o
OBJS += utils/debounce.o
OBJS += init.o
OBJS += blink.o
################################################################

@ -0,0 +1,22 @@
#include "blink.h"
#include "utils/timebase.h"
void green_toggle(void) { GPIOC_ODR ^= BIT9; }
void green_off(void) { GPIOC_ODR &= ~BIT9; }
void green_on(void) { GPIOC_ODR |= BIT9; }
void blue_toggle(void) { GPIOC_ODR ^= BIT8; }
void blue_on(void) { GPIOC_ODR |= BIT8; }
void blue_off(void) { GPIOC_ODR &= ~BIT8; }
void blink_green(void)
{
green_on();
schedule_task(green_off, 250);
}
void blink_blue(void)
{
blue_on();
schedule_task(blue_off, 250);
}

@ -0,0 +1,12 @@
#pragma once
void green_toggle(void);
void green_on(void);
void green_off(void);
void blue_toggle(void);
void blue_on(void);
void blue_off(void);
void blink_green(void);
void blink_blue(void);

@ -5,19 +5,8 @@
#include "utils/debounce.h"
#include "init.h"
#include "blink.h"
void blink_green(void)
{
GPIOC_ODR ^= BIT9;
}
void blink_blue(void)
{
GPIOC_ODR ^= BIT8;
}
void blue_on(void) { GPIOC_ODR |= BIT8; }
void blue_off(void) { GPIOC_ODR &= ~BIT8; }
// called every 1s
@ -35,11 +24,8 @@ void SystemInit(void)
init_gpios();
init_usart();
register_periodic_task(blink_green, 1000);
//register_periodic_task(blink_blue, 1000);
register_periodic_task(say_hello, 1000);
register_debounced_pin(GPIOA, 0, blue_on, blue_off);
register_periodic_task(green_toggle, 1000);
register_periodic_task(blink_blue, 5000);
}

@ -27,7 +27,8 @@ SOURCES += \
utils/gpio.c \
utils/timebase.c \
utils/usart.c \
utils/debounce.c
utils/debounce.c \
blink.c
HEADERS += \
lib/common.h \
@ -45,5 +46,6 @@ HEADERS += \
utils/gpio.h \
utils/timebase.h \
utils/usart.h \
utils/debounce.h
utils/debounce.h \
blink.h

@ -5,7 +5,7 @@ volatile uint32_t TIME_MS;
// --- time scheduler ---
#define PERIODIC_TASK_COUNT 5
#define PERIODIC_TASK_COUNT 10
typedef struct {
/** User callback */
@ -22,7 +22,7 @@ static periodic_task_t periodic_tasks[PERIODIC_TASK_COUNT];
// --- future calls ---
#define FUTURE_TASK_COUNT 5
#define FUTURE_TASK_COUNT 10
typedef struct {
/** 1 for active tasks */
bool active;

Loading…
Cancel
Save