Atmel Software Framework

avr2102_rf4control/addons/serial_interface/serial_interface.c File Reference
#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 nlde_data_indication (uint8_t PairingRef, profile_id_t ProfileId, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)
 
static void nlme_auto_discovery_confirm (nwk_enum_t Status, uint64_t SrcIEEEAddr)
 
static void nlme_comm_status_indication (nwk_enum_t Status, uint8_t PairingRef, uint16_t DstPANId, uint8_t DstAddrMode, uint64_t DstAddr)
 
static void nlme_discovery_confirm (nwk_enum_t Status, uint8_t NumNodes, node_desc_t *NodeDescList)
 
static void nlme_discovery_indication (nwk_enum_t Status, uint64_t SrcIEEEAddr, uint8_t OrgNodeCapabilities, uint16_t OrgVendorId, uint8_t OrgVendorString[7], uint8_t OrgAppCapabilities, uint8_t OrgUserString[15], dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], dev_type_t SearchDevType, uint8_t RxLinkQuality)
 
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_pair_indication (nwk_enum_t Status, uint16_t SrcPANId, uint64_t SrcIEEEAddr, uint8_t OrgNodeCapabilities, uint16_t OrgVendorId, uint8_t OrgVendorString[7], uint8_t OrgAppCapabilities, uint8_t OrgUserString[15], dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], uint8_t KeyExTransferCount, uint8_t ProvPairingRef)
 
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_unpair_indication (uint8_t PairingRef)
 
static void nlme_update_key_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
static void nwk_ch_agility_confirm (nwk_enum_t Status, bool ChannelChanged, uint8_t LogicalChannel)
 
static void nwk_ch_agility_indication (uint8_t LogicalChannel)
 
static void pbp_org_pair_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
static void pbp_rec_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)
 Post processing of the vendor data confirm. More...
 
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_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 nwk_indication_callback_t nwk_ind
 
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 handle_incoming_msg ( void  )
inlinestatic
static void nlde_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
profile_id_t  OrgProfile,
uint8_t  Handle 
)
static
void nlde_data_indication ( uint8_t  PairingRef,
profile_id_t  ProfileId,
uint16_t  VendorId,
uint8_t  nsduLength,
uint8_t *  nsdu,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)
static
static void nlme_auto_discovery_confirm ( nwk_enum_t  Status,
uint64_t  SrcIEEEAddr 
)
static
static void nlme_comm_status_indication ( nwk_enum_t  Status,
uint8_t  PairingRef,
uint16_t  DstPANId,
uint8_t  DstAddrMode,
uint64_t  DstAddr 
)
static
static void nlme_discovery_indication ( nwk_enum_t  Status,
uint64_t  SrcIEEEAddr,
uint8_t  OrgNodeCapabilities,
uint16_t  OrgVendorId,
uint8_t  OrgVendorString[7],
uint8_t  OrgAppCapabilities,
uint8_t  OrgUserString[15],
dev_type_t  OrgDevTypeList[3],
profile_id_t  OrgProfileIdList[7],
dev_type_t  SearchDevType,
uint8_t  RxLinkQuality 
)
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_pair_indication ( nwk_enum_t  Status,
uint16_t  SrcPANId,
uint64_t  SrcIEEEAddr,
uint8_t  OrgNodeCapabilities,
uint16_t  OrgVendorId,
uint8_t  OrgVendorString[7],
uint8_t  OrgAppCapabilities,
uint8_t  OrgUserString[15],
dev_type_t  OrgDevTypeList[3],
profile_id_t  OrgProfileIdList[7],
uint8_t  KeyExTransferCount,
uint8_t  ProvPairingRef 
)
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
void nlme_unpair_indication ( uint8_t  PairingRef)
static
static void nlme_update_key_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void nwk_ch_agility_confirm ( nwk_enum_t  Status,
bool  ChannelChanged,
uint8_t  LogicalChannel 
)
static
static void nwk_ch_agility_indication ( uint8_t  LogicalChannel)
static
static void pbp_org_pair_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void pbp_rec_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 
)

Post processing of the vendor data confirm.

Parameters
statusnwk status (constants defined by nwk layer)
PairingRefPairing reference
HandleNetwork Layer retries
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_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.

uint8_t data_length = 0
static

Referenced by serial_data_handler().

uint8_t head = 0
static
nwk_indication_callback_t nwk_ind
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().