Atmel Software Framework

thirdparty/wireless/avr2102_rf4control/apps/zrc/button_ctr/main.c File Reference
#include <asf.h>
#include "conf_board.h"
#include "pal.h"
#include "keyboard.h"
#include "tal.h"
#include "app_config.h"
#include "rf4ce.h"
#include "zrc.h"
#include "pb_pairing.h"
#include "sleepmgr.h"
#include "vendor_data.h"

Macros

#define DEBOUNCE_TIME_US   100000
 
#define INTER_FRAME_DURATION_US   200000
 
#define TX_OPTIONS
 

Typedefs

typedef enum node_status_tag node_status_t
 

Enumerations

enum  node_status_tag {
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  IDLE,
  WARM_START,
  COLD_START,
  TRANSMITTING,
  SELECT_TARGET_OPTIONS,
  TARGET_PAIRING,
  TARGET_CHANGING,
  BUTTON_RELEASE_WAITING,
  TARGET_PAIRING_WAIT,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  PUSH_BUTTON_PAIRING,
  CMD_DISCOVERING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  PRINTING_PAIRING_TABLE,
  UNPAIRING,
  CH_AGILITY_EXECUTION,
  BASE_CHANNEL_CHANGE,
  GETTING_CH_AG_NIBS,
  COLD_START_RESET,
  PC_RUNNING,
  IDLE,
  TRANSMITTING,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  PRINTING_PAIRING_TABLE,
  UNPAIRING,
  IDLE,
  WARM_START,
  COLD_START,
  CONFIGURING_ATTRIBUTES,
  CONNECTING,
  TRANSMITTING
}
 

Functions

static void app_task (void)
 Application task and state machine. More...
 
static void extended_delay_ms (uint16_t delay_ms)
 Extended blocking delay. More...
 
 FLASH_DECLARE (uint16_t VendorIdentifier)
 
 FLASH_DECLARE (uint8_t vendor_string[7])
 
 FLASH_DECLARE (uint8_t app_user_string[15])
 
 FLASH_DECLARE (uint8_t supported_cec_cmds[32])
 
static void indicate_fault_behavior (void)
 Indicating malfunction. More...
 
static key_state_t key_state_read (key_id_t key_no)
 Read key_state. More...
 
int main (void)
 Main function of the Single Button Controller application. More...
 
static void nlme_reset_confirm (nwk_enum_t Status)
 
void nlme_rx_enable_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to enable or disable the receiver. More...
 
static void nlme_start_confirm (nwk_enum_t Status)
 
static void pbp_org_pair_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Push button pairing confirm; target and controller use. More...
 
static void start_cmd_disc_cb (void *callback_parameter)
 
void vendor_app_alive_req (void)
 Vendor-spefic callback; handles reaction to incoming alive request. More...
 
void vendor_data_ind (uint8_t PairingRef, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)
 Post processing of the vendor data response. More...
 
static void zrc_cmd_confirm (nwk_enum_t Status, uint8_t PairingRef, cec_code_t RcCmd)
 ZRC command confirm. More...
 
static void zrc_cmd_disc_confirm (nwk_enum_t Status, uint8_t PairingRef, uint8_t *SupportedCmd)
 
static void zrc_cmd_disc_indication (uint8_t PairingRef)
 

Variables

uint8_t app_timer
 
static node_status_t node_status
 
static uint8_t pairing_ref = 0xFF
 
static uint8_t repeat_press_key_state = USER_CONTROL_RELEASED
 
zrc_indication_callback_t zrc_ind
 

#define DEBOUNCE_TIME_US   100000

Referenced by app_task().

#define INTER_FRAME_DURATION_US   200000
#define TX_OPTIONS
Value:
#define TXO_VEND_NOT_SPEC
Tx option - no vendor-specific data.
Definition: rf4ce.h:180
#define TXO_ACK_REQ
Tx option - ACK requested.
Definition: rf4ce.h:166
#define TXO_DST_ADDR_NET
Tx option - destination address: short.
Definition: rf4ce.h:160
#define TXO_UNICAST
Tx option - unicast.
Definition: rf4ce.h:156
#define TXO_SEC_REQ
Tx option - security requested.
Definition: rf4ce.h:170
#define TXO_MULTI_CH
Tx option - multi-channel transmission.
Definition: rf4ce.h:172
#define TXO_CH_NOT_SPEC
Tx option - channel not specified.
Definition: rf4ce.h:176

Referenced by app_task().

Enumerator
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
IDLE 
WARM_START 
COLD_START 
TRANSMITTING 
SELECT_TARGET_OPTIONS 
TARGET_PAIRING 
TARGET_CHANGING 
BUTTON_RELEASE_WAITING 
TARGET_PAIRING_WAIT 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
PUSH_BUTTON_PAIRING 
CMD_DISCOVERING 
ALL_IN_ONE_START 
WARM_STARTING 
PRINTING_PAIRING_TABLE 
UNPAIRING 
CH_AGILITY_EXECUTION 
BASE_CHANNEL_CHANGE 
GETTING_CH_AG_NIBS 
COLD_START_RESET 
PC_RUNNING 
IDLE 
TRANSMITTING 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
PRINTING_PAIRING_TABLE 
UNPAIRING 
IDLE 
WARM_START 
COLD_START 
CONFIGURING_ATTRIBUTES 
CONNECTING 
TRANSMITTING 

static void extended_delay_ms ( uint16_t  delay_ms)
static

Extended blocking delay.

Parameters
delay_msDelay value in ms

References pal_timer_delay.

Referenced by indicate_fault_behavior(), nlme_rx_enable_confirm(), and vendor_app_alive_req().

FLASH_DECLARE ( uint16_t  VendorIdentifier)
FLASH_DECLARE ( uint8_t  vendor_string[7])
FLASH_DECLARE ( uint8_t  app_user_string[15])
FLASH_DECLARE ( uint8_t  supported_cec_cmds[32])
static void indicate_fault_behavior ( void  )
static
static key_state_t key_state_read ( key_id_t  key_no)
static

Read key_state.

Parameters
button_noButton ID

References gpio_pin_is_low, KEY_PRESSED, KEY_RELEASED, SELECT_KEY, TARGET1_KEY, and TARGET2_KEY.

Referenced by app_task(), and main().

static void nlme_rx_enable_confirm ( nwk_enum_t  Status)

Notify the application of the status of its request to enable or disable the receiver.

Notify the application of the status of its rx enable request.

Parameters
Statusnwk status

References COLD_START, extended_delay_ms(), IDLE, indicate_fault_behavior(), node_status, NWK_SUCCESS, and WARM_START.

Referenced by nlme_reset_confirm(), pbp_org_pair_confirm(), and zrc_cmd_disc_confirm().

static void nlme_start_confirm ( nwk_enum_t  Status)
static
static void pbp_org_pair_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

Push button pairing confirm; target and controller use.

The push button pairing confirm is a callback that provides the status of the push pairing request.

Parameters
StatusStatus of the last pairing transaction
PairingRefIf pairing was successful, PairingRef contains assigned pairing reference.

References aplcMinTargetBlackoutPeriod_us, app_timer, FUNC_PTR, indicate_fault_behavior(), nlme_rx_enable_confirm(), nlme_rx_enable_request(), NWK_SUCCESS, nwkcMinActivePeriod, pairing_ref, pal_timer_start(), RX_DURATION_OFF, start_cmd_disc_cb(), and TIMEOUT_RELATIVE.

Referenced by app_task().

static void start_cmd_disc_cb ( void *  callback_parameter)
static
void vendor_app_alive_req ( void  )

Vendor-spefic callback; handles reaction to incoming alive request.

Vendor data alive request.

static void vendor_data_ind ( uint8_t  PairingRef,
uint16_t  VendorId,
uint8_t  nsduLength,
uint8_t *  nsdu,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)

Post processing of the vendor data response.

Parameters
PairingRefPairing reference
VendorIdVendor ID.
nsduLengthLength of the payload.
nsduActual payload
RxLinkQualityLink quality of received packet.
RxFlagsRx Flags.

References ALIVE_RESP, BATTERY_STATUS_RESP, FUNC_PTR, FW_VERSION_RESP, IDLE, nlme_rx_enable_confirm(), nlme_rx_enable_request(), node_status, PGM_READ_WORD, POWER_SAVE, RX_DURATION_INFINITY, and RX_ON_RESP.

Referenced by main().

static void zrc_cmd_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
cec_code_t  RcCmd 
)
static

ZRC command confirm.

The ZRC comand confirm callback provides information about the status of the last command request/transmission.

Parameters
StatusNWK_SUCCESS if transmission was successful
PairingRefPairing reference
RcCmdSent RC command

References IDLE, indicate_fault_behavior(), node_status, NWK_SUCCESS, repeat_press_key_state, and USER_CONTROL_REPEATED.

Referenced by app_task(), and handle_incoming_msg().

static void zrc_cmd_disc_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
uint8_t *  SupportedCmd 
)
static
static void zrc_cmd_disc_indication ( uint8_t  PairingRef)
static

References PGM_READ_BLOCK, and zrc_cmd_disc_response().

Referenced by main().

uint8_t app_timer

Referenced by main(), and pbp_org_pair_confirm().

uint8_t pairing_ref = 0xFF
static
uint8_t repeat_press_key_state = USER_CONTROL_RELEASED
static

Referenced by app_task(), and zrc_cmd_confirm().