GPIO¶
Methods for handling digital input/output pins.
Defines¶
Name | Value | Description |
---|---|---|
MIRA_GPIO_PIN(_PORT, _PIN) |
(((_PORT) << 8) | (_PIN)) | Generate a reference to a pin, given port and pin number |
MIRA_GPIO_PIN_UNDEFINED |
((mira_gpio_pin_t ) (-1)) |
Types¶
Name | Type | Description |
---|---|---|
mira_gpio_pin_t |
uint16_t |
Reference to a given hardware pin. Contains both possible port and pin number |
Enums¶
mira_gpio_dir_t¶
Value | Description |
---|---|
MIRA_GPIO_DIR_IN | |
MIRA_GPIO_DIR_OUT |
Variables¶
Type | Name | Description |
---|---|---|
process_event_t |
mira_gpio_edge_event |
Event that will be sent to processes when edge event occurs. |
Functions¶
mira_gpio_set_dir¶
mira_status_t mira_gpio_set_dir( mira_gpio_pin_t pin, mira_gpio_dir_t dir);
Set direction of a GPIO pin
Parameters
Parameter | Description |
---|---|
pin |
GPIO pin reference |
dir |
Direction of pin |
Return
Status of the operation
mira_gpio_set_value¶
mira_status_t mira_gpio_set_value( mira_gpio_pin_t pin, mira_bool_t value);
Set value of a GPIO output pin
Parameters
Parameter | Description |
---|---|
pin |
GPIO pin reference |
value |
Value of the pin. MIRA_TRUE for high, MIRA_FALSE for low. |
Return
Status of the operation
mira_gpio_get_value¶
mira_status_t mira_gpio_get_value( mira_gpio_pin_t pin, mira_bool_t* value);
Get value of a GPIO input pin
Parameters
Parameter | Description |
---|---|
pin |
GPIO pin reference |
value |
Pointer to where to store the pin value. MIRA_TRUE for high, MIRA_FALSE for low. |
Return
Status of the operation
mira_gpio_enable_edge_event¶
mira_status_t mira_gpio_enable_edge_event( mira_gpio_pin_t pin, mira_edge_t edge);
Enable mira_gpio_edge_event
event generation on pin level transitions.
To change the edge for an already enabled pin, first call mira_gpio_disable_edge_event
for that specific pin.
Parameters
Parameter | Description |
---|---|
pin |
GPIO pin reference |
edge |
Which edge(s) to generate an event for |
Return
Status of the operation
mira_gpio_disable_edge_event¶
mira_status_t mira_gpio_disable_edge_event( mira_gpio_pin_t pin);
Disable the generation of mira_gpio_edge_event
events for a specific pin.
Parameters
Parameter | Description |
---|---|
pin |
GPIO pin reference |
Return
Status of the operation
mira_gpio_has_triggered_edge_event¶
mira_bool_t mira_gpio_has_triggered_edge_event( mira_gpio_pin_t pin);
Get and reset the edge status of a pin have triggered events since the last call to this function.
When this function is called, the status of the pin will be reset to MIRA_FALSE
.
Return
Value | Description |
---|---|
MIRA_TRUE |
The pin has triggered a mira_gpio_edge_event since the last call to this function. |
MIRA_FALSE |
The pin has not triggered a mira_gpio_edge_event since the last call to this function. |