u16 N PHY Gen Load Samples (u32 freq, u16 max, u8 test)
This routine uses a macro CONVERT(X) defined as (((X) >= 0) ? ((((X) >> 15) + 1) >> 1) : -((((-(X)) >> 15) + 1) >> 1))
- If the band width is 40 MHz
- Set bw to 40
- Otherwise
- Set bw to 20
Set len to bw << 3
- If test is 1
- Read PHY Register 0x01, right shift by 15 and mask with 1
- If the result of the previous step is 1
- Set bw to 82
- Otherwise
- Set bw to 80
- If the band width is 40 MHz
Set bw to bw << 1
Set len to bw << 1
- Allocate a complex u32 buffer of length len
Set rot to (((freq * 36) / bw) << 16) / 100
- Set angle to 0
- Loop len times with i as index
Call PHY Cordic with angle and buffer[i] as arguments
- Increase angle by rot
- Set buffer[i].q to CONVERT(buffer[i].q * max)
- Set buffer[i].i to CONVERT(buffer[i].i * max)
Call N PHY Load Sample Table with buffer, len as arguments
- Free buffer
- Return len