195 lines
5.7 KiB
C
195 lines
5.7 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.
|
|
|
|
****************************************************************************/
|
|
/* os shim includes */
|
|
#include "os_types.h"
|
|
#include "os_utils.h"
|
|
#include "platform.h"
|
|
|
|
/* common includes */
|
|
#include "iot_io.h"
|
|
#include "iot_bitops.h"
|
|
|
|
/* driver includes */
|
|
#include "iot_uart.h"
|
|
#include "uart.h"
|
|
#include "iot_io.h"
|
|
#include "dbg_io.h"
|
|
#include "iot_errno_api.h"
|
|
|
|
#include "rf_mac_main.h"
|
|
#include "rf_mac_tx.h"
|
|
#include "rf_mac_rx.h"
|
|
#include "rf_mac_bb_common.h"
|
|
#include "rf_mac_isr_test.h"
|
|
#include "iot_gptmr_api.h"
|
|
#include "rf_hw_tonemap.h"
|
|
#include "phy_rf_chn.h"
|
|
#include "plc_mpdu_header.h"
|
|
#include "mac_ntb_wrap_test.h"
|
|
#include "mac_zc_dtest.h"
|
|
|
|
static uint32_t rf_mac_start(uint8_t is_dtest, uint32_t case_id)
|
|
{
|
|
uint32_t ret = ERR_FAIL;
|
|
rf_mac_cfg_info_t rf_mac_cfg = { 0 };
|
|
|
|
iot_printf("rf mac testid:%d start!\n", case_id);
|
|
|
|
/* mac tx common init interface */
|
|
rf_tx_common_init();
|
|
|
|
/* mac rx common init interface */
|
|
rf_rx_common_init();
|
|
|
|
switch(case_id)
|
|
{
|
|
case RF_MAC_TEST_COMMON_TIMER_ID:
|
|
/* common timer can be executed correctly */
|
|
ret = rf_mac_common_timer_test();
|
|
break;
|
|
case RF_MAC_TEST_COMMON_IRQ_ID:
|
|
/* common irq can be executed correctly */
|
|
if (is_dtest) {
|
|
ret = rf_mac_intr_loop_entry(0xFFFFFFFF);
|
|
} else {
|
|
ret = rf_mac_intr_loop_entry(5);
|
|
}
|
|
break;
|
|
case RF_MAC_TEST_SCHE_CMD_ID:
|
|
/* single CMD can be executed correctly */
|
|
ret = rf_mac_cmd_test();
|
|
break;
|
|
case RF_MAC_TEST_SCHE_CMDLIST_ID:
|
|
/* cmdlist can be executed correctly */
|
|
ret = rf_mac_cmdlist_test();
|
|
break;
|
|
case RF_MAC_TEST_TDMA_FLOW_ID:
|
|
rf_mac_cfg.option = PHY_RF_OPTION1_1M;
|
|
rf_mac_cfg.delimiter = FC_DELIM_SOF;
|
|
rf_mac_cfg.nid = 0xb;
|
|
rf_mac_cfg.phr_mcs = MCS_ID_5;
|
|
rf_mac_cfg.pld_mcs = MCS_ID_4;
|
|
rf_mac_cfg.pld_blkz = BLOCK_SIZE_0;
|
|
rf_mac_cfg.is_bcast = 1;
|
|
/* TDMA flow can be executed correctly */
|
|
rf_mac_tdma_flow_test(&rf_mac_cfg);
|
|
break;
|
|
case RF_MAC_TEST_CSMA_FLOW_ID:
|
|
rf_mac_cfg.option = PHY_RF_OPTION1_1M;
|
|
rf_mac_cfg.delimiter = FC_DELIM_SOF;
|
|
rf_mac_cfg.nid = 0xb;
|
|
rf_mac_cfg.phr_mcs = MCS_ID_5;
|
|
rf_mac_cfg.pld_mcs = MCS_ID_4;
|
|
rf_mac_cfg.pld_blkz = BLOCK_SIZE_0;
|
|
rf_mac_cfg.is_bcast = 1;
|
|
/* CSMA flow can be executed correctly */
|
|
rf_mac_csma_flow_test(&rf_mac_cfg);
|
|
break;
|
|
case RF_MAC_TEST_RX_FLOW_ID:
|
|
rf_mac_cfg.option = PHY_RF_OPTION1_1M;
|
|
rf_mac_cfg.delimiter = FC_DELIM_SOF;
|
|
rf_mac_cfg.nid = 0xb;
|
|
rf_mac_cfg.phr_mcs = MCS_ID_5;
|
|
rf_mac_cfg.pld_mcs = MCS_ID_4;
|
|
rf_mac_cfg.pld_blkz = BLOCK_SIZE_0;
|
|
rf_mac_cfg.is_bcast = 1;
|
|
/* RX flow can be executed correctly */
|
|
rf_mac_rx_flow_test(&rf_mac_cfg);
|
|
break;
|
|
case MAC_NTB_OVER_WRAP_TEST_ID:
|
|
if (is_dtest) {
|
|
ret = mac_ntb_wrap_test(0xFFFFFFFF);
|
|
} else {
|
|
ret = mac_ntb_wrap_test(10);
|
|
}
|
|
break;
|
|
case RF_MAC_TEST_DEBUG_HWQ_ID:
|
|
rf_mac_cfg.option = PHY_RF_OPTION1_1M;
|
|
rf_mac_cfg.delimiter = FC_DELIM_SOF;
|
|
rf_mac_cfg.nid = 0xb;
|
|
rf_mac_cfg.phr_mcs = MCS_ID_5;
|
|
rf_mac_cfg.pld_mcs = MCS_ID_4;
|
|
rf_mac_cfg.pld_blkz = BLOCK_SIZE_0;
|
|
rf_mac_cfg.is_bcast = 1;
|
|
/* debug hwq can be executed correctly */
|
|
rf_mac_debug_hwq_flow_test(&rf_mac_cfg);
|
|
break;
|
|
case RF_MAC_TEST_HW_ZC_ID:
|
|
if (is_dtest) {
|
|
ret = dtest_mac_zc_entry(0xFFFFFFFF);
|
|
} else {
|
|
ret = dtest_mac_zc_entry(50);
|
|
}
|
|
break;
|
|
default:
|
|
if (is_dtest) {
|
|
while(1);
|
|
}
|
|
ret = ERR_INVAL;
|
|
break;
|
|
}
|
|
|
|
if (is_dtest) {
|
|
while(1);
|
|
}
|
|
|
|
iot_printf("rf mac testid:%d end. %d\n", case_id, ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void iot_module_init()
|
|
{
|
|
/*platform intialization*/
|
|
//platform_init();
|
|
|
|
iot_gp_timer_init();
|
|
/* start gp timer */
|
|
iot_gp_timer_set(0, 0xFFFFFFFF, 1);
|
|
iot_gp_timer_start(0);
|
|
#if 0
|
|
/* to generate the HEX file */
|
|
iot_print_config(false);
|
|
|
|
dbg_uart_init();
|
|
|
|
dbg_uart_stage1_init();
|
|
|
|
/* init common modules */
|
|
iot_bitops_init();
|
|
#endif
|
|
}
|
|
|
|
/* is_dtest: 1 - dtest case, while(1) loop, 0 - cmd test case */
|
|
uint32_t rf_mac_main(uint8_t is_dtest, uint32_t case_id)
|
|
{
|
|
iot_printf("%s. mode:%d, case:%d\n", __FUNCTION__, is_dtest, case_id);
|
|
iot_module_init();
|
|
|
|
return rf_mac_start(is_dtest, case_id);
|
|
}
|
|
|
|
#if 0
|
|
/* to generate the HEX file */
|
|
int main()
|
|
{
|
|
iot_module_init();
|
|
|
|
rf_mac_start(0);
|
|
|
|
return 0;
|
|
}
|
|
#endif
|