# wgpio.c File Reference

## Detailed Description

Implementation of the Wireless GPIO Application.

This is a Wireless General Purpose IO Application a.k.a. a light switch application.

The application can run in two modes:

- (MP) mains powered : In this mode the receiver always on.
- (RC) remote control: Battery powered remote control with power down on idle.

Note:
  The RC mode can be eanbled on those boards, where the the control key is wired with an interrupt pin of the MCU. All boards with memory mapped keys are not capable of entering the RC mode.

With a long key press, you get into the configuration mode, where the status LED blinks 3 times and the Actor LED displays the current operation mode:

- ActorLed on : MP mode (reset value)
- ActorLed off : RC mode.

Definition in file wgpio.c.

Go to the source code of this file.

## Defines
#define | AWAKE_TIME MSEC(1000)
## Functions
int | main (void)
static void | state_app_config (app_ctx_t *ctx)
static void | state_app_running (app_ctx_t *events)
static void | state_app_status_pending (app_ctx_t *ctx)
static void | state_tx_status_in_progress (app_ctx_t *ctx)
static void | state_tx_switch_in_progress (app_ctx_t *ctx)
static void | status_led_config (uint8_t val, uint8_t blnk)
static void | status_led_handle ()
void | TRX_IRQ_vect ()
static void | wgpio_actor_update (uint8_t state)
static void | wgpio_idle (uint8_t idlemode)
static void | wgpio_init (void)
static bool | wgpio_send_status (event_code_t cmd, uint8_t state)
| Send the current key status.
## Variables
actor_ctx_t | ActorCtx
volatile uint8_t | KeyEvent = 0
uint8_t | Led1Blnk = 0
volatile uint16_t | TmoCounter = 0
volatile uint8_t | TmoEvent = 0
volatile event_t | TrxEvent
volatile app_state_t | TrxState

## Function Documentation

int main | ( | void |  | ) |

Main function of WGPIO application.

Definition at line 85 of file wgpio.c.

void TRX_IRQ_vect | ( |  | ) |

Transceiver IRQ routine. Application specific timer IRQ routine. used to read key status (debounced).

Definition at line 383 of file wgpio.c.

static void wgpio_init | ( | void |  | ) | `[static]`

Initialization function.

Definition at line 145 of file wgpio.c.

static bool wgpio_send_status | ( | event_code_t | cmd,
|  | uint8_t | state |
| ) |  |  | `[static]`

Send the current key status.

Parameters:

  | AppCtx.keytat | key status byte that is to send.

Definition at line 214 of file wgpio.c.