bcm-v4 [Specification]

## A PHY

### measure one value

#### PHY revisions bigger than two

Set bit 0x04 in PHY Register 3, then set the lower two bits of the same to 1. Read PHY Register 0x7F and multiply by 4 to get the result.

#### other PHY revisions

Write the saved value to PHY Register 0x7C, then read PHY Register 0x7D until bit 0x100 is set, delaying 10 microseconds after each read. If it doesn't happen in ten tries, use 0, otherwise the lower 8 bits of the read value. Afterwards, write the saved value to PHY Register 0x7C again.

### measure the PHY noise

Lock both PHY and radio registers against Microcode access during this measurement.

1. Save radio register 0x13 and clear bit 0x10 in it. Save radio register 0x03 as well.

2. If the PHY revision is less than two, save PHY register 0x7A, set the lowest 3 bits of PHY register 0x03 to 5, clear bits 0xF00 in PHY Register 0x7A and save PHY Register 0x7C.

3. Measure 20 values and calculate the average.
4. Restore radio register 0x13 and if applicable PHY register 0x7A.

5. Multiply the average by -5, add 8, divide by 16 and finally subtract 67.
6. Clamp the result to [-90, -25] (why, I wonder)

## B/G PHY

The microcode continually measures the raw PHY noise and stores it into SHM at offset 0x6E.

If the board has an ADC divider, clamp the value to [0,63] and look it up in the NRSSI table. Subtract that from 31, multiply the result by -131. Shift that value down by 7 and subtract 67.

If the board has no ADC divider, subtract the raw PHY noise from 31 and multiply the result by -149. Shift that value down by 7 and subtract 68.

If the result is bigger than -35, add 15.

Exported/Archived from the wiki to HTML on 2016-10-27