GlobLib
HAL and API libraries for MCUs and hardware.
stm32f103cb_gpio.h
Go to the documentation of this file.
1 #ifndef STM32F103CB_GPIO_H_
2 #define STM32F103CB_GPIO_H_
3 
9 #include <stdio.h>
10 #include "stm32f103cb_debug.h"
11 #include <libopencm3/stm32/rcc.h>
12 #include <libopencm3/stm32/gpio.h>
13 #include <libopencm3/cm3/nvic.h>
14 #include <libopencm3/stm32/exti.h>
15 
58 typedef enum{
59  GPIO_DI = 0x8,
60  GPIO_DO = 0x2,
61  GPIO_UART_TX = 0xB,
62  GPIO_UART_RX = 0x8,
63  GPIO_I2C = 0xF,
64  GPIO_PWM = 0xB,
65  GPIO_IC = 0x4,
66  GPIO_ADC = 0x4,
67  GPIO_SPI_OUT = 0xB,
68  GPIO_SPI_IN = 0x4,
69 }gpio_mode;
70 
75 typedef enum{
78 }gpio_state;
79 
85 typedef enum{
86  PORTA = 0x0,
87  PORTB = 0x400,
88  PORTC = 0x800,
89 }gpio_port;
90 
96 typedef enum{
100 }gpio_isr;
101 
107 typedef enum{
108 
109  PIN0 = 0x01,
110  PIN1 = 0x02,
111  PIN2 = 0x04,
112  PIN3 = 0x08,
113  PIN4 = 0x010,
114  PIN5 = 0x020,
115  PIN6 = 0x040,
116  PIN7 = 0x080,
117  PIN8 = 0x0100,
118  PIN9 = 0x200,
119  PIN10 = 0x400,
120  PIN11 = 0x800,
121  PIN12 = 0x1000,
122  PIN13 = 0x2000,
123  PIN14 = 0x4000,
124  PIN15 = 0x8000,
125 }gpio_pin;
126 
131 typedef enum{
132 
133  GPIO_BASE = 0x40010800,
134  CRL_OFFSET = 0x00,
135  CRH_OFFSET = 0x04,
136  IDR_OFFSET = 0x08,
137  ODR_OFFSET = 0x0C,
138  BSRR_OFFSET = 0x10,
139  BRR_OFFSET = 0x14,
140  LCKR_OFFSET = 0x18,
141 }gpio_mem;
142 
159 void pinHigh(gpio_port port, gpio_pin pin);
167 void pinLow(gpio_port port, gpio_pin pin);
176 void pinWrite(gpio_port port, gpio_pin pin, gpio_state state);
184 void pinToggle(gpio_port port, gpio_pin pin);
192 uint8_t pinRead(gpio_port port, gpio_pin pin);
193 
204 mcu_error GPIO_ISREnable(gpio_port port, gpio_pin pin, gpio_isr trigger, void (*handle)(void));
205 
216 #endif
Pin 3 of the port.
Pin 9 of the port.
gpio_port
GPIO ports available for the MCU.
Setup the port for digital output.
Header file for stm32f103cb DEBUG.
Setup the port for ADC.
void pinToggle(gpio_port port, gpio_pin pin)
Toggle the output of a given pin on a port.
void pinLow(gpio_port port, gpio_pin pin)
Set a given gpio pin on a port to logic low.
gpio_mem
GPIO memory address base and offsets.
gpio_state
GPIO pin states.
Pin 4 of the port.
Set the corresponding pin to logic high.
Control register low memory offset.
Pin 1 of the port.
Base memory address for GPIO peripheral.
mcu_error GPIO_ISRDisable(gpio_pin pin)
Disable interrupts on a gpio port / pin.
Setup the port for output SPI.
Port bit set/reset register.
void pinHigh(gpio_port port, gpio_pin pin)
Set a given gpio pin on a port to logic high.
Setup the port for USART receive.
Pin 0 of the port.
Setup the port for digital input.
Pin 2 of the port.
Interrupt occurs on falling edge detection.
Setup the port for USART transmit.
gpio_pin
GPIO pins available for each port.
Pin 13 of the port.
Pin 7 of the port.
Interrupt occurs on rising edge detection.
Interrupt occurs on rising and falling edge detection.
Pin 8 of the port.
Pin 6 of the port.
Port configuration lock register.
Set the corresponding pin to logic low.
Port B of the MCU.
gpio_isr
GPIO interrupt options for pins.
Pin 15 of the port.
mcu_error pinSetup(gpio_mode mode, gpio_port port, gpio_pin pin)
Setup a GPIO pin for a given function.
void pinWrite(gpio_port port, gpio_pin pin, gpio_state state)
Set a given gpio pin on a port to a logic state.
Setup the port for output PWM.
Pin 11 of the port.
Pin 5 of the port.
Setup the port for input SPI.
uint8_t pinRead(gpio_port port, gpio_pin pin)
Read the current digital value of an input pin.
Pin 14 of the port.
Port bit reset register.
Pin 10 of the port.
Setup the port for input capture.
mcu_error GPIO_ISREnable(gpio_port port, gpio_pin pin, gpio_isr trigger, void(*handle)(void))
Setup interrupts on a gpio port / pin.
Port C of the MCU.
gpio_mode
GPIO setup options.
Setup the port for I2C.
Port A of the MCU.
Port input data register.
Pin 12 of the port.
mcu_error
Error enumerators for the Debug peripheral.
Port output data register.
Control register high memory offset.