Firmware SDK
twr_gpio

Driver for general purpose input/output. More...

Enumerations

enum  twr_gpio_channel_t {
  TWR_GPIO_P0 = 0,
  TWR_GPIO_P1 = 1,
  TWR_GPIO_P2 = 2,
  TWR_GPIO_P3 = 3,
  TWR_GPIO_P4 = 4,
  TWR_GPIO_P5 = 5,
  TWR_GPIO_P6 = 6,
  TWR_GPIO_P7 = 7,
  TWR_GPIO_P8 = 8,
  TWR_GPIO_P9 = 9,
  TWR_GPIO_P10 = 10,
  TWR_GPIO_P11 = 11,
  TWR_GPIO_P12 = 12,
  TWR_GPIO_P13 = 13,
  TWR_GPIO_P14 = 14,
  TWR_GPIO_P15 = 15,
  TWR_GPIO_P16 = 16,
  TWR_GPIO_P17 = 17,
  TWR_GPIO_LED = 18,
  TWR_GPIO_BUTTON = 19,
  TWR_GPIO_INT = 20,
  TWR_GPIO_SCL0 = 21,
  TWR_GPIO_SDA0 = 22
}
 GPIO channels. More...
 
enum  twr_gpio_pull_t {
  TWR_GPIO_PULL_NONE = 0,
  TWR_GPIO_PULL_UP = 1,
  TWR_GPIO_PULL_DOWN = 2
}
 GPIO pull-up/pull-down setting. More...
 
enum  twr_gpio_mode_t {
  TWR_GPIO_MODE_INPUT = 0,
  TWR_GPIO_MODE_OUTPUT = 1,
  TWR_GPIO_MODE_ALTERNATE = 2,
  TWR_GPIO_MODE_ANALOG = 3,
  TWR_GPIO_MODE_OUTPUT_OD = 4,
  TWR_GPIO_MODE_ALTERNATE_0 = (0 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_1 = (1 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_2 = (2 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_3 = (3 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_4 = (4 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_5 = (5 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_6 = (6 << 4) | 2,
  TWR_GPIO_MODE_ALTERNATE_7 = (7 << 4) | 2
}
 GPIO mode of operation. More...
 

Functions

void twr_gpio_init (twr_gpio_channel_t channel)
 Initialize GPIO channel. More...
 
void twr_gpio_set_pull (twr_gpio_channel_t channel, twr_gpio_pull_t pull)
 Set pull-up/pull-down configuration for GPIO channel. More...
 
twr_gpio_pull_t twr_gpio_get_pull (twr_gpio_channel_t channel)
 Get pull-up/pull-down configuration for GPIO channel. More...
 
void twr_gpio_set_mode (twr_gpio_channel_t channel, twr_gpio_mode_t mode)
 Set mode of operation for GPIO channel. More...
 
twr_gpio_mode_t twr_gpio_get_mode (twr_gpio_channel_t channel)
 Get mode of operation for GPIO channel. More...
 
int twr_gpio_get_input (twr_gpio_channel_t channel)
 Get input state for GPIO channel. More...
 
void twr_gpio_set_output (twr_gpio_channel_t channel, int state)
 Set output state for GPIO channel. More...
 
int twr_gpio_get_output (twr_gpio_channel_t channel)
 Get output state for GPIO channel. More...
 
void twr_gpio_toggle_output (twr_gpio_channel_t channel)
 Toggle output state for GPIO channel. More...
 

Detailed Description

Driver for general purpose input/output.

Enumeration Type Documentation

◆ twr_gpio_channel_t

GPIO channels.

Enumerator
TWR_GPIO_P0 

GPIO channel P0, A0, TXD0.

TWR_GPIO_P1 

GPIO channel P1, A1, RXD0.

TWR_GPIO_P2 

GPIO channel P2, A2, TXD1.

TWR_GPIO_P3 

GPIO channel P3, A3, RXD1.

TWR_GPIO_P4 

GPIO channel P4, A4, DAC0.

TWR_GPIO_P5 

GPIO channel P5, A5, DAC1.

TWR_GPIO_P6 

GPIO channel P6.

TWR_GPIO_P7 

GPIO channel P7, A6.

TWR_GPIO_P8 

GPIO channel P8.

TWR_GPIO_P9 

GPIO channel P9.

TWR_GPIO_P10 

GPIO channel P10, RXD2.

TWR_GPIO_P11 

GPIO channel P11, TXD2.

TWR_GPIO_P12 

GPIO channel P12, MISO.

TWR_GPIO_P13 

GPIO channel P13, MOSI.

TWR_GPIO_P14 

GPIO channel P14, SCLK.

TWR_GPIO_P15 

GPIO channel P15, CS.

TWR_GPIO_P16 

GPIO channel P16, SCL1.

TWR_GPIO_P17 

GPIO channel P17, SDA1.

TWR_GPIO_LED 

GPIO channel LED.

TWR_GPIO_BUTTON 

GPIO channel BUTTON.

TWR_GPIO_INT 

GPIO channel INT.

TWR_GPIO_SCL0 

GPIO channel SCL0.

TWR_GPIO_SDA0 

GPIO channel SDA0.

Definition at line 12 of file twr_gpio.h.

◆ twr_gpio_mode_t

GPIO mode of operation.

Enumerator
TWR_GPIO_MODE_INPUT 

GPIO channel operates as input.

TWR_GPIO_MODE_OUTPUT 

GPIO channel operates as output.

TWR_GPIO_MODE_ALTERNATE 

GPIO channel operates in alternate mode.

TWR_GPIO_MODE_ANALOG 

GPIO channel operates in analog mode.

TWR_GPIO_MODE_OUTPUT_OD 

GPIO channel operates as open-drain output.

TWR_GPIO_MODE_ALTERNATE_0 

GPIO channel operates in alternate mode AF0.

TWR_GPIO_MODE_ALTERNATE_1 

GPIO channel operates in alternate mode AF1.

TWR_GPIO_MODE_ALTERNATE_2 

GPIO channel operates in alternate mode AF2.

TWR_GPIO_MODE_ALTERNATE_3 

GPIO channel operates in alternate mode AF3.

TWR_GPIO_MODE_ALTERNATE_4 

GPIO channel operates in alternate mode AF4.

TWR_GPIO_MODE_ALTERNATE_5 

GPIO channel operates in alternate mode AF5.

TWR_GPIO_MODE_ALTERNATE_6 

GPIO channel operates in alternate mode AF6.

TWR_GPIO_MODE_ALTERNATE_7 

GPIO channel operates in alternate mode AF7.

Definition at line 102 of file twr_gpio.h.

◆ twr_gpio_pull_t

GPIO pull-up/pull-down setting.

Enumerator
TWR_GPIO_PULL_NONE 

GPIO channel has no pull-up/pull-down.

TWR_GPIO_PULL_UP 

GPIO channel has pull-up.

TWR_GPIO_PULL_DOWN 

GPIO channel has pull-down.

Definition at line 87 of file twr_gpio.h.

Function Documentation

◆ twr_gpio_get_input()

int twr_gpio_get_input ( twr_gpio_channel_t  channel)

Get input state for GPIO channel.

Parameters
channelGPIO channel
Returns
state Input state

Definition at line 463 of file twr_gpio.c.

Referenced by twr_button_set_hold_time(), twr_module_battery_is_present(), twr_module_encoder_is_present(), twr_module_lcd_get_button_driver(), twr_module_sensor_get_input(), twr_pyq1648_set_blank_period(), and twr_switch_set_pull_advance_time().

Here is the caller graph for this function:

◆ twr_gpio_get_mode()

twr_gpio_mode_t twr_gpio_get_mode ( twr_gpio_channel_t  channel)

Get mode of operation for GPIO channel.

Parameters
[in]channelGPIO channel
Returns
Mode of operation

Definition at line 426 of file twr_gpio.c.

◆ twr_gpio_get_output()

int twr_gpio_get_output ( twr_gpio_channel_t  channel)

Get output state for GPIO channel.

Parameters
[in]channelGPIO channel
Returns
Output state

Definition at line 475 of file twr_gpio.c.

Referenced by twr_module_sensor_get_output().

Here is the caller graph for this function:

◆ twr_gpio_get_pull()

twr_gpio_pull_t twr_gpio_get_pull ( twr_gpio_channel_t  channel)

Get pull-up/pull-down configuration for GPIO channel.

Parameters
[in]channelGPIO channel
Returns
Pull-up/pull-down configuration

Definition at line 361 of file twr_gpio.c.

Referenced by twr_module_sensor_get_pull().

Here is the caller graph for this function:

◆ twr_gpio_init()

◆ twr_gpio_set_mode()

void twr_gpio_set_mode ( twr_gpio_channel_t  channel,
twr_gpio_mode_t  mode 
)

Set mode of operation for GPIO channel.

Parameters
[in]channelGPIO channel
[in]modeDesired mode of operation

Definition at line 367 of file twr_gpio.c.

Referenced by twr_button_init(), twr_hc_sr04_init(), twr_i2c_deinit(), twr_i2c_init(), twr_led_init(), twr_module_battery_is_present(), twr_module_encoder_deinit(), twr_module_encoder_is_present(), twr_module_lcd_get_button_driver(), twr_module_power_init(), twr_module_sensor_set_mode(), twr_pwm_disable(), twr_pyq1648_set_blank_period(), twr_rf_ook_init(), twr_switch_init(), twr_td1207r_init(), twr_uart_deinit(), twr_uart_init(), and twr_wssfm10r1at_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gpio_set_output()

void twr_gpio_set_output ( twr_gpio_channel_t  channel,
int  state 
)

Set output state for GPIO channel.

Parameters
[in]channelGPIO channel
[in]stateDesired output state

Definition at line 469 of file twr_gpio.c.

Referenced by twr_hc_sr04_init(), twr_module_battery_is_present(), twr_module_encoder_is_present(), twr_module_power_relay_set_state(), twr_module_sensor_set_output(), twr_pyq1648_set_blank_period(), twr_rf_ook_is_ready(), twr_td1207r_init(), twr_td1207r_send_rf_frame(), twr_wssfm10r1at_continuous_wave(), and twr_wssfm10r1at_init().

Here is the caller graph for this function:

◆ twr_gpio_set_pull()

void twr_gpio_set_pull ( twr_gpio_channel_t  channel,
twr_gpio_pull_t  pull 
)

Set pull-up/pull-down configuration for GPIO channel.

Parameters
[in]channelGPIO channel
[in]pullDesired pull-up/pull-down configuration

Definition at line 340 of file twr_gpio.c.

Referenced by twr_button_init(), twr_i2c_deinit(), twr_i2c_init(), twr_module_battery_is_present(), twr_module_encoder_is_present(), twr_module_sensor_set_pull(), twr_pyq1648_set_blank_period(), twr_switch_init(), twr_switch_set_pull_advance_time(), twr_uart_deinit(), and twr_uart_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gpio_toggle_output()

void twr_gpio_toggle_output ( twr_gpio_channel_t  channel)

Toggle output state for GPIO channel.

Parameters
[in]channelGPIO channel

Definition at line 481 of file twr_gpio.c.

Referenced by twr_module_sensor_toggle_output().

Here is the call graph for this function:
Here is the caller graph for this function: