stm32f0: stm32f1: led: initial implementation

master
S.J.R. van Schaik 7 years ago
parent ce71976939
commit a5dc77550d
  1. 10
      include/led.h
  2. 1
      source/platform/stm32f0/Makefile
  3. 31
      source/platform/stm32f0/led.c
  4. 1
      source/platform/stm32f1/Makefile
  5. 31
      source/platform/stm32f1/led.c

@ -0,0 +1,10 @@
#pragma once
struct led {
uint32_t port;
uint32_t pin;
int invert;
};
void led_enable(struct led *led);
void led_disable(struct led *led);

@ -4,6 +4,7 @@ obj-y += source/platform/usart.o
obj-y += source/platform/stm32f0/alarm.o
obj-y += source/platform/stm32f0/buzzer.o
obj-y += source/platform/stm32f0/gpio.o
obj-y += source/platform/stm32f0/led.o
obj-y += source/platform/stm32f0/rcc.o
obj-y += source/platform/stm32f0/rtc.o
obj-y += source/platform/stm32f0/spi.o

@ -0,0 +1,31 @@
#include <libopencm3/stm32/gpio.h>
#include <led.h>
#include <macros.h>
struct led leds[] = {
{ GPIOC, GPIO8, 0 },
};
size_t nleds = count_of(leds);
void led_enable(struct led *led)
{
if (!led)
return;
if (led->invert)
gpio_clear(led->port, led->pin);
else
gpio_set(led->port, led->pin);
}
void led_disable(struct led *led)
{
if (!led)
return;
if (led->invert)
gpio_set(led->port, led->pin);
else
gpio_clear(led->port, led->pin);
}

@ -4,6 +4,7 @@ obj-y += source/platform/usart.o
obj-y += source/platform/stm32f1/alarm.o
obj-y += source/platform/stm32f1/buzzer.o
obj-y += source/platform/stm32f1/gpio.o
obj-y += source/platform/stm32f1/led.o
obj-y += source/platform/stm32f1/rcc.o
obj-y += source/platform/stm32f1/rtc.o
obj-y += source/platform/stm32f1/spi.o

@ -0,0 +1,31 @@
#include <libopencm3/stm32/gpio.h>
#include <led.h>
#include <macros.h>
struct led leds[] = {
{ GPIOB, GPIO0, 1 },
};
size_t nleds = count_of(leds);
void led_enable(struct led *led)
{
if (!led)
return;
if (led->invert)
gpio_clear(led->port, led->pin);
else
gpio_set(led->port, led->pin);
}
void led_disable(struct led *led)
{
if (!led)
return;
if (led->invert)
gpio_set(led->port, led->pin);
else
gpio_clear(led->port, led->pin);
}
Loading…
Cancel
Save