MetaWear C++ API  0.20.0
C++ implementation of the MetaWear protocol
Classes | Enumerations | Functions | Variables
gpio.h File Reference

Interacts with the general purpose I/O pins on the board. More...

#include "sensor_common.h"

Go to the source code of this file.

Classes

struct  MblMwGpioAnalogReadParameters
 Additional parameters required for an enhanced analog read. More...
 

Enumerations

enum  MblMwGpioPullMode { MBL_MW_GPIO_PULL_MODE_UP = 0 , MBL_MW_GPIO_PULL_MODE_DOWN , MBL_MW_GPIO_PULL_MODE_NONE }
 Pin configuration types.
 
enum  MblMwGpioAnalogReadMode { MBL_MW_GPIO_ANALOG_READ_MODE_ABS_REF = 0 , MBL_MW_GPIO_ANALOG_READ_MODE_ADC }
 Read modes for analog input. More...
 
enum  MblMwGpioPinChangeType { MBL_MW_GPIO_PIN_CHANGE_TYPE_RISING = 1 , MBL_MW_GPIO_PIN_CHANGE_TYPE_FALLING , MBL_MW_GPIO_PIN_CHANGE_TYPE_ANY }
 Pin change types. More...
 

Functions

METAWEAR_API MblMwDataSignalmbl_mw_gpio_get_analog_input_data_signal (MblMwMetaWearBoard *board, uint8_t pin, MblMwGpioAnalogReadMode mode)
 Retrieves a data signal representing analog data See MblMwGpioAnalogReadMode for allowed mode values and see MetaWear datasheet for allowed pin values. More...
 
METAWEAR_API MblMwDataSignalmbl_mw_gpio_get_digital_input_data_signal (MblMwMetaWearBoard *board, uint8_t pin)
 Retrieves a data signal representing digital data See MetaWear datasheet for allowed pin values. More...
 
METAWEAR_API MblMwDataSignalmbl_mw_gpio_get_pin_monitor_data_signal (MblMwMetaWearBoard *board, uint8_t pin)
 Retrieves a data signal representing changes in digital data The monitor provides a callback anytime the value changes See MetaWear datasheet for allowed pin values. More...
 
METAWEAR_API void mbl_mw_gpio_set_pull_mode (const MblMwMetaWearBoard *board, uint8_t pin, MblMwGpioPullMode mode)
 Sets the pin pull mode A GPIO pin can be pulled up (to high voltage), pulled down (to 0V), or left floating. More...
 
METAWEAR_API void mbl_mw_gpio_set_digital_output (const MblMwMetaWearBoard *board, uint8_t pin)
 Sets the digital output state The GPIO pin is set as an output pin and turned on (high voltage) See MetaWear datasheet for allowed pin values. More...
 
METAWEAR_API void mbl_mw_gpio_clear_digital_output (const MblMwMetaWearBoard *board, uint8_t pin)
 Clears the digital output state The GPIO pin is set as an output pin and turned off (0 voltage) See MetaWear datasheet for allowed pin values. More...
 
METAWEAR_API void mbl_mw_gpio_set_pin_change_type (const MblMwMetaWearBoard *board, uint8_t pin, MblMwGpioPinChangeType type)
 Sets the pin change type to monitor The monitor provides a callback anytime the value changes by MblMwGpioPinChangeType when pin monitoring is on See MblMwGpioPinChangeType for allowed type values and see MetaWear datasheet for allowed pin values. More...
 
METAWEAR_API void mbl_mw_gpio_start_pin_monitoring (const MblMwMetaWearBoard *board, uint8_t pin)
 Start pin monitoring. More...
 
METAWEAR_API void mbl_mw_gpio_stop_pin_monitoring (const MblMwMetaWearBoard *board, uint8_t pin)
 Stop pin monitoring. More...
 

Variables

const uint8_t MBL_MW_GPIO_UNUSED_PIN = 0xff
 Pin value indicating the pin setting is not used.
 

Detailed Description

Interacts with the general purpose I/O pins on the board.

Enumeration Type Documentation

◆ MblMwGpioAnalogReadMode

Read modes for analog input.

Enumerator
MBL_MW_GPIO_ANALOG_READ_MODE_ABS_REF 

Read input voltage as an absolute reference.

MBL_MW_GPIO_ANALOG_READ_MODE_ADC 

Read input voltage as a supply ratio.

◆ MblMwGpioPinChangeType

Pin change types.

Enumerator
MBL_MW_GPIO_PIN_CHANGE_TYPE_RISING 

Notify on rising edge of a change.

MBL_MW_GPIO_PIN_CHANGE_TYPE_FALLING 

Notify on falling edge of a change.

MBL_MW_GPIO_PIN_CHANGE_TYPE_ANY 

Notify on any edge of a change.

Function Documentation

◆ mbl_mw_gpio_clear_digital_output()

METAWEAR_API void mbl_mw_gpio_clear_digital_output ( const MblMwMetaWearBoard board,
uint8_t  pin 
)

Clears the digital output state The GPIO pin is set as an output pin and turned off (0 voltage) See MetaWear datasheet for allowed pin values.

Parameters
boardBoard the pin is on
pinGPIO pin to clear

◆ mbl_mw_gpio_get_analog_input_data_signal()

METAWEAR_API MblMwDataSignal* mbl_mw_gpio_get_analog_input_data_signal ( MblMwMetaWearBoard board,
uint8_t  pin,
MblMwGpioAnalogReadMode  mode 
)

Retrieves a data signal representing analog data See MblMwGpioAnalogReadMode for allowed mode values and see MetaWear datasheet for allowed pin values.

Parameters
boardBoard to receive data from
pinGPIO pin to read
modeRead mode to use UINT32 is return signal data type

◆ mbl_mw_gpio_get_digital_input_data_signal()

METAWEAR_API MblMwDataSignal* mbl_mw_gpio_get_digital_input_data_signal ( MblMwMetaWearBoard board,
uint8_t  pin 
)

Retrieves a data signal representing digital data See MetaWear datasheet for allowed pin values.

Parameters
boardBoard to receive data from
pinGPIO pin to read UINT32 is return signal data type

◆ mbl_mw_gpio_get_pin_monitor_data_signal()

METAWEAR_API MblMwDataSignal* mbl_mw_gpio_get_pin_monitor_data_signal ( MblMwMetaWearBoard board,
uint8_t  pin 
)

Retrieves a data signal representing changes in digital data The monitor provides a callback anytime the value changes See MetaWear datasheet for allowed pin values.

Parameters
boardBoard to receive data from
pinGPIO pin to monitor UINT32 is return signal data type

◆ mbl_mw_gpio_set_digital_output()

METAWEAR_API void mbl_mw_gpio_set_digital_output ( const MblMwMetaWearBoard board,
uint8_t  pin 
)

Sets the digital output state The GPIO pin is set as an output pin and turned on (high voltage) See MetaWear datasheet for allowed pin values.

Parameters
boardBoard the pin is on
pinGPIO pin to set

◆ mbl_mw_gpio_set_pin_change_type()

METAWEAR_API void mbl_mw_gpio_set_pin_change_type ( const MblMwMetaWearBoard board,
uint8_t  pin,
MblMwGpioPinChangeType  type 
)

Sets the pin change type to monitor The monitor provides a callback anytime the value changes by MblMwGpioPinChangeType when pin monitoring is on See MblMwGpioPinChangeType for allowed type values and see MetaWear datasheet for allowed pin values.

Parameters
boardBoard the pin is on
pinGPIO pin to set
typeChange type to monitor

◆ mbl_mw_gpio_set_pull_mode()

METAWEAR_API void mbl_mw_gpio_set_pull_mode ( const MblMwMetaWearBoard board,
uint8_t  pin,
MblMwGpioPullMode  mode 
)

Sets the pin pull mode A GPIO pin can be pulled up (to high voltage), pulled down (to 0V), or left floating.

See MblMwGpioPullMode for allowed mode values

Parameters
boardBoard the pin is on
pinGPIO pin to modify
modeNew pull mode

◆ mbl_mw_gpio_start_pin_monitoring()

METAWEAR_API void mbl_mw_gpio_start_pin_monitoring ( const MblMwMetaWearBoard board,
uint8_t  pin 
)

Start pin monitoring.

Parameters
boardBoard the pin is on
pinGPIO pin to monitor

◆ mbl_mw_gpio_stop_pin_monitoring()

METAWEAR_API void mbl_mw_gpio_stop_pin_monitoring ( const MblMwMetaWearBoard board,
uint8_t  pin 
)

Stop pin monitoring.

Parameters
boardBoard the pin is on
pinGPIO pin to stop monitoring