ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_gpio.h File Reference
#include "ruuvi_driver_error.h"
#include "ruuvi_driver_enabled_modules.h"
#include <stdbool.h>

Go to the source code of this file.

Macros

#define RI_GPIO_ID_UNUSED   0xFFFF
 Enable implementation selected by application. More...
 

Typedefs

typedef uint16_t ri_gpio_id_t
 port<<8 + pin More...
 

Enumerations

enum  ri_gpio_mode_t {
  RI_GPIO_MODE_HIGH_Z , RI_GPIO_MODE_INPUT_NOPULL , RI_GPIO_MODE_INPUT_PULLUP , RI_GPIO_MODE_INPUT_PULLDOWN ,
  RI_GPIO_MODE_OUTPUT_STANDARD , RI_GPIO_MODE_OUTPUT_HIGHDRIVE , RI_GPIO_MODE_SINK_PULLUP_STANDARD , RI_GPIO_MODE_SINK_NOPULL_STANDARD ,
  RI_GPIO_MODE_SINK_PULLUP_HIGHDRIVE , RI_GPIO_MODE_SINK_NOPULL_HIGHDRIVE
}
 
enum  ri_gpio_state_t { RI_GPIO_LOW = false , RI_GPIO_HIGH = true }
 States of GPIO pins. More...
 

Functions

rd_status_t ri_gpio_init (void)
 Initializes GPIO module. Call this before other GPIO functions. After initialization all GPIO pins shall be in High-Z mode. More...
 
rd_status_t ri_gpio_uninit (void)
 Uninitializes GPIO module. Call this to reset GPIO to High-Z mode. After uninitialization all GPIO pins shall be in High-Z mode. Uninitialization can be called at any time, but behaviour is not defined if some other peripheral (i.e. SPI) is using GPIO pins. More...
 
bool ri_gpio_is_init (void)
 return true if GPIO is init, false otherwise. More...
 
rd_status_t ri_gpio_configure (const ri_gpio_id_t pin, const ri_gpio_mode_t mode)
 Configure a pin of a port into a mode. If there are several ports the platform driver must implement a conversion function from port + pin to uint8_t. More...
 
rd_status_t ri_gpio_toggle (const ri_gpio_id_t pin)
 Toggle the state of a pin of a port. If there are several ports the platform driver must implement a conversion function from port + pin to uint8_t. More...
 
rd_status_t ri_gpio_write (const ri_gpio_id_t pin, const ri_gpio_state_t state)
 Write a pin of a port into given state If there are several ports the platform driver must implement a conversion function from port + pin to uint8_t. More...
 
rd_status_t ri_gpio_read (const ri_gpio_id_t pin, ri_gpio_state_t *const p_state)
 Read state of a pin of a port into bool high If there are several ports the platform driver must implement a conversion function from port + pin to uint8_t. More...
 

Detailed Description

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2019-04-27

Interface for basic GPIO writes and reads

Definition in file ruuvi_interface_gpio.h.

Macro Definition Documentation

◆ RI_GPIO_ID_UNUSED

#define RI_GPIO_ID_UNUSED   0xFFFF

Enable implementation selected by application.

Use this value to signal that nothing should be done with this gpio, i.e. UART CTS not used.

Definition at line 29 of file ruuvi_interface_gpio.h.

Typedef Documentation

◆ ri_gpio_id_t

typedef uint16_t ri_gpio_id_t

port<<8 + pin

Definition at line 60 of file ruuvi_interface_gpio.h.

Enumeration Type Documentation

◆ ri_gpio_mode_t

GPIO modes supported by interface. If the underlying platform does not support given mode, it shall return RD_ERROR_NOT_SUPPORTED on configuration attempt.

Enumerator
RI_GPIO_MODE_HIGH_Z 

High-impedance mode, electrically disconnected.

RI_GPIO_MODE_INPUT_NOPULL 

Input, can be read. No pull resistors.

RI_GPIO_MODE_INPUT_PULLUP 

Input, can be read. Pulled up by internal resistor, value depends on IC.

RI_GPIO_MODE_INPUT_PULLDOWN 

Input, can be read. Pulled dpwn by internal resistor, value depends on IC.

RI_GPIO_MODE_OUTPUT_STANDARD 

Push-pull output, can be written.

RI_GPIO_MODE_OUTPUT_HIGHDRIVE 

Push-pull output, can be written. Higher current drive than standard.

RI_GPIO_MODE_SINK_PULLUP_STANDARD 

Sink only, pull-up, standard drive. I2C without external resistors.

RI_GPIO_MODE_SINK_NOPULL_STANDARD 

Sink only, nopull, standard drive. I2C with weak external resistors.

RI_GPIO_MODE_SINK_PULLUP_HIGHDRIVE 

Sink only, pull-up, high-drive. I2C with optional external resistors.

RI_GPIO_MODE_SINK_NOPULL_HIGHDRIVE 

Sink only, nopull,, high-drive. I2C with strong external resistors.

Definition at line 36 of file ruuvi_interface_gpio.h.

◆ ri_gpio_state_t

States of GPIO pins.

Enumerator
RI_GPIO_LOW 

GPIO electrically low.

RI_GPIO_HIGH 

GPIO electrically high.

Definition at line 53 of file ruuvi_interface_gpio.h.