Microchip® Advanced Software Framework

perf_api_serial_handler.c File Reference

SIO service implementation - Performance Analyzer application.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "tal.h"
#include "return_val.h"
#include "ieee_const.h"
#include "app_init.h"
#include "perf_msg_const.h"
#include "sio2host.h"
#include "perf_api.h"
#include "perf_api_serial_handler.h"
#include "tal_helper.h"

UART COMMUNICATION FRAMING

#define SOT   (1)
 The start of transmission delimiter. More...
 
#define EOT   (4)
 The end of transmission delimiter. More...
 
#define UART_RX_STATE_SOT   (1)
 A UART state that expects a SOT 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_DATA   (3)
 A UART state that expects the next data character to be received. More...
 
#define UART_RX_STATE_EOT   (4)
 A UART state that expects a EOT to be received as the next character. More...
 
#define SIO_BUF_COUNT   (3)
 
#define SIO_RX_BUF_SIZE   (32)
 
#define SIO_TX_BUF_SIZE   (156)
 
static uint8_t sio_rx_buf [SIO_RX_BUF_SIZE]
 This is the receive buffer 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 uint8_t * sio_rx_ptr
 This pointer points to the next free element inside the receive buffer of the UART. More...
 
static uint8_t sio_rx_state
 This is the receiver state of the UART. More...
 
static uint8_t sio_rx_length
 This is the transmit state of the UART. More...
 
static uint8_t data [SIO_RX_BUF_SIZE]
 This is the buffer to hold the frame received through serial interface. More...
 
static uint8_t data_length = 0
 This is length variable to keep track of no of received bytes. More...
 
static uint8_t rx_index = 0
 This is index used to validate the received bytes based on their position. More...
 
static uint8_t head = 0
 This is head of the queue of buffers to be transmitted. More...
 
static uint8_t buf_count = 0
 This is buffer count to keep track of the available bufer for transmission. More...
 
bool remote_cmd_rcvd = false
 This flag is used to check if a remote_test command has been received or not. More...
 
static uint8_t curr_tx_buffer_index = 0
 
static void process_incoming_sio_data (void)
 Process data received from SIO. More...
 
static uint8_t * get_next_tx_buffer (void)
 get the new buffer for next transmission through serial More...
 
static void handle_incoming_msg (void)
 Parses the Received Data in the Buffer and Process the Commands accordingly. More...
 
void init_sio (void)
 This function does the initialization of the Serial handler state Machine. More...
 
void serial_data_handler (void)
 Function to handle the state machine serial data exchange. More...
 
void convert_ota_serial_frame_rx (uint8_t *buf, uint8_t len)
 
More...
 
void usr_perf_start_confirm (uint8_t status, uint8_t start_mode, trx_config_params_t *trx_config_params, uint8_t peer_ic_type, char *peer_soc_mcu_name, char *peer_trx_name, char *peer_board_name, uint64_t peer_mac_address, float peer_fw_version, uint32_t peer_feature_mask)
 Function to generate Perf Start confirmation frame that must be sent to host application via serial interface. More...
 
void usr_per_test_start_confirm (uint8_t status)
 Function to generate Per Test Start confirmation frame that must be sent to host application via serial interface. More...
 
void usr_range_test_beacon_tx (uint8_t *frame)
 Function to send the transmitted frame to the Host application. More...
 
void usr_range_test_beacon_rsp (uint8_t *mpdu, uint8_t lqi_h, int8_t ed_h, uint8_t lqi_r, int8_t ed_r)
 Function to send the Received Range Test Response frame to the Host application. More...
 
void usr_range_test_marker_ind (uint8_t *mpdu, uint8_t lqi, int8_t ed_value)
 Function to send the Marker Indication frame to the Host application. More...
 
void usr_range_test_start_confirm (uint8_t status)
 Function to generate Range Test Start confirmation frame that must be sent to host application via serial interface. More...
 
void convert_ota_serial_frame_tx (uint8_t *buf, uint8_t len)
 The Received Remote Reply Command is converted into Serial Data and sent to the Host interface. More...
 
void usr_range_test_stop_confirm (uint8_t status)
 Function to generate Range Test Stop confirmation frame that must be sent to host application via serial interface. More...
 
void usr_perf_set_confirm (uint8_t status, uint8_t param_type, param_value_t *param_value)
 Function to generate Perf Set confirmation frame that must be sent to host application via serial interface. More...
 
void usr_perf_get_confirm (uint8_t status, uint8_t param_type, param_value_t *parame_value)
 Function to generate Perf Get confirmation frame that must be sent to host application via serial interface. More...
 
void usr_identify_peer_node_confirm (uint8_t status)
 Function to generate Identify_peer_cnode_confirm that must be sent to host application via serial interface. More...
 
void usr_cont_pulse_tx_confirm (uint8_t status)
 Function to generate cont_pulse_tx_confirm that must be sent to host application via serial interface. More...
 
void usr_cont_wave_tx_confirm (uint8_t status, bool start_stop_param, uint8_t tx_mode)
 Function to generate cont_wave_tx_confirm that must be sent to host application via serial interface. More...
 
void usr_register_read_confirm (uint8_t status, uint16_t reg_addr, uint8_t reg_val)
 Function to generate usr_register_read_confirm that must be sent to host application via serial interface. More...
 
void usr_register_write_confirm (uint8_t status, uint16_t reg_addr, uint8_t reg_val)
 Function to generate usr_register_write_confirm that must be sent to host application via serial interface. More...
 
void usr_register_dump_confirm (uint8_t status, uint16_t start_reg_addr, uint16_t end_reg_addr, uint8_t *reg_val)
 Function to generate usr_register_dump_confirm that must be sent to host application via serial interface. More...
 
void usr_per_test_end_indication (uint8_t status, int8_t rssi_val, uint8_t aver_lqi, uint32_t frames_transmitted, uint32_t frames_received, uint32_t frames_failure, uint32_t frames_no_ack, uint32_t frames_channel_access_failure, uint32_t frames_with_wrong_crc, float test_duration_sec, float test_net_data_rate)
 Function to generate Per test End Indication frame that must be sent to host application via serial interface. More...
 
void usr_ed_scan_start_confirm (uint8_t status, uint8_t scan_time_min, float scan_time_sec)
 Function to generate ED scan confirm test End Indication frame that must be sent to host application via serial interface. More...
 
void usr_pkt_stream_confirm (uint8_t status, bool start_stop)
 
void usr_rx_on_confirm (uint8_t status, bool start_stop)
 
void usr_ed_scan_end_indication (uint8_t no_of_channels, ed_scan_result_t *ed_scan_result)
 Function to generate ED scan Indication frame that must be sent to host application via serial interface. More...
 
void usr_sensor_data_get_confirm (uint8_t status, float bat_voltage, float temperature)
 Function to generate Sensor data confirm frame that must be sent to host application via serial interface. More...
 
void usr_peer_disconnect_confirm (uint8_t status)
 Function to generate Disconnect Confirm frame that must be sent to host application via serial interface. More...
 
void usr_set_default_config_confirm (uint8_t status, trx_config_params_t *default_trx_config_params)
 Function to generate Set default config Confirm frame that must be sent to host application via serial interface. More...
 
void usr_identify_board_confirm (uint8_t status, uint8_t ic_type, const char *mcu_soc_name, const char *trx_name, const char *board_name, uint64_t mac_address, float fw_version, uint32_t fw_feature_mask)
 Function to generate Identify Board confirm frame that must be sent to host application via serial interface. More...
 
void usr_get_current_config_confirm (uint8_t status, trx_config_params_t *curr_trx_conf_params)
 Function to generate Get Current config Confirm frame that must be sent to host application via serial interface. More...