Microchip® Advanced Software Framework

serial_interface.c File Reference

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 SIO_BUF_COUNT   (2)
#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 void nlde_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
profile_id_t  OrgProfile,
uint8_t  Handle 
)
static
static void nlme_get_confirm ( nwk_enum_t  Status,
nib_attribute_t  NIBAttribute,
uint8_t  NIBAttributeIndex,
void *  NIBAttributeValue 
)
static
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
static void nlme_reset_confirm ( nwk_enum_t  Status)
static
static void nlme_rx_enable_confirm ( nwk_enum_t  Status)
static
static void nlme_set_confirm ( nwk_enum_t  Status,
nib_attribute_t  NIBAttribute,
uint8_t  NIBAttributeIndex 
)
static
static void nlme_start_confirm ( nwk_enum_t  Status)
static
static void nlme_unpair_confirm ( uint8_t  Status,
uint8_t  PairingRef 
)
static
static void nlme_update_key_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void pbp_org_pair_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
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
static void zrc_cmd_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
cec_code_t  RcCmd 
)
static
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
static void zrc_cmd_indication ( uint8_t  PairingRef,
uint8_t  nsduLength,
uint8_t *  nsdu,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)
static
void zrc_indication_callback_init ( void  )

uint8_t buf_count = 0
static
uint8_t data[SIO_RX_BUF_SIZE]
static

This is the length of the message should be transmitted.

Referenced by process_incoming_sio_data(), and serial_data_handler().

uint8_t data_length = 0
static

Referenced by serial_data_handler().

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]
static

This is the receive buffer of the UART.

Referenced by handle_incoming_msg(), and process_incoming_sio_data().

uint8_t sio_rx_length
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().

uint8_t* sio_rx_ptr
static

This pointer points to the next free element inside the receive buffer of the UART.

Referenced by process_incoming_sio_data().

volatile uint8_t sio_rx_state
static
uint8_t sio_tx_buf[SIO_BUF_COUNT][SIO_TX_BUF_SIZE]
static

This is the transmit buffer of the UART.

Referenced by get_next_tx_buffer(), and serial_data_handler().