parent
ce71976939
commit
a5dc77550d
@ -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); |
@ -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); |
||||
} |
@ -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…
Reference in new issue