GPIO retrabalhada e PABOOST selecionavel
Revision 6:f0616e516844, committed 2021-05-20
- Comitter:
- MatteusCarr
- Date:
- Thu May 20 21:24:36 2021 +0000
- Parent:
- 2:6c5853c2fd72
- Commit message:
- Atualizacao SX1272 LoRaRadio, retrabalho e PABOOST
Changed in this revision
diff -r 6c5853c2fd72 -r f0616e516844 SX1272/SX1272_LoRaRadio.cpp --- a/SX1272/SX1272_LoRaRadio.cpp Thu Nov 12 22:09:59 2020 +0000 +++ b/SX1272/SX1272_LoRaRadio.cpp Thu May 20 21:24:36 2021 +0000 @@ -49,8 +49,8 @@ enum RadioVariant { SX1272UNDEFINED = 0, - SX1272MB2XAS, - SX1272MB1DCS + SX1272PABOOST = 1, + SX1272NOPABOOST = 2, }; /*! @@ -174,7 +174,7 @@ _reset_ctl(reset), _dio0_ctl(dio0), _dio1_ctl(dio1), _dio2_ctl(dio2), _rf_switch_ctl1(rf_switch_ctl1, 0), _rf_switch_ctl2(rf_switch_ctl2, 0), _txctl(txctl, 0), _rxctl(rxctl, 0), - _ant_switch(antswitch, PIN_INPUT, PullUp, 0), + _ant_switch(antswitch, 0), _pwr_amp_ctl(pwr_amp_ctl), _tcxo(tcxo) @@ -816,7 +816,6 @@ _rf_settings.fsk_packet_handler.fifo_thresh = read_register(REG_FIFOTHRESH) & 0x3F; - printf("transmit fsk!\n"); break; @@ -926,7 +925,6 @@ _rf_settings.fsk_packet_handler.nb_bytes = 0; _rf_settings.fsk_packet_handler.size = 0; - printf("receive fsk!\n"); break; @@ -1345,8 +1343,11 @@ _pwr_amp_ctl = 0; } - if (_rf_ctrls.rf_switch_ctl1 != NC && _rf_ctrls.rf_switch_ctl2 != NC) { + if (_rf_ctrls.rf_switch_ctl1 != NC) { _rf_switch_ctl1 = 0; + } + + if (_rf_ctrls.rf_switch_ctl2 != NC) { _rf_switch_ctl2 = 0; } @@ -1361,11 +1362,10 @@ */ uint8_t SX1272_LoRaRadio::get_pa_conf_reg() { - if (radio_variant == SX1272UNDEFINED) { + if (radio_variant == SX1272PABOOST) { return RF_PACONFIG_PASELECT_PABOOST; - } else if (radio_variant == SX1272MB1DCS) { - return RF_PACONFIG_PASELECT_PABOOST; - } else { + } + else { return RF_PACONFIG_PASELECT_RFO; } } @@ -1395,11 +1395,6 @@ /** * Sets the transmit power for the module */ -#if defined ( TARGET_MOTE_L152RC ) -static const uint8_t pa_boost_table[20] = {0, 0, 0, 0, 0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15}; -static const uint8_t RFO_table[11] = {1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 9}; -#endif - void SX1272_LoRaRadio::set_rf_tx_power(int8_t power) { uint8_t pa_config = 0; @@ -1407,18 +1402,6 @@ pa_config = read_register(REG_PACONFIG); pa_dac = read_register(REG_PADAC); - -#if defined ( TARGET_MOTE_L152RC ) - if(power > 19) { - pa_config = (pa_config & RF_PACONFIG_PASELECT_MASK) | RF_PACONFIG_PASELECT_RFO; - pa_config = (pa_config & RFLR_PACONFIG_OUTPUTPOWER_MASK) | RFO_table[power - 20]; - } - else - { - pa_config = (pa_config & RF_PACONFIG_PASELECT_MASK) | RF_PACONFIG_PASELECT_PABOOST; - pa_config = (pa_config & RFLR_PACONFIG_OUTPUTPOWER_MASK) | pa_boost_table[power]; - } -#else pa_config = (pa_config & RF_PACONFIG_PASELECT_MASK) | get_pa_conf_reg(); if ((pa_config & RF_PACONFIG_PASELECT_PABOOST) @@ -1457,7 +1440,6 @@ pa_config = (pa_config & RFLR_PACONFIG_OUTPUTPOWER_MASK) | (uint8_t) ((uint16_t) (power + 1) & 0x0F); } -#endif write_to_register(REG_PACONFIG, pa_config); write_to_register(REG_PADAC, pa_dac); } @@ -1478,19 +1460,7 @@ */ void SX1272_LoRaRadio::set_sx1272_variant_type() { - if (_rf_ctrls.ant_switch != NC){ - _ant_switch.input(); - wait_ms(1); - if (_ant_switch == 1) { - radio_variant = SX1272MB1DCS; - } else { - radio_variant = SX1272MB2XAS; - } - _ant_switch.output(); - wait_ms(1); - } else { - radio_variant = MBED_CONF_SX1272_LORA_DRIVER_RADIO_VARIANT; - } + radio_variant = MBED_CONF_SX1272_LORA_DRIVER_RADIO_VARIANT; } /** @@ -1503,64 +1473,69 @@ // as some pins might be NC switch (mode) { case RFLR_OPMODE_TRANSMITTER: - if (_rf_ctrls.rf_switch_ctl1 != NC - && _rf_ctrls.rf_switch_ctl2 != NC) { - // module is in transmit mode and RF latch switches - // are connected. Check if power amplifier boost is - // setup or not + if (radio_variant == SX1272PABOOST) + { if ((read_register(REG_PACONFIG) & RF_PACONFIG_PASELECT_PABOOST) - == RF_PACONFIG_PASELECT_PABOOST) { - _rf_switch_ctl1 = 1; - _rf_switch_ctl2 = 0; - } else { - // power amplifier not selected - _rf_switch_ctl1 = 0; - _rf_switch_ctl2 = 1; + == RF_PACONFIG_PASELECT_PABOOST) + { + if (_rf_ctrls.rf_switch_ctl1 != NC) { + _rf_switch_ctl1 = 1; + } + if (_rf_ctrls.rf_switch_ctl2 != NC) { + _rf_switch_ctl2 = 0; + } } - } else if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) { - // module is in transmit mode and tx/rx submodule control - // pins are connected + else + { + if (_rf_ctrls.rf_switch_ctl1 != NC) { + _rf_switch_ctl1 = 0; + } + if (_rf_ctrls.rf_switch_ctl2 != NC) { + _rf_switch_ctl2 = 1; + } + } + } + if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) + { _txctl = 1; _rxctl = 0; - } else if (_rf_ctrls.ant_switch != NC){ + } + if (_rf_ctrls.ant_switch != NC) { _ant_switch = 1; - } else { - // None of the control pins are connected. } break; + case RFLR_OPMODE_RECEIVER: case RFLR_OPMODE_RECEIVER_SINGLE: case RFLR_OPMODE_CAD: - if (_rf_ctrls.rf_switch_ctl1 != NC - && _rf_ctrls.rf_switch_ctl2 != NC) { - // radio is in reception or CAD mode and RF latch switches - // are connected - _rf_switch_ctl1 = 1; - _rf_switch_ctl2 = 1; - } else if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) { + if (_rf_ctrls.rf_switch_ctl1 != NC) { + _rf_switch_ctl1 = 0; + } + if (_rf_ctrls.rf_switch_ctl2 != NC) { + _rf_switch_ctl2 = 0; + } + if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) { _txctl = 0; _rxctl = 1; - } else if (_rf_ctrls.ant_switch != NC) { + } + if (_rf_ctrls.ant_switch != NC) { _ant_switch = 0; - } else { - // None of the control pins are connected. } break; + default: - // Enforce default case when any connected control pin is kept low. - if (_rf_ctrls.rf_switch_ctl1 != NC - && _rf_ctrls.rf_switch_ctl2 != NC) { - // radio is in reception or CAD mode and RF latch switches - // are connected + if (_rf_ctrls.rf_switch_ctl1 != NC) { _rf_switch_ctl1 = 0; + } + if (_rf_ctrls.rf_switch_ctl2 != NC) { _rf_switch_ctl2 = 0; - } else if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) { + } + if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) { _txctl = 0; _rxctl = 0; - } else if (_rf_ctrls.ant_switch != NC) { + } + if (_rf_ctrls.ant_switch != NC) { _ant_switch = 0; - } else { - // None of the control pins are connected. } break; }
diff -r 6c5853c2fd72 -r f0616e516844 SX1272/SX1272_LoRaRadio.h --- a/SX1272/SX1272_LoRaRadio.h Thu Nov 12 22:09:59 2020 +0000 +++ b/SX1272/SX1272_LoRaRadio.h Thu May 20 21:24:36 2021 +0000 @@ -341,7 +341,7 @@ mbed::DigitalOut _rf_switch_ctl2; mbed::DigitalOut _txctl; mbed::DigitalOut _rxctl; - mbed::DigitalInOut _ant_switch; + mbed::DigitalOut _ant_switch; mbed::DigitalOut _pwr_amp_ctl; mbed::DigitalOut _tcxo;
diff -r 6c5853c2fd72 -r f0616e516844 SX1272/mbed_lib.json --- a/SX1272/mbed_lib.json Thu Nov 12 22:09:59 2020 +0000 +++ b/SX1272/mbed_lib.json Thu May 20 21:24:36 2021 +0000 @@ -11,7 +11,7 @@ }, "radio-variant": { "help": "Use to set the radio variant if the antenna switch input is not connected.", - "value": "SX1272UNDEFINED" + "value": "SX1272PABOOST" } } }