Microchip® Advanced Software Framework

avr2102_rf4control/apps/zid/serial_if/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_api.h"
#include "sio2host.h"
#include "rf4ce.h"
#include "pb_pairing.h"
#include "zrc.h"
#include "zid.h"
#include "zid_device.h"
#include "zid_adaptor.h"
#include "vendor_data.h"

Macros

#define EOT   (4)
 The end of transmission delimiter. More...
 
#define SIO_BUF_COUNT   (2)
 
#define SIO_RX_BUF_SIZE   (250)
 
#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_get_confirm (nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, void *NIBAttributeValue)
 
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)
 
void nwk_ch_agility_indication (uint8_t LogicalChannel)
 Indicates a channel agility event. More...
 
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...
 
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 void zid_connect_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
static void zid_get_attribute_confirm (nwk_enum_t Status, uint8_t PairingRef, zid_attribute_t ZIDAttribute, uint8_t ZIDAttributeIndex, uint8_t AttributeSize, uint8_t *ZIDAttributeValue)
 
static void zid_get_report_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
static void zid_get_report_indication (uint8_t PairingRef, zid_report_types_t zid_report_type, zid_report_desc_t zid_report_desc, uint8_t RxLinkQuality, uint8_t RxFlags)
 
static void zid_heartbeat_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
static void zid_heartbeat_indication (uint8_t PairingRef)
 
void zid_indication_callback_init (void)
 This function does the initialization of the zid indication functions. More...
 
static void zid_report_data_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
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_set_attribute_confirm (nwk_enum_t Status, uint8_t PairingRef, zid_attribute_t ZIDAttribute, uint8_t ZIDAttributeIndex)
 
static void zid_set_null_report_confirm (nwk_enum_t Status)
 
static void zid_set_report_confirm (nwk_enum_t Status, uint8_t PairingRef)
 
static void zid_standby_confirm (nwk_enum_t Status, bool StdbyEnabled)
 
static void zid_standby_leave_indication (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 length of the message should be received. 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...
 
static zid_indication_callback_t zid_ind
 

#define SIO_BUF_COUNT   (2)
#define SIO_RX_BUF_SIZE   (250)

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

References Assert, ring_buffer::buffer, mouse_desc_tag::button0, mouse_desc_tag::button1, mouse_desc_tag::button2, keyboard_output_desc_tag::caps_lock, pinch_gesture_report_tag::center_x, pinch_gesture_report_tag::center_y, keyboard_output_desc_tag::compose, sync_report_tag::contact_count, CONTACT_DATA, contact_data_report_tag::contact_index, contact_data_report_tag::contact_state, contact_data_report_tag::contact_type, DEVICE_TYPE_LIST_SIZE, scroll_gesture_report_tag::direction, pinch_gesture_report_tag::direction, rotation_gesture_report_tag::direction, scroll_gesture_report_tag::distance, pinch_gesture_report_tag::distance, tap_support_properties_tag::double_tap, tap_gesture_report_tag::finger_count, scroll_gesture_report_tag::finger_count, pinch_gesture_report_tag::finger_present, rotation_gesture_report_tag::finger_present, FUNC_PTR, sync_report_tag::gesture, touch_sensor_properties_tag::gestures, INPUT, keyboard_output_desc_tag::kana, keyboard_input_desc_tag::key_code, KEYBOARD, contact_data_report_tag::location_x, tap_gesture_report_tag::location_x, contact_data_report_tag::location_y, tap_gesture_report_tag::location_y, tap_support_properties_tag::long_tap, rotation_gesture_report_tag::magnitude, contact_data_report_tag::major_axis_length, contact_data_report_tag::major_axis_orientation, touch_sensor_properties_tag::max_coordinate_x, touch_sensor_properties_tag::max_coordinate_y, MEMCPY_ENDIAN, contact_data_report_tag::minor_axis_length, keyboard_input_desc_tag::modifier_keys, MOUSE, nlde_data_confirm(), NLDE_DATA_REQUEST, nlde_data_request(), nlme_get_confirm(), NLME_GET_REQUEST, nlme_get_request(), 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(), keyboard_output_desc_tag::num_lock, nwk_ch_agility_confirm(), NWK_CH_AGILITY_REQUEST, nwk_ch_agility_request(), NWK_SUCCESS, touch_sensor_properties_tag::origin, OUTPUT, pbp_org_pair_confirm(), PBP_ORG_PAIR_REQUEST, pbp_org_pair_request(), pbp_rec_pair_confirm(), pbp_rec_pair_request(), PBP_REC_PAIR_REQUEST, PINCH_GESTURE, contact_data_report_tag::pressure, PROFILE_ID_LIST_SIZE, PROFILE_ID_ZID, touch_sensor_properties_tag::reliable_index, zid_report_data_record_tag::report_data, zid_report_data_record_tag::report_desc_identifier, zid_report_data_record_tag::report_type, touch_sensor_properties_tag::resolution_x, touch_sensor_properties_tag::resolution_y, ROTATE_GESTURE, SCROLL_GESTURE, keyboard_output_desc_tag::scroll_lock, touch_sensor_properties_tag::shape, tap_support_properties_tag::single_tap, sio_rx_buf, SYNC, tap_support_properties_tag::tap_and_a_half, TAP_GESTURE, TAP_SUPPORT_PROPERTIES, TOUCH_SENSOR_PROPERTIES, tap_gesture_report_tag::type, scroll_gesture_report_tag::type, vendor_data_confirm(), VENDOR_DATA_REQUEST, mouse_desc_tag::x_coordinate, mouse_desc_tag::y_coordinate, zid_connect_confirm(), zid_get_attribute_confirm(), ZID_GET_ATTRIBUTE_REQUEST, zid_get_attribute_request(), zid_get_report_confirm(), zid_get_report_data_request(), ZID_GET_REPORT_REQUEST, zid_heartbeat_confirm(), ZID_HEARTBEAT_REQUEST, zid_heartbeat_request(), ZID_ORG_CONNECT_REQUEST, zid_org_connect_request(), ZID_REC_CONNECT_REQUEST, zid_rec_connect_request(), zid_report_data_confirm(), ZID_REPORT_DATA_REQUEST, zid_report_data_request(), zid_set_attribute_confirm(), ZID_SET_ATTRIBUTE_REQUEST, zid_set_attribute_request(), zid_set_null_report(), zid_set_null_report_confirm(), ZID_SET_NULL_REPORT_REQUEST, zid_set_report_confirm(), ZID_SET_REPORT_REQUEST, zid_set_report_request(), zid_standby_confirm(), ZID_STANDBY_REQUEST, and zid_standby_request().

Referenced by process_incoming_sio_data().

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_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_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 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
static void vendor_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
profile_id_t  ProfileId,
uint8_t  Handle 
)
static
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 zid_connect_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void zid_get_attribute_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
zid_attribute_t  ZIDAttribute,
uint8_t  ZIDAttributeIndex,
uint8_t  AttributeSize,
uint8_t *  ZIDAttributeValue 
)
static

Referenced by handle_incoming_msg().

static void zid_get_report_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void zid_get_report_indication ( uint8_t  PairingRef,
zid_report_types_t  zid_report_type,
zid_report_desc_t  zid_report_desc,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)
static
static void zid_heartbeat_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void zid_heartbeat_indication ( uint8_t  PairingRef)
static
static void zid_report_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
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

References mouse_desc_tag::button0, mouse_desc_tag::button1, mouse_desc_tag::button2, keyboard_output_desc_tag::caps_lock, pinch_gesture_report_tag::center_x, pinch_gesture_report_tag::center_y, keyboard_output_desc_tag::compose, sync_report_tag::contact_count, CONTACT_DATA, contact_data_report_tag::contact_index, contact_data_report_tag::contact_state, contact_data_report_tag::contact_type, scroll_gesture_report_tag::direction, pinch_gesture_report_tag::direction, rotation_gesture_report_tag::direction, scroll_gesture_report_tag::distance, pinch_gesture_report_tag::distance, tap_support_properties_tag::double_tap, EOT, tap_gesture_report_tag::finger_count, scroll_gesture_report_tag::finger_count, pinch_gesture_report_tag::finger_present, rotation_gesture_report_tag::finger_present, sync_report_tag::gesture, touch_sensor_properties_tag::gestures, get_next_tx_buffer(), INPUT, keyboard_output_desc_tag::kana, keyboard_input_desc_tag::key_code, KEYBOARD, contact_data_report_tag::location_x, tap_gesture_report_tag::location_x, contact_data_report_tag::location_y, tap_gesture_report_tag::location_y, tap_support_properties_tag::long_tap, rotation_gesture_report_tag::magnitude, contact_data_report_tag::major_axis_length, contact_data_report_tag::major_axis_orientation, touch_sensor_properties_tag::max_coordinate_x, touch_sensor_properties_tag::max_coordinate_y, contact_data_report_tag::minor_axis_length, keyboard_input_desc_tag::modifier_keys, MOUSE, keyboard_output_desc_tag::num_lock, touch_sensor_properties_tag::origin, PINCH_GESTURE, contact_data_report_tag::pressure, touch_sensor_properties_tag::reliable_index, zid_report_data_record_tag::report_desc_identifier, zid_report_data_record_tag::report_type, touch_sensor_properties_tag::resolution_x, touch_sensor_properties_tag::resolution_y, RF4CONTROL_PID, ROTATE_GESTURE, SCROLL_GESTURE, keyboard_output_desc_tag::scroll_lock, touch_sensor_properties_tag::shape, tap_support_properties_tag::single_tap, SYNC, tap_support_properties_tag::tap_and_a_half, TAP_GESTURE, TAP_SUPPORT_PROPERTIES, temp, TOUCH_SENSOR_PROPERTIES, tap_gesture_report_tag::type, scroll_gesture_report_tag::type, mouse_desc_tag::x_coordinate, mouse_desc_tag::y_coordinate, and ZID_REPORT_DATA_INDICATION.

Referenced by zid_indication_callback_init().

static void zid_set_attribute_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef,
zid_attribute_t  ZIDAttribute,
uint8_t  ZIDAttributeIndex 
)
static

Referenced by handle_incoming_msg().

static void zid_set_null_report_confirm ( nwk_enum_t  Status)
static
static void zid_set_report_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static
static void zid_standby_confirm ( nwk_enum_t  Status,
bool  StdbyEnabled 
)
static
static void zid_standby_leave_indication ( void  )
static

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

zid_indication_callback_t zid_ind
static