acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

SX1276.cpp (1882B)

      1 #include "SX1276.h"
      2 #if !defined(RADIOLIB_EXCLUDE_SX127X)
      3 
      4 SX1276::SX1276(Module* mod) : SX1278(mod) {
      5 
      6 }
      7 
      8 int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) {
      9   // execute common part
     10   int16_t state = SX127x::begin(RADIOLIB_SX1278_CHIP_VERSION, syncWord, preambleLength);
     11   RADIOLIB_ASSERT(state);
     12 
     13   // configure publicly accessible settings
     14   state = setBandwidth(bw);
     15   RADIOLIB_ASSERT(state);
     16 
     17   state = setFrequency(freq);
     18   RADIOLIB_ASSERT(state);
     19 
     20   state = setSpreadingFactor(sf);
     21   RADIOLIB_ASSERT(state);
     22 
     23   state = setCodingRate(cr);
     24   RADIOLIB_ASSERT(state);
     25 
     26   state = setOutputPower(power);
     27   RADIOLIB_ASSERT(state);
     28 
     29   state = setGain(gain);
     30   RADIOLIB_ASSERT(state);
     31 
     32   return(state);
     33 }
     34 
     35 int16_t SX1276::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) {
     36   // execute common part
     37   int16_t state = SX127x::beginFSK(RADIOLIB_SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK);
     38   RADIOLIB_ASSERT(state);
     39 
     40   // configure settings not accessible by API
     41   state = configFSK();
     42   RADIOLIB_ASSERT(state);
     43 
     44   // configure publicly accessible settings
     45   state = setFrequency(freq);
     46   RADIOLIB_ASSERT(state);
     47 
     48   state = setOutputPower(power);
     49   RADIOLIB_ASSERT(state);
     50 
     51   if(enableOOK) {
     52     state = setDataShapingOOK(RADIOLIB_SHAPING_NONE);
     53     RADIOLIB_ASSERT(state);
     54   } else {
     55     state = setDataShaping(RADIOLIB_SHAPING_NONE);
     56     RADIOLIB_ASSERT(state);
     57   }
     58 
     59   return(state);
     60 }
     61 
     62 int16_t SX1276::setFrequency(float freq) {
     63   RADIOLIB_CHECK_RANGE(freq, 137.0, 1020.0, RADIOLIB_ERR_INVALID_FREQUENCY);
     64 
     65   // set frequency and if successful, save the new setting
     66   int16_t state = SX127x::setFrequencyRaw(freq);
     67   if(state == RADIOLIB_ERR_NONE) {
     68     SX127x::_freq = freq;
     69   }
     70   return(state);
     71 }
     72 
     73 #endif