Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / drivers / ao_cc1200.c
index 9d3b77cbdf87561d56a8eb69b807927d4b041ce4..4ddc96ce09b2dec483e722ea4b03c77ac9858527 100644 (file)
@@ -716,6 +716,7 @@ ao_radio_get(uint8_t len)
 {
        static uint32_t last_radio_setting;
        static uint8_t  last_radio_rate;
+       static uint8_t  last_radio_10mw;
 
        ao_mutex_get(&ao_radio_mutex);
 
@@ -732,6 +733,18 @@ ao_radio_get(uint8_t len)
                ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET;
                last_radio_rate = ao_config.radio_rate;
        }
+       if(ao_config.radio_10mw != last_radio_10mw) {
+               last_radio_10mw = ao_config.radio_10mw;
+               /*
+                * 0x37 "should" be 10dBm, but measurements on TBT
+                * v4.0 show that too hot, so use * 0x32 to make sure 
+                * we're in spec.
+                */
+               if (ao_config.radio_10mw)
+                       ao_radio_reg_write(CC1200_PA_CFG1, 0x32);
+               else
+                       ao_radio_reg_write(CC1200_PA_CFG1, 0x3f);
+       }
        ao_radio_set_len(len);
 }