GPIO Port Driver API Reference.
More...
◆ port_read
Reads from beforehand initialized port.
- Parameters
-
[in] | port | Port driver context structure. See port_t structure definition for detailed explanation. |
- Returns
- Value read from port output state.
- Precondition
- Make sure that
port
structure has been declared and initialized beforehand. See port_t structure definition and port_init for detailed explanation.
Example
hal_port_size_t port_size_t
Definition drv_name.h:78
#define port_read
Read from port.
Definition drv_port.h:241
◆ port_init()
Initializes port driver context structure and masked GPIO pins as digital output or digital input.
- Parameters
-
[in,out] | port | Port driver context structure. See port_t structure definition for detailed explanation. |
[in] | name | Port name. See port_name_t structure definition for detailed explanation. |
[in] | mask | GPIO pin mask. See port_size_t structure definition for detailed explanation. |
[in] | direction | GPIO pin direction. See pin_direction_t structure definition for detailed explanation. |
- Returns
- The function can return one of the values defined in the port_err_t enum list.
- Precondition
- Make sure that
port
structure has been declared. See port_t structure definition for detailed explanation.
- Warning
- The following example includes pin mapping. Take into consideration that different hardware might not have the same pins. Make sure to accommodate pin name based on your hardware specifics.
Example
} else {
}
@ PORT_SUCCESS
Definition drv_port.h:59
@ PIN_DIRECTION_DIGITAL_OUTPUT
Definition drv_port.h:69
err_t port_init(port_t *port, port_name_t name, port_size_t mask, pin_direction_t direction)
Initialize GPIO port.
Port driver context structure, consisted of the following fields :
Definition drv_port.h:82
◆ port_read_input()
Reads from beforehand initialized port.
- Parameters
-
[in] | port | Port driver context structure. See port_t structure definition for detailed explanation. |
- Returns
- Value read from port input state.
- Precondition
- Make sure that
port
structure has been declared and initialized beforehand. See port_t structure definition and port_init for detailed explanation.
Example
port_size_t port_read_input(port_t *port)
Read from port.
◆ port_read_output()
Reads from beforehand initialized port.
- Parameters
-
[in] | port | Port driver context structure. See port_t structure definition for detailed explanation. |
- Returns
- Value read from port output state.
- Precondition
- Make sure that
port
structure has been declared and initialized beforehand. See port_t structure definition and port_init for detailed explanation.
Example
port_size_t port_read_output(port_t *port)
Read from port.
◆ port_write()
Writes value
to beforehand initialized port.
- Parameters
-
[in] | port | Port driver context structure. See port_t structure definition for detailed explanation. |
[in] | value | Bit map to write on port. See port_size_t structure definition for detailed explanation. |
- Returns
- The function can return one of the values defined in the port_err_t enum list.
- Precondition
- Make sure that
port
structure has been declared and initialized beforehand. See port_t structure definition and port_init for detailed explanation.
Example
} else {
}
err_t port_write(port_t *port, port_size_t value)
Write to port.