Microchip® Advanced Software Framework

atpl230.c File Reference

ATPL230 Physical layer.

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

#include <stdio.h>
#include <string.h>
#include "atpl230.h"
#include "atpl230_reg.h"
#include "atpl230_version.h"
#include "atpl230_iir_filter.h"
#include "conf_atpl230.h"
#include "conf_phy.h"
#include "asf.h"

Macros

#define MOL_MINIMUM   21
 
#define PHY_TX_MIN_DELAY   10 /* 100 us. */
 
#define VCRC_TYPES_NUMBER   4
 
#define REG_ATPL230_PHY_TX_INIT_ADDRESS   0x0000
 
#define REG_ATPL230_PHY_RX_INIT_ADDRESS   (REG_ATPL230_PHY_TX_INIT_ADDRESS + PHY_MAX_PPDU_SIZE * PHY_NUM_TX_BUFFERS)
 
#define REG_ATPL230_PHY_NOISE_INIT_ADDRESS   0x0000
 
#define MAC_GEN_HEADER_SIZE   9
 
#define MAC_HEADER_SIZE   7
 
#define PHY_DMA_OFFSET   16
 
#define ATT_0dB   0xFF
 
#define ATT_1dB   0xE3
 
#define ATT_2dB   0xCA
 
#define ATT_3dB   0xB4
 
#define ATT_4dB   0xA0
 
#define ATT_5dB   0x8F
 
#define ATT_6dB   0x7F
 
#define ATT_7dB   0x71
 
#define ATT_8dB   0x65
 
#define ATT_9dB   0x5A
 
#define ATT_10dB   0x50
 
#define ATT_11dB   0x47
 
#define ATT_12dB   0x40
 
#define ATT_13dB   0x39
 
#define ATT_14dB   0x32
 
#define ATT_15dB   0x2D
 
#define ATT_16dB   0x28
 
#define ATT_17dB   0x24
 
#define ATT_18dB   0x20
 
#define ATT_19dB   0x1C
 
#define ATT_20dB   0x19
 
#define ATT_21dB   0x16
 
#define PHY_TX_TIMEOUT_IMMEDIATE   750 /* 750 ms */
 
#define PHY_TX_TIMEOUT_IMMEDIATE_10US   PHY_TX_TIMEOUT_IMMEDIATE * 100
 
#define PHY_TX_TIMEOUT_DELAYED   1500 /* 1.5 second */
 
#define PHY_TX_TIMEOUT_DELAYED_10US   PHY_TX_TIMEOUT_DELAYED * 100
 
#define MAX_LEN_DBPSK   39
 
#define MAX_LEN_DBPSK_VTB   63
 
#define MAX_LEN_DQPSK   18
 
#define MAX_LEN_DQPSK_VTB   39
 
#define MAX_LEN_D8PSK   11
 
#define MAX_LEN_D8PSK_VTB   25
 
#define MAX_LEN_DBPSK_ROBO   (MAX_LEN_DBPSK_VTB << 2)
 
#define MAX_LEN_DQPSK_ROBO   (MAX_LEN_DQPSK_VTB << 2)
 
#define VCRC8_POLYNOM   0x00000007
 
#define VCRC8_RST   0x00000000
 
#define VCRC8_CONF   0xC0
 
#define VCRC16_POLYNOM   0x00000107
 
#define VCRC16_RST   0x00000000
 
#define VCRC16_CONF   0xC1
 
#define VCRC24_POLYNOM   0x00010107
 
#define VCRC24_RST   0x00000000
 
#define VCRC24_CONF   0xC2
 
#define VCRC32_POLYNOM   0x04C11DB7
 
#define VCRC32_RST   0x00000000
 
#define VCRC32_CONF   0xC3
 

Functions

static uint32_t _get_crc (uint8_t uc_crc_type, uint8_t *puc_buf, uint16_t us_len, uint8_t uc_header_type)
 Get CRC value from the buffer content. More...
 
static void _init_IIR_filter (void)
 Filter IIR initialization. More...
 
static void _init_phy_layer (uint8_t uc_rst_type)
 PHY init layer. More...
 
static void _phy_rx_task (void)
 Task to process RX PLC. More...
 
static void _phy_tx_result_task (void)
 Task to process TX PLC. More...
 
static void _reset_rx_flag_interrupt (uint8_t uc_buf_idx)
 Reset reception interrupt. More...
 
static void _store_filter_sec (uint8_t *puc_fir_data, uint8_t uc_cmd, uint8_t uc_num_rows, uint8_t uc_way_mode, uint8_t uc_start_mem_byte, uint8_t uc_inv_mode)
 Store Filter secuence. More...
 
static void _upd_sna_crc (uint8_t *puc_sna)
 Update CRC of SNA. More...
 
static uint8_t _update_channel (uint8_t uc_channel)
 Update channel in atpl230 device. More...
 
static void _update_emit1_mode (uint8_t uc_emode)
 Update emit 1 mode in atpl230 device. More...
 
static void _update_emit2_mode (uint8_t uc_emode)
 Update emit 2 mode in atpl230 device. More...
 
static void _update_txrx1_polarity (uint8_t uc_pol)
 Update polarity of TXRX 1 in atpl230 device. More...
 
static void _update_txrx2_polarity (uint8_t uc_pol)
 Update polarity of TXRX 2 in atpl230 device. More...
 
void Dummy_serial_if_init (void)
 Dummy Phy Tester Tool Serialization Addon. More...
 
void Dummy_sniffer_if_init (uint8_t uc_enable_led)
 Dummy Phy Sniffer Serialization Addon. More...
 
void phy_handler (void)
 PHY interrupt management. More...
 
void serial_if_init (void)))
 Initialize serial interface. More...
 
void sniffer_if_init (uint8_t uc_enable_led)))
 Initialize sniffer interface. More...
 
ATPL230 Physical Layer Interface
void phy_tx_frame_result_cb (xPhyMsgTxResult_t *px_tx_result)
 Task to process TX PLC. More...
 
uint8_t phy_get_cfg_param (uint16_t us_id, void *p_val, uint16_t uc_len)
 Get PHY layer parameter. More...
 
uint8_t phy_set_cfg_param (uint16_t us_id, void *p_val, uint16_t uc_len)
 Set PHY layer parameter. More...
 
uint8_t phy_cmd_cfg_param (uint16_t us_id, uint8_t uc_cmd, uint8_t uc_mask)
 Set PHY layer parameter. More...
 
uint8_t phy_tx_frame (xPhyMsgTx_t *px_msg)
 Write the transmitted data with ATPL230 device. More...
 
void phy_rx_frame_cb (xPhyMsgRx_t *px_msg)
 Read the received data with ATPL230 device. More...
 
void phy_init (uint8_t uc_ifaceEnable)
 Create PHY tasks, queues and semaphores Initialize physical parameters and configure ATPL230 device. More...
 
void phy_reset (uint8_t uc_reset_type)
 Reset PHY layer including pplc service and serial ifaces Initialize physical parameters and configure ATPL230 device. More...
 

Variables

static atpl230_t atpl230
 
const float f_escalado_a22
 
const float f_escalado_a23
 
const float f_escalado_b22
 
const float f_escalado_b23
 
static uint8_t puc_phy_noise_buffer_event
 
static uint8_t puc_phy_rx_buffer_event [4]
 
static uint8_t puc_phy_tx_buffer_event [4]
 
static uint8_t const uc_att_value_tab [MOL_MINIMUM+1]
 
static uint8_t const uc_bc_mode_config_value [8]
 
static uint8_t const uc_crc_type_tab [3]
 
uint8_t uc_data_angle_real_imag_comp [LENGTH_DATA_ANGLE_REAL_IMAG_COMP]
 
uint8_t uc_data_chirp [LENGTH_DATA_CHIRP]
 
uint8_t uc_data_filter_IIR [LENGTH_DATA_FILTER_IIR]
 
static uint8_t const uc_emit_freq_tab [PHY_NUM_CHANNELS]
 
static uint8_t uc_last_rx_buf
 
static uint8_t uc_last_tx_buf
 
static uint8_t const uc_num_bytes_per_symbol_tab [16]
 
static uint8_t const uc_peak_cut_gain_tab [16]
 
static uint8_t uc_phy_headers_buffer [PHY_NUM_RX_BUFFERS][PHY_DMA_OFFSET]
 
static uint8_t uc_serial_ifaces_cfg
 
static uint16_t const uc_stop_time [MODE_NUM_EF]
 
static uint16_t const uc_time_X1 [MODE_NUM_EF]
 
static uint16_t const uc_time_X2 [MODE_NUM_EF]
 
static uint8_t const uc_time_Y1 [MODE_NUM_EF]
 
static uint8_t const uc_time_Y2 [MODE_NUM_EF]
 
static uint32_t const ul_channel_tx_tab [PHY_NUM_CHANNELS]
 
uint32_t ul_data_offset_correction [NUM_ROWS_DATA_OFFSET_CORRECTION]
 
static uint16_t us_phy_last_tx_lengths [PHY_NUM_TX_BUFFERS]
 
static const uint8_t v_crc_conf [VCRC_TYPES_NUMBER]
 
static const uint32_t v_crc_polynom [VCRC_TYPES_NUMBER]
 
static const uint32_t v_crc_rst [VCRC_TYPES_NUMBER]
 
static uint32_t v_crc_rst_sna [VCRC_TYPES_NUMBER]
 
atpl230ChnCfg_t atpl230ChnCfg
 
atpl230Cfg_t atpl230Cfg
 
static uint8_t phyTxAttChirpHighZ
 
static uint8_t phyTxAttSignalHighZ
 
static uint8_t phyTxAttChirpLowZ
 
static uint8_t phyTxAttSignalLowZ
 
static uint8_t phyTxAttChirpVLowZ
 
static uint8_t phyTxAttSignalVLowZ
 
static uint16_t phyTxLoadThreshold1
 
static uint16_t phyTxLoadThreshold2
 
static uint16_t phyTxLoadThreshold3
 
static uint16_t phyTxLoadThreshold4
 
static uint8_t uc_reg_rx_int
 
static uint8_t uc_reg_tx_int
 
static uint8_t uc_reg_ns_int
 
#define PEAK_CFG_ENABLE   0x80
 
#define PEAK_CFG_DISABLE   0
 
#define NOT_ALLOWED   0
 
static uint8_t const uc_peak_cut_on_enable_tab [16]
 
#define EMIT_GAIN_CHIRP   0x24
 
#define EMIT_GAIN_SIGNAL   0x1C
 
static uint8_t const uc_emit_gain_tab [16]