aboutsummaryrefslogtreecommitdiff
path: root/system-clock/src/gpio.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2018-01-16 00:23:35 -0700
committerJosh Rahm <joshuarahm@gmail.com>2018-01-16 00:23:35 -0700
commitedec50e6a918359190f8ca34b2148e3a3c637e40 (patch)
tree39641126769cbf8bfc29bdca503ab23a3801e206 /system-clock/src/gpio.c
parentb679becb9d09b6e74bf1412e98132504f8467c2b (diff)
downloadstm32l4-edec50e6a918359190f8ca34b2148e3a3c637e40.tar.gz
stm32l4-edec50e6a918359190f8ca34b2148e3a3c637e40.tar.bz2
stm32l4-edec50e6a918359190f8ca34b2148e3a3c637e40.zip
Format all files and add a clang-format file.
Diffstat (limited to 'system-clock/src/gpio.c')
-rw-r--r--system-clock/src/gpio.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/system-clock/src/gpio.c b/system-clock/src/gpio.c
index f79f233..2404398 100644
--- a/system-clock/src/gpio.c
+++ b/system-clock/src/gpio.c
@@ -5,31 +5,22 @@
* 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)
+ __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)
+ __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
- };
+ return (gpio_output_pin_t){.gpio_port = gpio_port, .pin = pin};
}
-void set_gpio_output_pin(
- gpio_output_pin_t pin,
- bool onoff)
+void set_gpio_output_pin(gpio_output_pin_t pin, bool onoff)
{
if (onoff) {
pin.gpio_port->output_r |= 1 << pin.pin;
@@ -38,10 +29,9 @@ void set_gpio_output_pin(
}
}
-#define GPIO_PORTS_BASE_ADDR ((uint32_t)0x48000000)
+#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));
+ return (__IO gpio_port_t*)(GPIO_PORTS_BASE_ADDR + (gpio_port_number * 0x400));
}