Atmel Software Framework

thirdparty/wireless/avr2102_rf4control/apps/zid/adptr/usb_hid/main.c File Reference
#include <stdio.h>
#include "conf_usb.h"
#include "conf_board.h"
#include <asf.h>
#include "app_config.h"
#include "led.h"
#include "delay.h"
#include "vendor_data.h"
#include "pb_pairing.h"
#include "common_sw_timer.h"
#include "zid.h"

Macros

#define LED_DATA   (LED0)
 
#define LED_DATA   (LED0)
 
#define LED_NWK_SETUP   (LED0)
 
#define LED_START   (LED0)
 
#define PAIR_WAIT_PERIOD   500000
 

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_alert (void)
 
static void app_task (void)
 Application task. More...
 
 FLASH_DECLARE (uint16_t VendorIdentifier)
 
 FLASH_DECLARE (uint8_t vendor_string[7])
 
 FLASH_DECLARE (uint8_t app_user_string[15])
 
static void led_handling (void *callback_parameter)
 Function to handle the LED States based on application state. More...
 
int main (void)
 Main function, initialization and main message loop. More...
 
void main_kbd_disable (void)
 Called by HID interface Callback running when USB Host disable keyboard interface. More...
 
bool main_kbd_enable (void)
 Called by HID interface Callback running when USB Host enable keyboard interface. More...
 
void main_mouse_disable (void)
 Called by HID interface Callback running when USB Host disable mouse interface. More...
 
bool main_mouse_enable (void)
 Called by HID interface Callback running when USB Host enable mouse interface. More...
 
static void nlme_reset_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to reset the NWK layer. More...
 
static void nlme_start_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to start the NWK. More...
 
static void nlme_unpair_indication (uint8_t PairingRef)
 Notify the application of the removal of link by another device. More...
 
bool pbp_allow_pairing (nwk_enum_t Status, uint64_t SrcIEEEAddr, uint16_t OrgVendorId, uint8_t OrgVendorString[7], uint8_t OrgUserString[15], uint8_t KeyExTransferCount)
 This function decides whether push button pairing request should be allowed. More...
 
static void zid_connect_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Notify the application of the status of its connect request. More...
 
static void zid_heartbeat_indication (uint8_t PairingRef)
 Notify the application of the status of its heartbeat request. More...
 
static void zid_indication_callback_init (void)
 This function registers the callback function for indications from the stack. More...
 
static void zid_report_data_indication (uint8_t PairingRef, uint8_t num_report_records, zid_report_data_record_t *zid_report_data_record_ptr, uint8_t RxLinkQuality, uint8_t RxFlags)
 Notify the application when ZID report data is received from the paired device. More...
 
void zid_standby_leave_indication (void)
 Notify the application of the status of its standby request. More...
 

Variables

static uint8_t APP_TIMER
 
static bool duplicate_pair_entry = false
 
static volatile bool main_b_kbd_enable = false
 
static bool main_b_mouse_enable = false
 
static node_status_t node_status
 
static uint8_t number_of_paired_dev = 0
 
static nwk_indication_callback_t nwk_ind
 
static uint8_t target_auto_start = true
 
static zid_indication_callback_t zid_ind
 

#define LED_DATA   (LED0)
#define LED_DATA   (LED0)
#define LED_NWK_SETUP   (LED0)

Referenced by led_handling().

#define LED_START   (LED0)
#define PAIR_WAIT_PERIOD   500000

Referenced by led_handling(), and nlme_start_confirm().

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 app_alert ( void  )
static

References delay_us.

static void app_task ( void  )
static
FLASH_DECLARE ( uint16_t  VendorIdentifier)
FLASH_DECLARE ( uint8_t  vendor_string[7])
FLASH_DECLARE ( uint8_t  app_user_string[15])
static void led_handling ( void *  callback_parameter)
static

Function to handle the LED States based on application state.

Parameters
callback_parametercallback parameter if any.

References ALL_IN_ONE_START, APP_TIMER, FUNC_PTR, LED_NWK_SETUP, node_status, PAIR_WAIT_PERIOD, SW_TIMEOUT_RELATIVE, sw_timer_start(), sw_timer_stop(), and ZID_CONNECTING.

Referenced by nlme_start_confirm().

int main ( void  )
void main_kbd_disable ( void  )

Called by HID interface Callback running when USB Host disable keyboard interface.

References main_b_kbd_enable.

bool main_kbd_enable ( void  )

Called by HID interface Callback running when USB Host enable keyboard interface.

Return values
trueif keyboard startup is ok

References main_b_kbd_enable.

void main_mouse_disable ( void  )

Called by HID interface Callback running when USB Host disable mouse interface.

bool main_mouse_enable ( void  )

Called by HID interface Callback running when USB Host enable mouse interface.

Return values
trueif mouse startup is ok
static void nlme_reset_confirm ( nwk_enum_t  Status)
static

Notify the application of the status of its request to reset the NWK layer.

Parameters
Statusnwk status

References FUNC_PTR, nlme_reset_request(), nlme_start_confirm(), nlme_start_request(), and NWK_SUCCESS.

Referenced by app_task().

static void nlme_start_confirm ( nwk_enum_t  Status)
static
static void nlme_unpair_indication ( uint8_t  PairingRef)
static

Notify the application of the removal of link by another device.

The NLME-UNPAIR.indication primitive allows the NLME to notify the application of the removal of a pairing link by another device.

Parameters
PairingRefPairing Ref for which entry is removed from pairing table.

References number_of_paired_dev.

static void zid_connect_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

Notify the application of the status of its connect request.

Parameters
Statusnwk status.
PairingRefPairing reference.

References duplicate_pair_entry, IDLE, node_status, number_of_paired_dev, and NWK_SUCCESS.

Referenced by nlme_start_confirm().

static void zid_heartbeat_indication ( uint8_t  PairingRef)
static

Notify the application of the status of its heartbeat request.

Parameters
PairingRefPairing reference.
static void zid_indication_callback_init ( void  )
static

This function registers the callback function for indications from the stack.

static void zid_report_data_indication ( uint8_t  PairingRef,
uint8_t  num_report_records,
zid_report_data_record_t zid_report_data_record_ptr,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)
static
void zid_standby_leave_indication ( void  )

Notify the application of the status of its standby request.

uint8_t APP_TIMER
static
bool duplicate_pair_entry = false
static

Referenced by zid_connect_confirm().

volatile bool main_b_kbd_enable = false
static
bool main_b_mouse_enable = false
static
uint8_t number_of_paired_dev = 0
static
nwk_indication_callback_t nwk_ind
static
uint8_t target_auto_start = true
static

Referenced by app_task().

zid_indication_callback_t zid_ind
static