|
GlobLib
HAL and API libraries for MCUs and hardware.
|
This module contains low level functions GPIO access. More...
Files | |
| file | attiny13a_gpio.h |
| Header file for attiny13a GPIO. | |
Enumerations |
Functions | |
| mcu_error | pinSetup (gpio_mode mode, gpio_port port, gpio_pin pin) |
| Setup a GPIO pin for a given function. More... | |
| void | pinHigh (gpio_port port, gpio_pin pin) |
| Set a given gpio pin on a port to logic high. More... | |
| void | pinLow (gpio_port port, gpio_pin pin) |
| Set a given gpio pin on a port to logic low. More... | |
| void | pinWrite (gpio_port port, gpio_pin pin, gpio_state state) |
| Set a given gpio pin on a port to a logic state. More... | |
| void | pinToggle (gpio_port port, gpio_pin pin) |
| Toggle the output of a given pin on a port. More... | |
| uint8_t | pinRead (gpio_port port, gpio_pin pin) |
| Read the current digital value of an input pin. More... | |
| mcu_error | GPIO_ISREnable (gpio_port port, gpio_pin pin, gpio_isr trigger, void(*handle)(void)) |
| Setup interrupts on a gpio port / pin. More... | |
| mcu_error | GPIO_ISRDisable (gpio_pin pin) |
| Disable interrupts on a gpio port / pin. More... | |
This module contains low level functions GPIO access.
The attiny13a only has a single GPIO port, port B, with pins numbered 0 - 5. Pin 5 is used for the reset (active low). To use this pin as a regular GPIO the correct fuses need to be set in the Makefile.
| enum gpio_isr |
GPIO interrupt options for pins.
corresponds with the memory address offset used.
Definition at line 104 of file attiny13a_gpio.h.
| enum gpio_mode |
GPIO setup options.
These values are used when setting up the pin for use.
Definition at line 65 of file attiny13a_gpio.h.
| enum gpio_pin |
GPIO pins available for each port.
These macros are used to access the hardware pins for each port. Each hexidecimal number corresponds with the memory address offset used.
| Enumerator | |
|---|---|
| PIN0 |
Pin 0 of the port. |
| PIN1 |
Pin 1 of the port. |
| PIN2 |
Pin 2 of the port. |
| PIN3 |
Pin 3 of the port. |
| PIN4 |
Pin 4 of the port. |
| PIN5 |
Pin 5 of the port. |
Definition at line 116 of file attiny13a_gpio.h.
| enum gpio_port |
GPIO ports available for the MCU.
There is only one port available on the Attiny13a. This macro is used for combatability with other MCU
| Enumerator | |
|---|---|
| PORTB |
Port B of the MCU. |
Definition at line 93 of file attiny13a_gpio.h.
| enum gpio_state |
GPIO pin states.
These values are used when writing a value to a pin with pinWrite().
| Enumerator | |
|---|---|
| GPIO_LOW |
Set the corresponding pin to logic low. |
| GPIO_HIGH |
Set the corresponding pin to logic high. |
Definition at line 82 of file attiny13a_gpio.h.
Disable interrupts on a gpio port / pin.
This function clears all previous setting of the interrupt.
| pin | The pin of the port, defined by gpio_pin |
Setup interrupts on a gpio port / pin.
The MCU can only support one external interrupt. This interrupt is called for every pin which has a mask enabled. Good stradegy is to test which pin could meet the intterupt condition in the main program.
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
| trigger | The interrupt trigger, define by gpio_isr |
| handle | Pointer to the function to be called on interrupt event. |
Set a given gpio pin on a port to logic high.
Pin must be set for digital output to use this function
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
Definition at line 47 of file attiny13a_gpio.c.
Set a given gpio pin on a port to logic low.
Pin must be set for digital output to use this function
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
Definition at line 53 of file attiny13a_gpio.c.
Read the current digital value of an input pin.
Pin must be set for digital input to use this function
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
Definition at line 78 of file attiny13a_gpio.c.
Setup a GPIO pin for a given function.
This function is also employed by other modules to configure pins and ports.
| mode | The mode for the pin to operate, defined by gpio_mode |
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
Definition at line 24 of file attiny13a_gpio.c.
Toggle the output of a given pin on a port.
Pin must be set for digital output to use this function
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
Definition at line 72 of file attiny13a_gpio.c.
| void pinWrite | ( | gpio_port | port, |
| gpio_pin | pin, | ||
| gpio_state | state | ||
| ) |
Set a given gpio pin on a port to a logic state.
Pin must be set for digital output to use this function
| state | The state to set the pin to, defined by gpio_state |
| port | The port of the MCU, defined by gpio_port |
| pin | The pin of the port, defined by gpio_pin |
Definition at line 59 of file attiny13a_gpio.c.