147 lines
4.8 KiB
C
147 lines
4.8 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "os_types.h"
|
|
#include "iot_config.h"
|
|
#include "iot_io_api.h"
|
|
#include "mac_rf_isr.h"
|
|
#include "plc_protocol.h"
|
|
|
|
#if HPLC_RF_DEV_SUPPORT
|
|
|
|
#include "mac_rf_rx_buf_ring.h"
|
|
#include "mac_rf_rx_hw.h"
|
|
#include "mac_rf_common_hw.h"
|
|
#include "mac_rf.h"
|
|
|
|
void mac_rf_rx_hw_init()
|
|
{
|
|
mac_rf_set_pb_hdr_to_buf(0);
|
|
mac_rf_sw_isr_enable(RF_MAC_SW_ISR_RX_MPDU_COMPLETE);
|
|
}
|
|
|
|
uint32_t mac_rf_rx_debug_log_exception(iot_pkt_t *pkt)
|
|
{
|
|
#if (PLC_MAC_RX_DEBUG_LOG >= PLC_MAC_LOG_LEVEL_1)
|
|
uint8_t proto = PLC_PROTO_TYPE_SG;
|
|
rx_fc_msg_t rx_fc_msg = { 0 };
|
|
rf_rx_attention *att;
|
|
rf_rx_mpdu_start *mpdu_st;
|
|
|
|
uint8_t *data = iot_pkt_data(pkt);
|
|
att = (rf_rx_attention *)(data + RF_RX_ATTENTION_OFFSET);
|
|
mpdu_st = (rf_rx_mpdu_start *)(data + RF_RX_MPDU_START_OFFSET);
|
|
|
|
mac_rf_get_rx_frm_msg_from_fc(proto,
|
|
mac_rf_rx_mpdu_st_get_phr_addr(mpdu_st), &rx_fc_msg);
|
|
|
|
iot_printf("rx exception:status-%d, stei=%d, delim=%d\n",
|
|
att->rx_status, rx_fc_msg.src_tei, rx_fc_msg.delimiter);
|
|
#else
|
|
(void)pkt;
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
void mac_rf_rx_debug_log_sof_info(rx_fc_msg_t rx_fc_msg,
|
|
rf_rx_mpdu_start *mpdu_st, rf_rx_mpdu_end *mpdu_ed,
|
|
rf_rx_pb_start *pb_st, rf_rx_pb_end *pb_ed, rf_rx_attention *att)
|
|
{
|
|
#if (RF_MAC_RX_DEBUG_LOG >= PLC_MAC_LOG_LEVEL_1)
|
|
iot_printf("rf_rx_sof: bcast:%d, nid:0x%x, dtei:%d, stei:%d, "
|
|
"ssn:%d, st:%d, ed:%d,"
|
|
"1stpb:%d, last_pb:%d, retry:%d,"
|
|
"pb_num:%d, pbidx:%d, mcs:%d-%d,"
|
|
"gain:%d, snr:%d, rssi:%d, nf:%d, rxppm:%d - %d, ts:%u, crc:%d, "
|
|
"dlt:%d\n",
|
|
rx_fc_msg.bcast, rx_fc_msg.nid, rx_fc_msg.dst_tei, rx_fc_msg.src_tei,
|
|
mac_rf_rx_pb_st_get_pb_ssn(pb_st),
|
|
mac_rf_rx_pb_st_get_msdu_start(pb_st),
|
|
mac_rf_rx_pb_st_get_msdu_end(pb_st),
|
|
mac_rf_rx_pb_st_get_first_pb(pb_st),
|
|
mac_rf_rx_pb_st_get_last_pb(pb_st),
|
|
rx_fc_msg.retry,
|
|
mac_rf_rx_pb_st_get_rx_pb_cnt(pb_st),
|
|
rx_fc_msg.rf_pb_sz_idx,
|
|
att->phr_mcs,
|
|
rx_fc_msg.rf_mcs,
|
|
mac_rf_rx_mpdu_st_get_rx_gain(mpdu_st),
|
|
mac_rf_rx_mpdu_st_get_avg_snr(mpdu_st),
|
|
mac_rf_rx_mpdu_st_get_rssi(mpdu_st),
|
|
0, /* TODO: add get rf nf api */
|
|
/* 1/64 ppm */
|
|
mac_rf_rx_mpdu_st_get_rx_ppmhz(mpdu_st),
|
|
/* ppm */
|
|
mac_rf_rx_mpdu_st_get_rx_ppmhz(mpdu_st) >> PLC_NTB_PPM_SHIFT,
|
|
mac_rf_rx_mpdu_end_get_ntb_timestamp(mpdu_ed),
|
|
pb_ed->rx_pb_crc_err,
|
|
mac_rf_rx_pb_end_get_mismatch_dlt(pb_ed));
|
|
#else
|
|
(void)rx_fc_msg;
|
|
(void)mpdu_st;
|
|
(void)mpdu_ed;
|
|
(void)pb_st;
|
|
(void)pb_ed;
|
|
(void)att;
|
|
#endif
|
|
}
|
|
|
|
void mac_rf_rx_debug_log_bcn_info(rx_fc_msg_t *rx_fc_msg,
|
|
rf_rx_mpdu_start *mpdu_st, rf_rx_mpdu_end *mpdu_ed, rf_rx_pb_end *pb_ed)
|
|
{
|
|
#if (RF_MAC_RX_DEBUG_LOG >= PLC_MAC_LOG_LEVEL_1)
|
|
int32_t delta;
|
|
|
|
(void)mpdu_st;
|
|
delta = mac_rf_rx_mpdu_end_get_ntb_timestamp(mpdu_ed)
|
|
- rx_fc_msg->time_stamp;
|
|
|
|
iot_printf("rf_rx_bcn: nid:0x%x, "
|
|
"stei:%d, pbcrc:%d, pldcrc:%d, d_ts:%d, pbidx:%d, "
|
|
"mcs:%d, rxgain:%d, snr:%d, rssi:%d, nf:%d, rxppm:%d - %d, ts:%lu, "
|
|
"rx_ts:%u, lts:%u dlt:%d\n",
|
|
rx_fc_msg->nid,
|
|
rx_fc_msg->src_tei,
|
|
mac_rf_rx_pb_end_get_rx_pb_crc_err(pb_ed),
|
|
mac_rf_rx_pb_end_get_rx_bcn_pld_crc_err(pb_ed),
|
|
delta,
|
|
rx_fc_msg->rf_pb_sz_idx,
|
|
rx_fc_msg->rf_mcs,
|
|
mac_rf_rx_mpdu_st_get_rx_gain(mpdu_st),
|
|
mac_rf_rx_mpdu_st_get_avg_snr(mpdu_st),
|
|
mac_rf_rx_mpdu_st_get_rssi(mpdu_st),
|
|
0, /* TODO: add get rf nf api */
|
|
/* 1/64 ppm */
|
|
mac_rf_rx_mpdu_st_get_rx_ppmhz(mpdu_st),
|
|
/* ppm */
|
|
mac_rf_rx_mpdu_st_get_rx_ppmhz(mpdu_st) >> PLC_NTB_PPM_SHIFT,
|
|
rx_fc_msg->time_stamp,
|
|
mac_rf_rx_mpdu_end_get_ntb_timestamp(mpdu_ed),
|
|
mac_rf_rx_mpdu_end_get_local_timestamp(mpdu_ed),
|
|
mac_rf_rx_pb_end_get_mismatch_dlt(pb_ed)
|
|
);
|
|
|
|
//TODO: add flash log
|
|
#else
|
|
(void)rx_fc_msg;
|
|
(void)mpdu_st;
|
|
(void)mpdu_ed;
|
|
(void)pb_ed;
|
|
#endif
|
|
}
|
|
|
|
#endif /* HPLC_RF_DEV_SUPPORT */
|
|
|