MiraOS  1.22
Typedefs | Enumerations | Functions
mira_gpio.h File Reference

MiraOS GPIO driver. More...

#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef void(* MiraGpioCallbackType) (uint8_t port, uint8_t pin)
 Type definition for callbacks invoked by the GPIO ISRs. More...
 

Enumerations

enum  MiraGpioInterruptType { MiraGpioIrqRisingEdge = 0, MiraGpioIrqFallingEdge = 1, MiraGpioIrqBothEdges = 2 }
 GPIO edge trigger. More...
 
enum  MiraGpioPorts { MiraGpioPortA = 0, MiraGpioPortB = 1, MiraGpioPortC = 2, MiraGpioPortD = 3 }
 GPIO ports.
 
enum  MiraGpioPinMode { MiraInputPin, MiraOutputPin }
 GPIO pin mode.
 
enum  MiraGpioPullMode { MiraPullUp = 1, MiraPullDown = 2, MiraNoPull = 0 }
 GPIO pin pullup/pulldown mode.
 

Functions

void mira_gpio_init (MiraGpioPorts port, uint8_t pin, MiraGpioPinMode mode, MiraGpioPullMode pull_mode)
 Initialize a GPIO pin. More...
 
uint8_t mira_gpio_read (MiraGpioPorts port, uint8_t pin)
 Read an input pin. More...
 
void mira_gpio_set (MiraGpioPorts port, uint8_t pin)
 Set an output pin (logic high output). More...
 
void mira_gpio_clear (MiraGpioPorts port, uint8_t pin)
 Clear an output pin (logic low output). More...
 
void mira_gpio_setup_interrupt (MiraGpioPorts port, uint8_t pin, MiraGpioInterruptType irq_type, MiraGpioCallbackType callback)
 Configure an GPIO interrupt. More...
 
void mira_gpio_enable_interrupt (MiraGpioPorts port, uint8_t pin)
 Enables an GPIO interrupt. More...
 
void mira_gpio_disable_interrupt (MiraGpioPorts port, uint8_t pin)
 Disables an GPIO interrupt. More...
 

Detailed Description

MiraOS GPIO driver.

Author
LumenRadio AB
Date
5 March 2016 The MiraOS library provides functions for controlling the Mira radio module, sending/receiving messages, controlling peripherals, etc.
See also
http://docs.lumenrad.io/mira

Typedef Documentation

typedef void(* MiraGpioCallbackType) (uint8_t port, uint8_t pin)

Type definition for callbacks invoked by the GPIO ISRs.

This is the prototype of a function pointer passed to mira_gpio_setup_interrupt(). These callbacks are registered on a port/pin basis. When a GPIO port generates an interrupt, if a callback has been registered for the port/pin combination, the ISR will invoke it. The ISR will pass the port/pin as arguments in that call, so that a developer can re-use the same callback for multiple port/pin combinations

Parameters
portThe port that triggered the GPIO interrupt.
pinThe pin that triggered the interrupt
Returns
void

Enumeration Type Documentation

GPIO edge trigger.

Enumerator
MiraGpioIrqRisingEdge 

Interrupt triggers on rising edge

MiraGpioIrqFallingEdge 

Interrupt triggers on falling edge

MiraGpioIrqBothEdges 

Interrupt triggers on both rising and falling edges

Function Documentation

void mira_gpio_clear ( MiraGpioPorts  port,
uint8_t  pin 
)

Clear an output pin (logic low output).

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
Returns
void
void mira_gpio_disable_interrupt ( MiraGpioPorts  port,
uint8_t  pin 
)

Disables an GPIO interrupt.

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
Returns
void
void mira_gpio_enable_interrupt ( MiraGpioPorts  port,
uint8_t  pin 
)

Enables an GPIO interrupt.

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
Returns
void
void mira_gpio_init ( MiraGpioPorts  port,
uint8_t  pin,
MiraGpioPinMode  mode,
MiraGpioPullMode  pull_mode 
)

Initialize a GPIO pin.

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
modeInput or output
pull_modePull-up/pull-down mode
Returns
void
uint8_t mira_gpio_read ( MiraGpioPorts  port,
uint8_t  pin 
)

Read an input pin.

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
Returns
logic level at input pin
void mira_gpio_set ( MiraGpioPorts  port,
uint8_t  pin 
)

Set an output pin (logic high output).

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
Returns
void
void mira_gpio_setup_interrupt ( MiraGpioPorts  port,
uint8_t  pin,
MiraGpioInterruptType  irq_type,
MiraGpioCallbackType  callback 
)

Configure an GPIO interrupt.

If both edges are used as trigger, this will not be able to wake up processor from deep sleep. Only rising or falling edges may be used as wake-up triggers.

Parameters
portThe port where the pin is located (Port A, B, C)
pinPin number within the port
irq_typeThe interrupt type (falling, rising or both edges)
callbackThe callback function that will be invoked by the ISR
Returns
void