|
Firmware SDK
|
Driver for switch. More...
Macros | |
| #define | TWR_SWITCH_OPEN false |
| #define | TWR_SWITCH_CLOSE true |
Typedefs | |
| typedef struct twr_switch_t | twr_switch_t |
| State. | |
Enumerations | |
| enum | twr_switch_event_t { TWR_SWITCH_EVENT_OPENED = 0 , TWR_SWITCH_EVENT_CLOSED = 1 } |
| Callback events. More... | |
| enum | twr_switch_type_t { TWR_SWITCH_TYPE_NO = 0 , TWR_SWITCH_TYPE_NC = 1 } |
| Type. More... | |
| enum | twr_switch_pull_t { TWR_SWITCH_PULL_NONE = 0 , TWR_SWITCH_PULL_UP = 1 , TWR_SWITCH_PULL_UP_DYNAMIC = 2 , TWR_SWITCH_PULL_DOWN = 3 , TWR_SWITCH_PULL_DOWN_DYNAMIC = 4 } |
| Pull. More... | |
Functions | |
| void | twr_switch_init (twr_switch_t *self, twr_gpio_channel_t channel, twr_switch_type_t type, twr_switch_pull_t pull) |
| Initialize button. More... | |
| void | twr_switch_set_event_handler (twr_switch_t *self, void(*event_handler)(twr_switch_t *, twr_switch_event_t, void *), void *event_param) |
| Set callback function. More... | |
| bool | twr_switch_get_state (twr_switch_t *self) |
| Get state. More... | |
| void | twr_switch_set_scan_interval (twr_switch_t *self, twr_tick_t scan_interval) |
| Set scan interval (period of button input sampling), default 50ms. More... | |
| void | twr_switch_set_debounce_time (twr_switch_t *self, twr_tick_t debounce_time) |
| Set debounce time (minimum sampling interval during which input cannot change to toggle its state), default 20ms. More... | |
| void | twr_switch_set_pull_advance_time (twr_switch_t *self, uint16_t pull_advance_time_us) |
| Set pull advance time (work only with dynamic pull up/down), default 50us, for time bigger than 1000us is used scheduler. More... | |
Driver for switch.
| enum twr_switch_event_t |
Callback events.
| Enumerator | |
|---|---|
| TWR_SWITCH_EVENT_OPENED | Event Opened. |
| TWR_SWITCH_EVENT_CLOSED | Event Closed. |
Definition at line 17 of file twr_switch.h.
| enum twr_switch_pull_t |
Pull.
Definition at line 41 of file twr_switch.h.
| enum twr_switch_type_t |
Type.
| Enumerator | |
|---|---|
| TWR_SWITCH_TYPE_NO | Type Normally Open. |
| TWR_SWITCH_TYPE_NC | Type Normally Closed. |
Definition at line 29 of file twr_switch.h.
| bool twr_switch_get_state | ( | twr_switch_t * | self | ) |
Get state.
| [in] | self | Instance |
Definition at line 51 of file twr_switch.c.
| void twr_switch_init | ( | twr_switch_t * | self, |
| twr_gpio_channel_t | channel, | ||
| twr_switch_type_t | type, | ||
| twr_switch_pull_t | pull | ||
| ) |
Initialize button.
| [in] | self | Instance |
| [in] | type | Type |
| [in] | pull | Pull |
Definition at line 18 of file twr_switch.c.

| void twr_switch_set_debounce_time | ( | twr_switch_t * | self, |
| twr_tick_t | debounce_time | ||
| ) |
Set debounce time (minimum sampling interval during which input cannot change to toggle its state), default 20ms.
| [in] | self | Instance |
| [in] | debounce_time | Desired debounce time in ticks |
Definition at line 67 of file twr_switch.c.
| void twr_switch_set_event_handler | ( | twr_switch_t * | self, |
| void(*)(twr_switch_t *, twr_switch_event_t, void *) | event_handler, | ||
| void * | event_param | ||
| ) |
Set callback function.
| [in] | self | Instance |
| [in] | event_handler | Function address |
| [in] | event_param | Optional event parameter (can be NULL) |
Definition at line 56 of file twr_switch.c.
| void twr_switch_set_pull_advance_time | ( | twr_switch_t * | self, |
| uint16_t | pull_advance_time_us | ||
| ) |
Set pull advance time (work only with dynamic pull up/down), default 50us, for time bigger than 1000us is used scheduler.
| [in] | self | Instance |
| [in] | pull_advance_time | Pull advance time in us |
Definition at line 72 of file twr_switch.c.
| void twr_switch_set_scan_interval | ( | twr_switch_t * | self, |
| twr_tick_t | scan_interval | ||
| ) |
Set scan interval (period of button input sampling), default 50ms.
| [in] | self | Instance |
| [in] | scan_interval | Desired scan interval in ticks |
Definition at line 62 of file twr_switch.c.