## LP PHY Start TX Tone (s32 f_kHz, u16 max_val)

This routine uses a macro CONVERT(X) defined as (((X) >= 0) ? ((((X) >> 15) + 1) >> 1) : -((((-(X)) >> 15) + 1) >> 1))

- Create a table structure
- Create a u16 data buffer of size 64
- Create a complex integer structure called tone_samp
Copy f_kHz to

**phy_tx_tone_freq**- If f_kHz is not zero
- Set a counter (k) to 1
- Start a loop
- Set bw to 20000 * k
- Set the number of samples to bw / abs(f_kHz) ?? Can f_kHz be negative
- Error if number of samples is greater than 63
- Increment k
- Repeat as long as the number of samples * abs(f_kHz) is not equal to bw

- Otherwise
- Set the number of samples to 2

Calculate rotation equal to (((36 * f_kHz)/20) << 16) /100

- Set starting angle to 0
- Loop from 0 through the number of samples (non-inclusive)
Perform the PHY Cordic routine with the angle and &tone_samp as arguments

- Add the rotation to the angle
- Calculate the imaginary part as CONVERT((tone_samp.i * max_val) masked with 0xFF)
- Calculate the real part as CONVERT((tone_samp.q * max_val) masked with 0xFF)
- Store imaginary part left-shifted by 8 and bitwise ORed by the real part into the data array using the loop index

- Set the table data pointer to the data buffer, the table length to the number of samples, and the table ID to 5
- Set the table offset to 0 and the table width to 16
Perform an LP table-write

Perform the LP PHY Run Samples with (number of samples, 0xFFFF, 0) as the arguments