This function finds 4 gain values and takes in one value
If the PHY Revision is 1 or less OR PHY Connected isn't set
- The first gain value is 0x20
- The third gain value is 0
- If the absolute value of the first passed in value is 0x14 or higher
- The second gain value is 1
- The fourth gain value is 2
- Otherwise, if the first passed in value is 0x12 or higher
- The second gain value is 1
- The fourth gain value is 1
- Otherwise, if the first passed in value is 0xF or higher
- The second gain value is 1
- The fourth gain value is 0
- Otherwise,
- The second gain value is 0
- The fourth gain value is 0
- If the second gain value is 0
Unset bit 0x0008 in RadioRegister 0x7A
- Otherwise
Set bit 0x0008 in RadioRegister 0x7A
Otherwise
- Find the absolute value of the first passed in value
- The first gain value is 0
If PHYConnected is set and this is PHY Revision 2 or higher
If the absolute value of the first passed in value is >= the second Loopback Gain value / 2
Subtract the value of the second Loopback Gain value / 2 from the absolute value of the first passed in value and use this as the first passed in value
- The first gain value is 0x20
- If the first passed in value is 8 or less
- The second gain value is 0
- Otherwise
- The second gain value is 1
- Subtract 8 from the first passed in value and use this as the first passed in value
- Clamp the first passed in value between [0,0x2D]
- Divide the first passed in value by 3 and use this as the first passed in value
- If the value of the first passed in value is 5 or greater
- The third gain value is 2
- The fourth gain value is the first passed in value - 5
- Otherwise
- The third gain value is 0
- The fourth gain value is the first passed in value
- If the second gain value is 0
Unset bit 0x0008 in RadioRegister 0x7A
- Otherwise
Set bit 0x0008 in RadioRegister 0x7A