GlobLib
HAL and API libraries for MCUs and hardware.
attiny13a_gpio.h
Go to the documentation of this file.
1 #ifndef ATTINY13A_GPIO_H_
2 #define ATTINY13A_GPIO_H_
3 
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include "attiny13a_debug.h"
12 #include <avr/io.h>
13 #include <avr/interrupt.h>
14 
51 //These values are used as part of AVR libraries, undefine them here
52 //so they can be redefined for use with this library.
53 #undef PORTB
54 #undef PIN0
55 #undef PIN1
56 #undef PIN2
57 #undef PIN3
58 #undef PIN4
59 #undef PIN5
60 
65 typedef enum{
66  GPIO_DI = 0x8,
67  GPIO_DO = 0x2,
68  GPIO_UART_TX = 0xB,
69  GPIO_UART_RX = 0x8,
70  GPIO_I2C = 0xF,
71  GPIO_PWM = 0xB,
72  GPIO_IC = 0x4,
73  GPIO_ADC = 0x4,
74  GPIO_SPI_OUT = 0xB,
75  GPIO_SPI_IN = 0x4,
76 }gpio_mode;
77 
82 typedef enum{
85 }gpio_state;
86 
87 
93 typedef enum{
94  PORTB = 0x18 + __SFR_OFFSET,
95 }gpio_port;
96 
97 
104 typedef enum{
109 }gpio_isr;
110 
116 typedef enum{
117 
118  PIN0 = 0x00,
119  PIN1 = 0x01,
120  PIN2 = 0x02,
121  PIN3 = 0x03,
122  PIN4 = 0x04,
123  PIN5 = 0x05,
124 }gpio_pin;
125 
142 void pinHigh(gpio_port port, gpio_pin pin);
150 void pinLow(gpio_port port, gpio_pin pin);
159 void pinWrite(gpio_port port, gpio_pin pin, gpio_state state);
167 void pinToggle(gpio_port port, gpio_pin pin);
175 uint8_t pinRead(gpio_port port, gpio_pin pin);
176 
187 mcu_error GPIO_ISREnable(gpio_port port, gpio_pin pin, gpio_isr trigger, void (*handle)(void));
188 
199 #endif
Pin 3 of the port.
gpio_port
GPIO ports available for the MCU.
Setup the port for digital output.
Header file for attiny13a DEBUG.
Setup the port for ADC.
Interrupt occurs on low level.
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_state
GPIO pin states.
Pin 4 of the port.
Set the corresponding pin to logic high.
Pin 1 of the port.
mcu_error GPIO_ISRDisable(gpio_pin pin)
Disable interrupts on a gpio port / pin.
Setup the port for output SPI.
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.
Interrupt occurs on rising edge detection.
Interrupt occurs on rising and falling edge detection.
Set the corresponding pin to logic low.
Port B of the MCU.
gpio_isr
GPIO interrupt options for pins.
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 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.
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.
gpio_mode
GPIO setup options.
Setup the port for I2C.
mcu_error
Error enumerators for the Debug peripheral.