49 #define rInterrupt_CORTUS_0 (0x10a8) 50 #define rInterrupt_CORTUS_1 (0x10ac) 51 #define rInterrupt_CORTUS_2 (0x10b0) 53 #define rBurstTx_NMI_TX_RATE (0x161d00) 54 #define rBurstTx_NMI_NUM_TX_FRAMES (0x161d04) 55 #define rBurstTx_NMI_TX_FRAME_LEN (0x161d08) 56 #define rBurstTx_NMI_TX_CW_PARAM (0x161d0c) 57 #define rBurstTx_NMI_TX_GAIN (0x161d10) 58 #define rBurstTx_NMI_TX_DPD_CTRL (0x161d14) 59 #define rBurstTx_NMI_USE_PMU (0x161d18) 60 #define rBurstTx_NMI_TEST_CH (0x161d1c) 61 #define rBurstTx_NMI_TX_PHY_CONT (0x161d20) 62 #define rBurstTx_NMI_TX_CW_MODE (0x161d24) 63 #define rBurstTx_NMI_TEST_XO_OFF (0x161d28) 64 #define rBurstTx_NMI_USE_EFUSE_XO_OFF (0x161d2c) 66 #define rBurstTx_NMI_MAC_FILTER_ENABLE_DA (0x161d30) 67 #define rBurstTx_NMI_MAC_ADDR_LO_PEER (0x161d34) 68 #define rBurstTx_NMI_MAC_ADDR_LO_SELF (0x161d38) 69 #define rBurstTx_NMI_MAC_ADDR_HI_PEER (0x161d3c) 70 #define rBurstTx_NMI_MAC_ADDR_HI_SELF (0x161d40) 71 #define rBurstTx_NMI_RX_PKT_CNT_SUCCESS (0x161d44) 72 #define rBurstTx_NMI_RX_PKT_CNT_FAIL (0x161d48) 73 #define rBurstTx_NMI_SET_SELF_MAC_ADDR (0x161d4c) 74 #define rBurstTx_NMI_MAC_ADDR_LO_SA (0x161d50) 75 #define rBurstTx_NMI_MAC_ADDR_HI_SA (0x161d54) 76 #define rBurstTx_NMI_MAC_FILTER_ENABLE_SA (0x161d58) 78 #define rBurstRx_NMI_RX_ALL_PKTS_CONT (0x9898) 79 #define rBurstRx_NMI_RX_ERR_PKTS_CONT (0x988c) 81 #define TX_DGAIN_MAX_NUM_REGS (4) 82 #define TX_DGAIN_REG_BASE_ADDRESS (0x1240) 83 #define TX_GAIN_CODE_MAX_NUM_REGS (3) 84 #define TX_GAIN_CODE_BASE_ADDRESS (0x1250) 85 #define TX_PA_MAX_NUM_REGS (3) 86 #define TX_PA_BASE_ADDRESS (0x1e58) 90 volatile static uint8 gu8AteIsRunning = 0;
91 volatile static uint8 gu8RxState = 0;
92 volatile static uint8 gu8TxState = 0;
93 volatile static uint32 gaAteFwTxRates[M2M_ATE_MAX_NUM_OF_RATES] =
95 0x01, 0x02, 0x05, 0x0B,
96 0x06, 0x09, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x36,
97 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87
104 static void m2m_ate_set_rx_status(
uint8 u8Value)
106 gu8RxState = u8Value;
109 static void m2m_ate_set_tx_status(
uint8 u8Value)
111 gu8TxState = u8Value;
132 s8Ret =
nm_drv_init(&u8WifiMode, req_serial_number);
147 sint8 m2m_ate_deinit(
void)
171 if((M2M_ATE_FW_STATE_STOP == u8State) && (M2M_ATE_FW_STATE_STOP != gu8AteIsRunning))
174 u32Val &= ~(1 << 10);
176 gu8AteIsRunning = M2M_ATE_FW_STATE_STOP;
178 else if((M2M_ATE_FW_STATE_RUN == u8State) && (M2M_ATE_FW_STATE_RUN != gu8AteIsRunning))
201 if((u32Val & (1ul << 10)) == (1ul << 10))
203 u32Val &= ~(1ul << 10);
211 u32Val |= (1ul << 10);
217 gu8AteIsRunning = M2M_ATE_FW_STATE_RUN;
221 s8Ret = M2M_ATE_ERR_UNHANDLED_CASE;
225 if((
M2M_SUCCESS == s8Ret) && (M2M_ATE_FW_STATE_RUN == gu8AteIsRunning))
244 sint8 m2m_ate_get_fw_state(
void)
246 return gu8AteIsRunning;
265 if(M2M_ATE_MAX_NUM_OF_RATES <= u8Index)
269 return gaAteFwTxRates[u8Index];
284 sint8 m2m_ate_get_tx_status(
void)
303 sint8 m2m_ate_start_tx(tstrM2mAteTx * strM2mAteTx)
306 uint8 u8LoopCntr = 0;
310 if(
NULL == strM2mAteTx)
312 s8Ret = M2M_ATE_ERR_VALIDATE;
316 if(0 != m2m_ate_get_tx_status())
318 s8Ret = M2M_ATE_ERR_TX_ALREADY_RUNNING;
322 if(0 != m2m_ate_get_rx_status())
324 s8Ret = M2M_ATE_ERR_RX_ALREADY_RUNNING;
328 if( (strM2mAteTx->channel_num < M2M_ATE_CHANNEL_1) ||
329 (strM2mAteTx->channel_num > M2M_ATE_CHANNEL_14) ||
330 (strM2mAteTx->tx_gain_sel < M2M_ATE_TX_GAIN_DYNAMIC) ||
331 (strM2mAteTx->tx_gain_sel > M2M_ATE_TX_GAIN_TELEC) ||
332 (strM2mAteTx->frame_len > M2M_ATE_MAX_FRAME_LENGTH) ||
333 (strM2mAteTx->frame_len < M2M_ATE_MIN_FRAME_LENGTH)
336 s8Ret = M2M_ATE_ERR_VALIDATE;
340 if( (strM2mAteTx->duty_cycle < M2M_ATE_TX_DUTY_MAX_VALUE ) ||
341 (strM2mAteTx->duty_cycle > M2M_ATE_TX_DUTY_MIN_VALUE ) ||
342 (strM2mAteTx->dpd_ctrl < M2M_ATE_TX_DPD_DYNAMIC) ||
343 (strM2mAteTx->dpd_ctrl > M2M_ATE_TX_DPD_ENABLED) ||
344 (strM2mAteTx->use_pmu < M2M_ATE_PMU_DISBLE) ||
345 (strM2mAteTx->use_pmu > M2M_ATE_PMU_ENABLE) ||
346 (strM2mAteTx->phy_burst_tx < M2M_ATE_TX_SRC_MAC) ||
347 (strM2mAteTx->phy_burst_tx > M2M_ATE_TX_SRC_PHY) ||
348 (strM2mAteTx->cw_tx < M2M_ATE_TX_MODE_NORM) ||
349 (strM2mAteTx->cw_tx > M2M_ATE_TX_MODE_CW)
352 s8Ret = M2M_ATE_ERR_VALIDATE;
356 for(u8LoopCntr=0; u8LoopCntr<M2M_ATE_MAX_NUM_OF_RATES; u8LoopCntr++)
358 if(gaAteFwTxRates[u8LoopCntr] == strM2mAteTx->data_rate)
364 if(M2M_ATE_MAX_NUM_OF_RATES == u8LoopCntr)
366 s8Ret = M2M_ATE_ERR_VALIDATE;
372 s8Ret +=
nm_write_reg(rBurstTx_NMI_USE_PMU, strM2mAteTx->use_pmu);
373 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_PHY_CONT, strM2mAteTx->phy_burst_tx);
374 s8Ret +=
nm_write_reg(rBurstTx_NMI_NUM_TX_FRAMES, strM2mAteTx->num_frames);
375 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_GAIN, strM2mAteTx->tx_gain_sel);
376 s8Ret +=
nm_write_reg(rBurstTx_NMI_TEST_CH, strM2mAteTx->channel_num);
377 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_FRAME_LEN, strM2mAteTx->frame_len);
378 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_CW_PARAM, strM2mAteTx->duty_cycle);
379 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_DPD_CTRL, strM2mAteTx->dpd_ctrl);
380 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_RATE, strM2mAteTx->data_rate);
381 s8Ret +=
nm_write_reg(rBurstTx_NMI_TX_CW_MODE, strM2mAteTx->cw_tx);
382 s8Ret +=
nm_write_reg(rBurstTx_NMI_TEST_XO_OFF, strM2mAteTx->xo_offset_x1000);
383 s8Ret +=
nm_write_reg(rBurstTx_NMI_USE_EFUSE_XO_OFF, strM2mAteTx->use_efuse_xo_offset);
385 val32 = strM2mAteTx->peer_mac_addr[5] << 0;
386 val32 |= strM2mAteTx->peer_mac_addr[4] << 8;
387 val32 |= strM2mAteTx->peer_mac_addr[3] << 16;
390 val32 = strM2mAteTx->peer_mac_addr[2] << 0;
391 val32 |= strM2mAteTx->peer_mac_addr[1] << 8;
392 val32 |= strM2mAteTx->peer_mac_addr[0] << 16;
398 m2m_ate_set_tx_status(1);
418 sint8 m2m_ate_stop_tx(
void)
425 m2m_ate_set_tx_status(0);
443 sint8 m2m_ate_get_rx_status(
void)
462 sint8 m2m_ate_start_rx(tstrM2mAteRx * strM2mAteRxStr)
466 if(
NULL == strM2mAteRxStr)
468 s8Ret = M2M_ATE_ERR_VALIDATE;
472 if(0 != m2m_ate_get_tx_status())
474 s8Ret = M2M_ATE_ERR_TX_ALREADY_RUNNING;
478 if(0 != m2m_ate_get_rx_status())
480 s8Ret = M2M_ATE_ERR_RX_ALREADY_RUNNING;
484 if( (strM2mAteRxStr->channel_num < M2M_ATE_CHANNEL_1) ||
485 (strM2mAteRxStr->channel_num > M2M_ATE_CHANNEL_14)||
486 (strM2mAteRxStr->use_pmu < M2M_ATE_PMU_DISBLE) ||
487 (strM2mAteRxStr->use_pmu > M2M_ATE_PMU_ENABLE)
490 s8Ret = M2M_ATE_ERR_VALIDATE;
494 s8Ret +=
nm_write_reg(rBurstTx_NMI_TEST_CH, strM2mAteRxStr->channel_num);
495 s8Ret +=
nm_write_reg(rBurstTx_NMI_USE_PMU, strM2mAteRxStr->use_pmu);
496 s8Ret +=
nm_write_reg(rBurstTx_NMI_TEST_XO_OFF, strM2mAteRxStr->xo_offset_x1000);
497 s8Ret +=
nm_write_reg(rBurstTx_NMI_USE_EFUSE_XO_OFF, strM2mAteRxStr->use_efuse_xo_offset);
499 if(strM2mAteRxStr->override_self_mac_addr)
501 val32 = strM2mAteRxStr->self_mac_addr[5] << 0;
502 val32 |= strM2mAteRxStr->self_mac_addr[4] << 8;
503 val32 |= strM2mAteRxStr->self_mac_addr[3] << 16;
506 val32 = strM2mAteRxStr->self_mac_addr[2] << 0;
507 val32 |= strM2mAteRxStr->self_mac_addr[1] << 8;
508 val32 |= strM2mAteRxStr->self_mac_addr[0] << 16;
512 if(strM2mAteRxStr->mac_filter_en_sa)
514 val32 = strM2mAteRxStr->sa_mac_addr[5] << 0;
515 val32 |= strM2mAteRxStr->sa_mac_addr[4] << 8;
516 val32 |= strM2mAteRxStr->sa_mac_addr[3] << 16;
519 val32 = strM2mAteRxStr->sa_mac_addr[2] << 0;
520 val32 |= strM2mAteRxStr->sa_mac_addr[1] << 8;
521 val32 |= strM2mAteRxStr->sa_mac_addr[0] << 16;
525 nm_write_reg(rBurstTx_NMI_MAC_FILTER_ENABLE_DA, strM2mAteRxStr->mac_filter_en_da);
526 nm_write_reg(rBurstTx_NMI_MAC_FILTER_ENABLE_SA, strM2mAteRxStr->mac_filter_en_sa);
527 nm_write_reg(rBurstTx_NMI_SET_SELF_MAC_ADDR, strM2mAteRxStr->override_self_mac_addr);
532 m2m_ate_set_rx_status(1);
552 sint8 m2m_ate_stop_rx(
void)
554 m2m_ate_set_rx_status(0);
573 sint8 m2m_ate_read_rx_status(tstrM2mAteRxStatus *strM2mAteRxStatus)
577 if(
NULL == strM2mAteRxStatus)
579 s8Ret = M2M_ATE_ERR_VALIDATE;
583 if(0 != m2m_ate_get_tx_status())
585 s8Ret = M2M_ATE_ERR_TX_ALREADY_RUNNING;
591 strM2mAteRxStatus->num_rx_pkts =
nm_read_reg(rBurstTx_NMI_RX_PKT_CNT_SUCCESS) +
nm_read_reg(rBurstTx_NMI_RX_PKT_CNT_FAIL);
592 strM2mAteRxStatus->num_good_pkts =
nm_read_reg(rBurstTx_NMI_RX_PKT_CNT_SUCCESS);
593 strM2mAteRxStatus->num_err_pkts =
nm_read_reg(rBurstTx_NMI_RX_PKT_CNT_FAIL);
598 strM2mAteRxStatus->num_err_pkts =
nm_read_reg(rBurstRx_NMI_RX_ERR_PKTS_CONT);
599 strM2mAteRxStatus->num_good_pkts = strM2mAteRxStatus->num_rx_pkts - strM2mAteRxStatus->num_err_pkts;
617 sint8 m2m_ate_set_dig_gain(
double dGaindB)
619 uint32_t dGain, val32;
620 dGain = (uint32_t)(pow(10, dGaindB/20.0) * 1024.0);
623 val32 &= ~(0x1ffful << 0);
624 val32 |= (((uint32_t)dGain) << 0);
640 sint8 m2m_ate_get_dig_gain(
double * pdGaindB)
648 dGain = (val32 >> 0) & 0x1ffful;
649 *pdGaindB = 20.0*log10((
double)dGain / 1024.0);
674 * paGain = (val32 >> 8) & 0x3f;
698 * ppaGain = (val32 >> 5) & 0x7;
714 sint8 m2m_ate_get_tot_gain(
double * pTotGaindB)
716 double totGaindB, dGaindB;
717 uint32 paGain,ppaGain,m_cmbPAGainStep,m_cmbPPAGainStep;
720 m2m_ate_get_pa_gain(&paGain);
721 m2m_ate_get_ppa_gain(&ppaGain);
722 m2m_ate_get_dig_gain(&dGaindB);
751 m_cmbPPAGainStep = 2;
754 m_cmbPPAGainStep = 1;
757 m_cmbPPAGainStep = 0;
760 m_cmbPPAGainStep = 3;
764 totGaindB = dGaindB + 18 - m_cmbPAGainStep*3;
765 totGaindB += 9 - m_cmbPPAGainStep*3;
767 *pTotGaindB = totGaindB;
771 #endif //_M2M_ATE_FW_ signed char sint8
Range of values between -128 to 127.
This module contains WINC3400 M2M driver APIs declarations.
#define rNMI_BOOT_RESET_MUX
WINC3400 Peripherals Application Interface.
This module contains WINC3400 ASIC specific internal APIs.
void nm_bsp_sleep(uint32 u32TimeMsec)
sint8 nm_write_reg(uint32 u32Addr, uint32 u32Val)
#define M2M_ERR_INVALID_ARG
This module contains WINC3400 bus APIs implementation.
sint8 nm_drv_deinit(void *arg)
sint8 nm_drv_init(void *arg, uint32 req_serial_number)
unsigned long uint32
Range of values between 0 to 4294967295.
This module contains WINC3400 BSP APIs declarations.
unsigned char uint8
Range of values between 0 to 255.
This module contains M2M host interface APIs implementation.
uint32 nm_read_reg(uint32 u32Addr)