button controller application
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#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, WARM_START, COLD_START, TRANSMITTING, SELECT_TARGET_OPTIONS, TARGET_PAIRING, TARGET_CHANGING, BUTTON_RELEASE_WAITING, TARGET_PAIRING_WAIT } |
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) |
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) |
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 |
Referenced by app_task().
typedef enum node_status_tag node_status_t |
enum node_status_tag |
|
static |
Application task and state machine.
References APP_CAPABILITIES, BUTTON_RELEASE_WAITING, DEBOUNCE_TIME_US, DEV_TYPE_REMOTE_CONTROL, DEV_TYPE_WILDCARD, FUNC_PTR, FUNCTION1_KEY, FUNCTION2_KEY, IDLE, KEY_PRESSED, KEY_RELEASED, key_state_read(), LED0, LED_On, MAX_KEYS, node_status, NUM_SUPPORTED_PROFILES, nwk_ready_to_sleep(), pairing_ref, pal_get_current_time(), pbp_org_pair_confirm(), pbp_org_pair_request(), POWER_TOGGLE_FUNCTION, PROFILE_ID_ZRC, repeat_press_key_state, SELECT_KEY, SELECT_TARGET_OPTIONS, sleepmgr_enter_sleep(), SLEEPMGR_IDLE, sleepmgr_init(), sleepmgr_lock_mode(), TARGET1_KEY, TARGET2_KEY, TARGET_CHANGING, TARGET_PAIRING, TARGET_PAIRING_WAIT, TRANSMITTING, TX_OPTIONS, USER_CONTROL_IDLE, USER_CONTROL_PRESSED, USER_CONTROL_RELEASED, USER_CONTROL_REPEATED, VOLUME_UP, zrc_cmd_confirm(), and zrc_cmd_request().
Referenced by main().
|
static |
Extended blocking delay.
delay_ms | Delay 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 |
Indicating malfunction.
References extended_delay_ms(), LED0, LED1, LED2, LED_Off, and LED_On.
Referenced by main(), nlme_reset_confirm(), nlme_rx_enable_confirm(), nlme_start_confirm(), pbp_org_pair_confirm(), and zrc_cmd_confirm().
|
static |
Read key_state.
button_no | Button ID |
References gpio_pin_is_low, GPIO_PUSH_BUTTON_0, GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_2, KEY_PRESSED, KEY_RELEASED, SELECT_KEY, TARGET1_KEY, and TARGET2_KEY.
Referenced by app_task(), and main().
int main | ( | void | ) |
Main function of the Single Button Controller application.
References app_task(), app_timer, board_init(), COLD_RESET_KEY, COLD_START, cpu_irq_enable, FUNC_PTR, indicate_fault_behavior(), irq_initialize_vectors, KEY_PRESSED, key_state_read(), LED0, LED_On, nlme_reset_confirm(), nlme_reset_request(), node_status, nwk_init(), NWK_SUCCESS, nwk_task(), pal_timer_get_id(), register_zrc_indication_callback(), sw_timer_init(), sysclk_init(), vendor_data_ind(), zrc_indication_callback::vendor_data_ind_cb, WARM_START, zrc_cmd_disc_indication(), and zrc_indication_callback::zrc_cmd_disc_indication_cb.
|
static |
void nlme_rx_enable_confirm | ( | nwk_enum_t | Status | ) |
References COLD_START, extended_delay_ms(), IDLE, indicate_fault_behavior(), LED0, LED1, LED2, LED_Off, LED_On, node_status, NWK_SUCCESS, and WARM_START.
Referenced by nlme_reset_confirm(), pbp_org_pair_confirm(), vendor_data_ind(), and zrc_cmd_disc_confirm().
|
static |
References indicate_fault_behavior(), and NWK_SUCCESS.
Referenced by nlme_reset_confirm().
|
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.
Status | Status of the last pairing transaction |
PairingRef | If 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 |
References FUNC_PTR, pairing_ref, zrc_cmd_disc_confirm(), and zrc_cmd_disc_request().
Referenced by pbp_org_pair_confirm().
void vendor_app_alive_req | ( | void | ) |
Vendor-spefic callback; handles reaction to incoming alive request.
Vendor data alive request.
References extended_delay_ms(), LED0, LED1, LED2, LED_Off, and LED_On.
Referenced by vendor_data_ind().
void vendor_data_ind | ( | uint8_t | PairingRef, |
uint16_t | VendorId, | ||
uint8_t | nsduLength, | ||
uint8_t * | nsdu, | ||
uint8_t | RxLinkQuality, | ||
uint8_t | RxFlags | ||
) |
References ALIVE_REQ, ALIVE_RESP, BATTERY_STATUS_REQ, BATTERY_STATUS_RESP, FUNC_PTR, FW_DATA_RESP, FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_REQ, FW_VERSION_RESP, FW_VERSION_REV, get_batmon_voltage(), nlde_data_request(), nlme_rx_enable_confirm(), nlme_rx_enable_request(), PGM_READ_WORD, PROFILE_ID_ZRC, RX_FLAG_WITH_SEC, RX_ON_REQ, RX_ON_RESP, TXO_ACK_REQ, TXO_CH_NOT_SPEC, TXO_DST_ADDR_NET, TXO_MULTI_CH, TXO_SEC_REQ, TXO_UNICAST, TXO_VEND_SPEC, VD_NOT_SUPPORTED_ATTRIBUTE, vendor_app_alive_req(), and vendor_data_confirm().
Referenced by main().
|
static |
ZRC command confirm.
The ZRC comand confirm callback provides information about the status of the last command request/transmission.
Status | NWK_SUCCESS if transmission was successful |
PairingRef | Pairing reference |
RcCmd | Sent RC command |
References IDLE, indicate_fault_behavior(), LED0, LED_Off, node_status, NWK_SUCCESS, repeat_press_key_state, and USER_CONTROL_REPEATED.
Referenced by app_task().
|
static |
References FUNC_PTR, nlme_rx_enable_confirm(), nlme_rx_enable_request(), nwkcMinActivePeriod, and RX_DURATION_OFF.
Referenced by start_cmd_disc_cb().
|
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().
|
static |
Referenced by app_task(), main(), nlme_reset_confirm(), nlme_rx_enable_confirm(), and zrc_cmd_confirm().
|
static |
Referenced by app_task(), nlme_reset_confirm(), pbp_org_pair_confirm(), and start_cmd_disc_cb().
|
static |
Referenced by app_task(), and zrc_cmd_confirm().
zrc_indication_callback_t zrc_ind |