aboutsummaryrefslogtreecommitdiff
path: root/01-system-clock/src/gpio.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-24 13:46:41 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-24 13:46:41 -0700
commit93b063fedfcf7409a67df035170ea5670cad22e1 (patch)
treea23321a7465d966b1ccf196ca00e65a70c9f9110 /01-system-clock/src/gpio.c
parentb040195d31df6ad759f16ea3456471897f55daa1 (diff)
downloadstm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.tar.gz
stm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.tar.bz2
stm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.zip
Moved action to top level.
Removed old iterations of the project and moved the files from 02-usart to the root directory since that's the sole place where the action is and that subproject has outgrown its initial title.
Diffstat (limited to '01-system-clock/src/gpio.c')
-rw-r--r--01-system-clock/src/gpio.c37
1 files changed, 0 insertions, 37 deletions
diff --git a/01-system-clock/src/gpio.c b/01-system-clock/src/gpio.c
deleted file mode 100644
index 2404398..0000000
--- a/01-system-clock/src/gpio.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "gpio.h"
-#include "rcc.h"
-
-/*
- * Sets the mode of a pin on a gpio por.
- */
-void set_gpio_pin_mode(
- __IO gpio_port_t* gpio_port, gpio_pin_t pin, gpio_pin_mode_t mode)
-{
- /* Each pin has a 2-bit mode provided at bits pin#*2 and pin#*2+1 */
- gpio_port->mode_r &= ~(0x03 << pin * 2);
- gpio_port->mode_r |= mode << pin * 2;
-}
-
-gpio_output_pin_t set_gpio_pin_output(
- __IO gpio_port_t* gpio_port, gpio_pin_t pin)
-{
- set_gpio_pin_mode(gpio_port, pin, MODE_OUTPUT);
-
- return (gpio_output_pin_t){.gpio_port = gpio_port, .pin = pin};
-}
-
-void set_gpio_output_pin(gpio_output_pin_t pin, bool onoff)
-{
- if (onoff) {
- pin.gpio_port->output_r |= 1 << pin.pin;
- } else {
- pin.gpio_port->output_r &= ~(1 << pin.pin);
- }
-}
-
-#define GPIO_PORTS_BASE_ADDR ((uint32_t)0x48000000)
-__IO gpio_port_t* enable_gpio(gpio_port_number_t gpio_port_number)
-{
- RCC.ahb2en_r |= 1 << gpio_port_number; /* Enable the GPIO port. */
- return (__IO gpio_port_t*)(GPIO_PORTS_BASE_ADDR + (gpio_port_number * 0x400));
-}