int NPHY ACI Scan W2based
Set u16 repeat_ctr to nphy_aci.detect_repeat_ctr
Set u16 nsamps to nphy_aci.detect_num_samples
- Set u16 min_valid_samples to nsamps / 8
- Set u16 sleep_us to 10
- Set u16 array clip_off to { 0xFFFF, 0xFFFF }
- Set s8 w2_thresh to 22
- Set s8 array w2_range to { 22, 14, 11, 0, -20, -25, -33 }
- Set u32 array adc_range to { 1000, 2000, 10000, 30000, 60000, 90000 }
- Set u32 num_ranges to 6
- Set int aci to 0
- Set s8 minw2 to 32
Call N PHY Classifier with arguments ( 0, 0 ) and save result in u16 classifier_state
Call N PHY Classifier with arguments ( 7, 4 )
Call N PHY Clip Det with arguments ( 0, clip_state) (2 - element u16 array)
Call N PHY Clip Det with arguments ( 1, clip_off )
Call N PHY RF Control Override with arguments ( 0x400 0xAC, 0x3, 0 )
Read PHY Register 0x91 and save result in rfctrlintc1
Read PHY Register 0x92 and save result in rfctrlintc2
Write 0x120 to PHY Registers 0x91 and 0x92
Call NPHY Force RFseq with argument 2
Read PHY Register 0x66 and save result in rxrf_spc1
Read PHY Register 0x95 and save result in rxrf_spc2
Set bits 0x0C in PHY Registers 0x66 and 0x95
Set bits 0x7 in PHY Registers 0xCD and 0xD9
Clear bit 2 in PHY Registers 0x66 and 0x95
Read PHY Register 0x71 and save in core1_rxbb_rccal_ctrl
Read PHY Register 0x95 and save in core2_rxbb_rccal_ctrl
Write 0 to PHY Registers 0x71 and 0x95
Read PHY Register 0xCA and save in gpiosel
Call NPHY Select RSSI Select with arguments ( 5, 1 )
- Loop 2 times using core as an index
Write core + 6 to PHY Register 0xCA
- Loop repeat_ctr times using ctr as the index
- Loop 2 times using iq as the index
- Set pwr_ctr, avg_adcpwr, and avgw2 to 0
- Loop nsamp times using samp as the index
- If iq is zero
Read PHY Register 0x1C9 and save as gpio
- Otherwise
Read PHY Register 0x1CA and save as gpio
Set adc_code to ((gpio & 0x3FF) << 6 ) >> 6
Set w2 (((gpio >> 10) & 0x3F) << 2 ) >> 2
If w2 <= w2_thresh
- Add w2 to avgw2
- Add adc_code squared to avg_adcpwr
- Increment pwr_ctr
- If iq is zero
If pwr_ctr > min_valid_samples
- Divide avg_adcpwr by pwr_ctr to get average
- Divide avgw2 by pwr_ctr to get average
- Loop num_ranges times using w2_ctr as index
- Set w2_l to w2_range[w2_ctrl]
- Set w2_r to w2_range[w2_ctrl + 1]
If awgw2 <= w2_l AND avgw2 > w2_r AND avg_adcpwr < adc_range[w2_ctr]
- Set aci to 1
If avgw2 < minw2
- Set minw2 to avgw2
- Loop 2 times using iq as the index
- Delay 10 usec
Write gpiosel to PHY Register 0xCA
Call NPHY RSSI Select with arguments ( 0, 0 )
Write core1_rxbb_rccal_ctrl to Radio Register 0x71
Write core2_rxbb_rccal_ctrl to Radio Register 0xA0
Write rxrf_spc1 to Radio Register 0x66
Write rxrf_spc2 to Radio Register 0x95
Write lna_gainbst1 to Radio Register 0xCD
Write lna_gainbst2 to Radio Register 0xD9
Write rfctrlintc1 to PHY Register 0x91
Write rfctrlintc2 to PHY Register 0x92
Call NPHY RF Control Override with arguments ( 0x400, 0, 3, 1 )
Call NPHY Force RF Seq with argument 2
Call NPHY Clip Det with arguments ( 1, clip_state )
Call NPHY Classifier with arguments ( 7, classifier_state )
- If aci is zero
- Set aci_pwr to 0
- Otherwise
If minw2 >= 18
- Set aci_pwr to 1
Else if minw2 >= -20
- Set aci_pwr to 2
- Otherwise
- Set aci_pwr to 3
- Return aci_pwr