RF4CE Serial Interface Implementation.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "compiler.h"
#include "app_config.h"
#include "nwk_msg_code.h"
#include "serial_interface.h"
#include "sio2host.h"
#include "rf4ce.h"
#include "pb_pairing.h"
#include "zrc.h"
#include "vendor_data.h"
#include "nwk_config.h"
Macros | |
#define | EOT (4) |
The end of transmission delimiter. More... | |
#define | SIO_BUF_COUNT (2) |
#define | SIO_RX_BUF_SIZE (200) |
#define | SIO_TX_BUF_SIZE SIO_RX_BUF_SIZE |
#define | SOT (1) |
The start of transmission delimiter. More... | |
#define | UART_RX_PROTOCOL_ID (3) |
A UART state that expects the protocol id to be received as the next character. More... | |
#define | UART_RX_STATE_DATA (4) |
A UART state that expects the next data character to be received. More... | |
#define | UART_RX_STATE_EOT (5) |
A UART state that expects a EOT to be received as the next character. More... | |
#define | UART_RX_STATE_LENGTH (2) |
A UART state that expects the length to be received as the next character. More... | |
#define | UART_RX_STATE_SOT (1) |
A UART state that expects a SOT to be received as the next character. More... | |
Functions | |
static uint8_t * | get_next_tx_buffer (void) |
static void | handle_incoming_msg (void) |
static void | nlde_data_confirm (nwk_enum_t Status, uint8_t PairingRef, profile_id_t OrgProfile, uint8_t Handle) |
static void | nlme_discovery_confirm (nwk_enum_t Status, uint8_t NumNodes, node_desc_t *NodeDescList) |
static void | nlme_get_confirm (nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, void *NIBAttributeValue) |
static void | nlme_pair_confirm (nwk_enum_t Status, uint8_t PairingRef, uint16_t RecVendorId, uint8_t RecVendorString[7], uint8_t RecAppCapabilities, uint8_t RecUserString[15], dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7]) |
static void | nlme_reset_confirm (nwk_enum_t Status) |
static void | nlme_rx_enable_confirm (nwk_enum_t Status) |
static void | nlme_set_confirm (nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex) |
static void | nlme_start_confirm (nwk_enum_t Status) |
static void | nlme_unpair_confirm (uint8_t Status, uint8_t PairingRef) |
static void | nlme_update_key_confirm (nwk_enum_t Status, uint8_t PairingRef) |
static void | pbp_org_pair_confirm (nwk_enum_t Status, uint8_t PairingRef) |
static void | process_incoming_sio_data (void) |
void | serial_data_handler (void) |
Function to handle the state machine serial data exchange. More... | |
void | serial_interface_init (void) |
This function does the initialization of the SIO or UART. More... | |
void | stack_indication_callback_init (void) |
void | vendor_data_confirm (nwk_enum_t Status, uint8_t PairingRef, profile_id_t ProfileId, uint8_t Handle) |
static 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) |
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) |
static void | zrc_cmd_indication (uint8_t PairingRef, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags) |
void | zrc_indication_callback_init (void) |
Variables | |
static uint8_t | buf_count = 0 |
static uint8_t | data [SIO_RX_BUF_SIZE] |
This is the length of the message should be transmitted. More... | |
static uint8_t | data_length = 0 |
static uint8_t | head = 0 |
static uint8_t | protocol_id |
static uint8_t | rx_index = 0 |
static uint8_t | sio_rx_buf [SIO_RX_BUF_SIZE] |
This is the receive buffer of the UART. More... | |
static uint8_t | sio_rx_length |
This is the transmit state of the UART. More... | |
static uint8_t * | sio_rx_ptr |
This pointer points to the next free element inside the receive buffer of the UART. More... | |
static volatile uint8_t | sio_rx_state |
This is the receiver state of the UART. More... | |
static uint8_t | sio_tx_buf [SIO_BUF_COUNT][SIO_TX_BUF_SIZE] |
This is the transmit buffer of the UART. More... | |
zrc_indication_callback_t | zrc_ind |
#define EOT (4) |
The end of transmission delimiter.
Referenced by nlde_data_confirm(), nlme_discovery_confirm(), nlme_get_confirm(), nlme_pair_confirm(), nlme_reset_confirm(), nlme_rx_enable_confirm(), nlme_set_confirm(), nlme_start_confirm(), nlme_unpair_confirm(), nlme_update_key_confirm(), pbp_org_pair_confirm(), process_incoming_sio_data(), vendor_data_confirm(), vendor_data_ind(), zrc_cmd_confirm(), zrc_cmd_disc_confirm(), zrc_cmd_disc_indication(), and zrc_cmd_indication().
#define SIO_BUF_COUNT (2) |
Referenced by get_next_tx_buffer(), and serial_data_handler().
#define SIO_RX_BUF_SIZE (200) |
Referenced by serial_data_handler().
#define SIO_TX_BUF_SIZE SIO_RX_BUF_SIZE |
#define SOT (1) |
The start of transmission delimiter.
Referenced by get_next_tx_buffer(), and process_incoming_sio_data().
#define UART_RX_PROTOCOL_ID (3) |
A UART state that expects the protocol id to be received as the next character.
Referenced by process_incoming_sio_data().
#define UART_RX_STATE_DATA (4) |
A UART state that expects the next data character to be received.
Referenced by process_incoming_sio_data().
#define UART_RX_STATE_EOT (5) |
A UART state that expects a EOT to be received as the next character.
Referenced by process_incoming_sio_data().
#define UART_RX_STATE_LENGTH (2) |
A UART state that expects the length to be received as the next character.
Referenced by process_incoming_sio_data().
#define UART_RX_STATE_SOT (1) |
A UART state that expects a SOT to be received as the next character.
Referenced by process_incoming_sio_data(), and serial_interface_init().
|
static |
References buf_count, head, SIO_BUF_COUNT, sio_tx_buf, and SOT.
Referenced by nlde_data_confirm(), nlme_discovery_confirm(), nlme_get_confirm(), nlme_pair_confirm(), nlme_reset_confirm(), nlme_rx_enable_confirm(), nlme_set_confirm(), nlme_start_confirm(), nlme_unpair_confirm(), nlme_update_key_confirm(), pbp_org_pair_confirm(), vendor_data_confirm(), vendor_data_ind(), zrc_cmd_confirm(), zrc_cmd_disc_confirm(), zrc_cmd_disc_indication(), and zrc_cmd_indication().
|
inlinestatic |
References Assert, DEVICE_TYPE_LIST_SIZE, FUNC_PTR, MEMCPY_ENDIAN, nlde_data_confirm(), NLDE_DATA_REQUEST, nlde_data_request(), NLME_AUTO_DISCOVERY_REQUEST, nlme_discovery_confirm(), NLME_DISCOVERY_REQUEST, nlme_discovery_request(), NLME_DISCOVERY_RESPONSE, nlme_get_confirm(), NLME_GET_REQUEST, nlme_get_request(), nlme_pair_confirm(), NLME_PAIR_REQUEST, nlme_pair_request(), NLME_PAIR_RESPONSE, nlme_reset_confirm(), NLME_RESET_REQUEST, nlme_reset_request(), nlme_rx_enable_confirm(), NLME_RX_ENABLE_REQUEST, nlme_rx_enable_request(), nlme_set_confirm(), NLME_SET_REQUEST, nlme_set_request(), nlme_start_confirm(), NLME_START_REQUEST, nlme_start_request(), nlme_unpair_confirm(), NLME_UNPAIR_REQUEST, nlme_unpair_request(), NLME_UNPAIR_RESPONSE, nlme_unpair_response(), nlme_update_key_confirm(), NLME_UPDATE_KEY_REQUEST, nlme_update_key_request(), NWK_CH_AGILITY_REQUEST, pbp_org_pair_confirm(), PBP_ORG_PAIR_REQUEST, pbp_org_pair_request(), PROFILE_ID_LIST_SIZE, PROFILE_ID_ZRC, sio_rx_buf, vendor_data_confirm(), VENDOR_DATA_REQUEST, zrc_cmd_confirm(), zrc_cmd_disc_confirm(), zrc_cmd_disc_request(), zrc_cmd_disc_response(), ZRC_CMD_DISCOVERY_REQUEST, ZRC_CMD_DISCOVERY_RESPONSE, ZRC_CMD_REQUEST, and zrc_cmd_request().
Referenced by process_incoming_sio_data().
|
static |
References EOT, get_next_tx_buffer(), NLDE_DATA_CONF_LEN, NLDE_DATA_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References NodeDesc_tag::AppCapabilities, DEVICE_TYPE_LIST_SIZE, NodeDesc_tag::DevTypeList, NodeDesc_tag::DiscReqLQI, EOT, get_next_tx_buffer(), NodeDesc_tag::LogicalChannel, NLME_DISCOVERY_CONF_LEN, NLME_DISCOVERY_CONFIRM, NodeDesc_tag::NodeCapabilities, PROFILE_ID_LIST_SIZE, NodeDesc_tag::ProfileIdList, RF4CONTROL_PID, RF4CONTROL_PID_LEN, NodeDesc_tag::Status, NodeDesc_tag::UserString, and NodeDesc_tag::VendorString.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_GET_CONF_LEN, NLME_GET_CONFIRM, nwk_get_nib_attribute_size(), RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References DEVICE_TYPE_LIST_SIZE, EOT, get_next_tx_buffer(), NLME_PAIR_CONF_LEN, NLME_PAIR_CONFIRM, PROFILE_ID_LIST_SIZE, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_RESET_CONF_LEN, NLME_RESET_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_RX_ENABLE_CONF_LEN, NLME_RX_ENABLE_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_SET_CONF_LEN, NLME_SET_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_START_CONF_LEN, NLME_START_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_UNPAIR_CONF_LEN, NLME_UNPAIR_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), NLME_UPDATE_KEY_CONF_LEN, NLME_UPDATE_KEY_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), PBP_ORG_PAIR_CONFIRM, RF4CONTROL_PID, and RF4CONTROL_PID_LEN.
Referenced by handle_incoming_msg().
|
inlinestatic |
References data, EOT, handle_incoming_msg(), protocol_id, RF4CONTROL_PID, rx_index, sio_rx_buf, sio_rx_length, sio_rx_ptr, sio_rx_state, SOT, UART_RX_PROTOCOL_ID, UART_RX_STATE_DATA, UART_RX_STATE_EOT, UART_RX_STATE_LENGTH, and UART_RX_STATE_SOT.
Referenced by serial_data_handler().
void stack_indication_callback_init | ( | void | ) |
References nwk_indication_callback_tag::nlde_data_indication_cb, nwk_indication_callback_tag::nlme_unpair_indication_cb, register_nwk_indication_callback(), register_zrc_indication_callback(), vendor_data_ind(), zrc_indication_callback::vendor_data_ind_cb, zrc_cmd_disc_indication(), zrc_indication_callback::zrc_cmd_disc_indication_cb, zrc_cmd_indication(), and zrc_indication_callback::zrc_cmd_indication_cb.
Referenced by main().
void vendor_data_confirm | ( | nwk_enum_t | Status, |
uint8_t | PairingRef, | ||
profile_id_t | ProfileId, | ||
uint8_t | Handle | ||
) |
References EOT, get_next_tx_buffer(), RF4CONTROL_PID, RF4CONTROL_PID_LEN, and VENDOR_DATA_CONFIRM.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), PROFILE_ID_ZRC, RF4CONTROL_PID, RF4CONTROL_PID_LEN, and VENDOR_DATA_INDICATION.
Referenced by stack_indication_callback_init().
|
static |
References EOT, get_next_tx_buffer(), RF4CONTROL_PID, RF4CONTROL_PID_LEN, and ZRC_CMD_CONFIRM.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), RF4CONTROL_PID, RF4CONTROL_PID_LEN, and ZRC_CMD_DISCOVERY_CONFIRM.
Referenced by handle_incoming_msg().
|
static |
References EOT, get_next_tx_buffer(), RF4CONTROL_PID, RF4CONTROL_PID_LEN, and ZRC_CMD_DISCOVERY_INDICATION.
Referenced by stack_indication_callback_init().
|
static |
References EOT, get_next_tx_buffer(), NLDE_DATA_IND_LEN, RF4CONTROL_PID, RF4CONTROL_PID_LEN, and ZRC_CMD_INDICATION.
Referenced by stack_indication_callback_init().
void zrc_indication_callback_init | ( | void | ) |
|
static |
Referenced by get_next_tx_buffer(), and serial_data_handler().
|
static |
This is the length of the message should be transmitted.
Referenced by process_incoming_sio_data(), and serial_data_handler().
|
static |
Referenced by serial_data_handler().
|
static |
Referenced by get_next_tx_buffer(), and serial_data_handler().
|
static |
Referenced by process_incoming_sio_data().
|
static |
Referenced by process_incoming_sio_data(), and serial_data_handler().
|
static |
This is the receive buffer of the UART.
Referenced by handle_incoming_msg(), and process_incoming_sio_data().
|
static |
This is the transmit state of the UART.
(UART_TX_STATE_SOT, UART_TX_STATE_LENGTH, UART_TX_STATE_DATA, or UART_TX_STATE_EOT) This is the length of the message should be received.
Referenced by process_incoming_sio_data().
|
static |
This pointer points to the next free element inside the receive buffer of the UART.
Referenced by process_incoming_sio_data().
|
static |
This is the receiver state of the UART.
(UART_RX_STATE_SOT, UART_RX_STATE_LENGTH, UART_RX_STATE_DATA, or UART_RX_STATE_EOT)
Referenced by process_incoming_sio_data(), and serial_interface_init().
|
static |
This is the transmit buffer of the UART.
Referenced by get_next_tx_buffer(), and serial_data_handler().
zrc_indication_callback_t zrc_ind |