Fix ADR channel mask handling
Fork of lmic_MOTE_L152RC by
Diff: radio.cpp
- Revision:
- 8:0faa1bb768b5
- Parent:
- 4:1a9a62cf220f
- Child:
- 9:83ae7f34e88c
diff -r 9095e54e381f -r 0faa1bb768b5 radio.cpp --- a/radio.cpp Mon Sep 21 17:59:42 2015 +0000 +++ b/radio.cpp Wed Oct 21 01:03:34 2015 +0000 @@ -399,7 +399,33 @@ DigitalOut pd2(PD_2); // power amplifier voltage control pin +/* pd2=0 pd2=1 +op pab rfo rfo +0 4.6 18.5 27.0 +1 5.6 21.1 28.1 +2 6.7 23.3 29.1 +3 7.7 25.3 30.1 +4 8.8 26.2 30.7 +5 9.8 27.3 31.2 +6 10.7 28.1 31.6 +7 11.7 28.6 32.2 +8 12.8 29.2 32.4 +9 13.7 29.9 32.9 +10 14.7 30.5 33.1 +11 15.6 30.8 33.4 +12 16.4 30.9 33.6 +13 17.1 31.0 33.7 +14 17.8 31.1 33.7 +15 18.4 31.1 33.7 +*/ +// txpow: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +static const u1_t boost_table[20] = { 0, 0, 0, 0, 0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15 }; + +// txpow: 20 21 22 23 24 25 26 27 28 29 30 +static const u1_t rfo_table[11] = { 1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 9 }; + static void configPower () { + printf("txpow:%d ", LMIC.txpow); #ifdef CFG_sx1276_radio // no boost used for now s1_t pw = (s1_t)LMIC.txpow; @@ -413,30 +439,17 @@ writeReg(RegPaDac, readReg(RegPaDac)|0x4); #elif defined(CFG_sx1272_radio) - // set PA config (2-17 dBm using PA_BOOST) - s1_t pw = (s1_t)LMIC.txpow; - /*if(pw > 17) { - pw = 17; - } else if(pw < 2) { - pw = 2; - }*/ + /* NA-mote TX power config: */ - if (pw > 23) { - // use RFO with external amplifier + if (LMIC.txpow > 19) { PaSelect = 0x00; // use RFO - writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-25))); - if (pw > 26) - pd2 = 1; - else - pd2 = 0; + writeReg(RegPaConfig, PaSelect | rfo_table[LMIC.txpow-20]); + pd2 = 0; } else { - // use PA_BOOST direct to antenna PaSelect = 0x80; // use PA_BOOST - if (pw > 17) - pw = 17; - writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-2))); + writeReg(RegPaConfig, PaSelect | boost_table[LMIC.txpow]); } - + //printf("PaConfig:%02x\r\n", readReg(RegPaConfig)); #else #error Missing CFG_sx1272_radio/CFG_sx1276_radio