aboutsummaryrefslogtreecommitdiff
path: root/02-usart/src/kern/gpio/sysled.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-23 19:41:05 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-23 19:41:05 -0700
commit60b1e3055c179312eef809fe1d01f58042b64d5f (patch)
treec620b5ca1eab2d05c9396637db50d0a110328d29 /02-usart/src/kern/gpio/sysled.c
parent2a6ae24ba769892993ec7a173c564f59feb06495 (diff)
downloadstm32l4-60b1e3055c179312eef809fe1d01f58042b64d5f.tar.gz
stm32l4-60b1e3055c179312eef809fe1d01f58042b64d5f.tar.bz2
stm32l4-60b1e3055c179312eef809fe1d01f58042b64d5f.zip
Add new GPIO subsystem.
This gpio subsystem keeps track of the GPIO pins which have been reserved and takes care of the housekeeping with keeping them running. This gpio subsystem also knows which alternate functions belong to which pins, so it can automatically configure the pins for the alternate functions.
Diffstat (limited to '02-usart/src/kern/gpio/sysled.c')
-rw-r--r--02-usart/src/kern/gpio/sysled.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/02-usart/src/kern/gpio/sysled.c b/02-usart/src/kern/gpio/sysled.c
new file mode 100644
index 0000000..a728da3
--- /dev/null
+++ b/02-usart/src/kern/gpio/sysled.c
@@ -0,0 +1,14 @@
+#include "kern/gpio/sysled.h"
+
+#define SYSLED GPIO_PIN_PB3
+
+gpio_reserved_pin_t get_sysled()
+{
+ if (gpio_pin_in_use(SYSLED)) {
+ return (gpio_reserved_pin_t) { .v_ = SYSLED };
+ }
+
+ int ec;
+ gpio_pin_opts_t opts = DEFAULT_GPIO_OPTS_OUTPUT;
+ return reserve_gpio_pin(SYSLED, &opts, &ec);
+}