libyggdrasil  v1.0.0
gpio.h
Go to the documentation of this file.
1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * _____.___. .___ .__.__ *
3  * \__ | | ____ ____ __| _/___________ _____|__| | *
4  * / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5  * \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6  * / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7  * \/ /_____//_____/ \/ \/ \/ *
8  * - Midgard - *
9  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10  * This software can be used by students and other personal of the *
11  * Bern University of Applied Sciences under the terms of the MIT *
12  * license. *
13  * For other persons this software is under the terms of the GNU *
14  * General Public License version 2. *
15  * *
16  * Copyright © 2021, Bern University of Applied Sciences. *
17  * All rights reserved. *
18  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 #include <c/common/types.h>
27 
28 #include <stm32f7xx_hal.h>
29 
30 #define LOW_ACTIVE true
31 #define HIGH_ACTIVE false
32 
36 typedef GPIO_TypeDef* port_t;
37 
41 typedef u8 pin_t;
42 
46 typedef struct {
49  bool lowActive;
50 } gpio_t;
51 
59 
67 
75 
82 C_LINKAGE void yggdrasil_GPIO_Set(gpio_t gpio, bool state);
83 
90 
100 
110 C_LINKAGE void yggdrasil_GPIO_SetMultiple(port_t port, u8 from, u8 to, u16 value);
gpio_t::port
port_t port
Definition: gpio.h:47
types.h
Commonly used type definitions and helper templates.
u16
uint16_t u16
Definition: types.h:37
u8
uint8_t u8
Unsigned integer definitions.
Definition: types.h:36
port_t
GPIO_TypeDef * port_t
GPIO port type.
Definition: gpio.h:36
yggdrasil_GPIO_SetMultiple
C_LINKAGE void yggdrasil_GPIO_SetMultiple(port_t port, u8 from, u8 to, u16 value)
Set multiple GPIO states.
Definition: gpio.cpp:69
yggdrasil_GPIO_Get
C_LINKAGE bool yggdrasil_GPIO_Get(gpio_t gpio)
Get GPIO state.
Definition: gpio.cpp:86
yggdrasil_GPIO_Toggle
C_LINKAGE void yggdrasil_GPIO_Toggle(gpio_t gpio)
Toggle GPIO.
Definition: gpio.cpp:109
yggdrasil_GPIO_GetMultiple
C_LINKAGE u16 yggdrasil_GPIO_GetMultiple(port_t port, u8 from, u8 to)
Get multiple GPIO states.
Definition: gpio.cpp:63
gpio_t::pin
pin_t pin
Definition: gpio.h:48
yggdrasil_GPIO_Init
bool yggdrasil_GPIO_Init(gpio_t gpio)
GPIO initialization.
Definition: gpio.cpp:44
gpio_t
GPIO handle type.
Definition: gpio.h:34
pin_t
u8 pin_t
GPIO pin type.
Definition: gpio.h:41
C_LINKAGE
#define C_LINKAGE
Definition: attributes.h:43
yggdrasil_GPIO_Deinit
C_LINKAGE bool yggdrasil_GPIO_Deinit(gpio_t gpio)
GPIO deinitialization.
Definition: gpio.cpp:55
yggdrasil_GPIO_Set
C_LINKAGE void yggdrasil_GPIO_Set(gpio_t gpio, bool state)
Set GPIO state.
Definition: gpio.cpp:99