ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_gpio.h
Go to the documentation of this file.
1 #ifndef RUUVI_INTERFACE_GPIO_H
2 #define RUUVI_INTERFACE_GPIO_H
3 #include "ruuvi_driver_error.h"
5 #include <stdbool.h>
25 #if RI_GPIO_ENABLED
26 # define RUUVI_NRF5_SDK15_GPIO_ENABLED RUUVI_NRF5_SDK15_ENABLED
27 #endif
28 
29 #define RI_GPIO_ID_UNUSED 0xFFFF
30 
36 typedef enum
37 {
49 
53 typedef enum
54 {
55  RI_GPIO_LOW = false,
56  RI_GPIO_HIGH = true
58 
60 typedef uint16_t ri_gpio_id_t;
61 
71 
82 
89 bool ri_gpio_is_init (void);
90 
102  const ri_gpio_mode_t mode);
103 
114 
126  const ri_gpio_state_t state);
127 
141  ri_gpio_state_t * const p_state);
143 #endif
uint32_t rd_status_t
bitfield for representing errors
rd_status_t ri_gpio_uninit(void)
Uninitializes GPIO module. Call this to reset GPIO to High-Z mode. After uninitialization all GPIO pi...
bool ri_gpio_is_init(void)
return true if GPIO is init, false otherwise.
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 ...
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 ...
rd_status_t ri_gpio_init(void)
Initializes GPIO module. Call this before other GPIO functions. After initialization all GPIO pins sh...
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 impl...
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 ...
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
uint16_t ri_gpio_id_t
port<<8 + pin
ri_gpio_mode_t
@ RI_GPIO_MODE_OUTPUT_STANDARD
Push-pull output, can be written.
@ RI_GPIO_MODE_SINK_PULLUP_STANDARD
Sink only, pull-up, standard drive. I2C without external resistors.
@ RI_GPIO_MODE_INPUT_PULLUP
Input, can be read. Pulled up by internal resistor, value depends on IC.
@ RI_GPIO_MODE_OUTPUT_HIGHDRIVE
Push-pull output, can be written. Higher current drive than standard.
@ RI_GPIO_MODE_SINK_NOPULL_HIGHDRIVE
Sink only, nopull,, high-drive. I2C with strong external resistors.
@ RI_GPIO_MODE_INPUT_NOPULL
Input, can be read. No pull 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_HIGH_Z
High-impedance mode, electrically disconnected.
@ RI_GPIO_MODE_INPUT_PULLDOWN
Input, can be read. Pulled dpwn by internal resistor, value depends on IC.
ri_gpio_state_t
States of GPIO pins.
@ RI_GPIO_LOW
GPIO electrically low.
@ RI_GPIO_HIGH
GPIO electrically high.