## LP PHY TX Power Recalc Target

- Define a u32 rate array with 12 elements
- Establish an LP PHY table with width = 32
- Set reset (u8) to 0
- If the PHY revision is less than 2
- Set the table ID to 10

- Otherwise
- Set the table ID to 7

- Loop from 0 to 11 (inclusive) in steps of 1 using loop variable i
Set the i'th element of the rate array to the negative of the i'th element of Transmit power offset

- Set the table length to 12, the table offset to 0x40, and the table data pointer to the rate array
Write the LP PHY Table

- Convert the current channel to frequency (MHz) and save as frequency (u16)
If Target TX frequency is not equal to frequency

- If frequency less than 2500
- Else if frequency less than 5321
Set b0 to txpa low[0]

Set b1 to txpa low[1]

Set a1 to txpa low[2]

- Else if frequency less than 5701
- Otherwise
Set b0 to txpa high[0]

Set b1 to txpa high[1]

Set a1 to txpa high[2]

- Set the table data pointer to power (int), the table length to 1, and the table offset to 0
- Loop from 0 to 63 (inclusive) in steps of 1 with tssi (int) as the loop variable
Using LP PHY Tssi to dBm, convert tssi, a1, b0, and b1 to dBm and save the result in power

Write the LP PHY Table

- Increment the table offset

Set Target TX frequency to frequency

- Set reset to 1

Read PHY Register 0x4A7, and bitwise AND with 0xFF

If the result obtained in the previous step is not equal to Transmit power minimum

MaskSet PHY Register 0x4A7 with mask 0xFF00 and set with Transmit power minimum

- Set reset to 1

- If reset equal to 1