Microchip® Advanced Software Framework

main.c File Reference

ZID USB HID Adaptor Application.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#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   (LED1)
 
#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
}
 

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)
 
bool main_kbd_enable (void)
 
void main_mouse_disable (void)
 
bool main_mouse_enable (void)
 
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   (LED1)
#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 

static void app_alert ( void  )
static

References delay_us, LED0, LED1, and LED_Toggle.

Referenced by main().

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, LED_Toggle, node_status, PAIR_WAIT_PERIOD, SW_TIMEOUT_RELATIVE, sw_timer_start(), sw_timer_stop(), and ZID_CONNECTING.

Referenced by nlme_start_confirm().

void main_kbd_disable ( void  )

References main_b_kbd_enable.

bool main_kbd_enable ( void  )

References main_b_kbd_enable.

void main_mouse_disable ( void  )

References main_b_mouse_enable.

bool main_mouse_enable ( void  )

References main_b_mouse_enable.

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.

Referenced by zid_indication_callback_init().

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, LED0, LED_On, 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.

Referenced by zid_indication_callback_init().

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.

References LED0, and LED_Off.

Referenced by zid_indication_callback_init().

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