Esempio n. 1
0
 protected void decode(byte val) {
   extFilter = Arithmetic.getBit(val, 7);
   refDiv = (value & 0x78) >> 3;
   alarmDisable = Arithmetic.getBit(val, 2);
   alarmHigh = Arithmetic.getBit(val, 1);
   alarmLow = Arithmetic.getBit(val, 0);
 }
Esempio n. 2
0
 protected void decode(byte val) {
   mlimit = (val & 0xe0) >> 5;
   lockAvgN = Arithmetic.getBit(val, 4);
   lockAvgMode = Arithmetic.getBit(val, 3);
   settling = SETTLING[(val & 0x06) >> 1];
   modemResetN = Arithmetic.getBit(val, 0);
 }
Esempio n. 3
0
    protected void decode(byte val) {

      rxtx = Arithmetic.getBit(val, RXTX);
      fReg = Arithmetic.getBit(val, F_REG);
      rxPd = Arithmetic.getBit(val, RX_PD);
      txPd = Arithmetic.getBit(val, TX_PD);
      fsPd = Arithmetic.getBit(val, FS_PD);
      corePd = Arithmetic.getBit(val, CORE_PD);
      biasPd = Arithmetic.getBit(val, BIAS_PD);
      resetN = Arithmetic.getBit(val, RESET_N);

      if (rxPd) receiver.endReceive();
      else receiver.beginReceive(2.4);

      if (txPd) transmitter.endTransmit();
      else transmitter.beginTransmit(getPower(), getFrequency());

      if (!rxPd || !txPd) {
        ticker.activate();
      } else {
        ticker.deactivate();
      }

      boolean oldrxtx = Arithmetic.getBit(oldVal, RXTX);
      if (rxtx && !oldrxtx) {
        // switch from receive to transmit
        if (radioPrinter != null) {
          radioPrinter.println("CC1000: RX end receiving -> begin transmitting");
        }
      } else if (!rxtx && oldrxtx) {
        // switch from transmit to receive
        if (radioPrinter != null) {
          radioPrinter.println("CC1000: TX end transmitting -> begin receiving");
        }
      }

      currentFrequencyRegister = fReg ? FREQ_B_reg : FREQ_A_reg;

      if (resetN && !Arithmetic.getBit(oldVal, RESET_N)) {
        oldVal = val;
        // TODO: reset the radio.
        return;
      }

      if (val != oldVal) {
        // TODO: reduce this code to compute state more easily
        int state;
        if (corePd) state = 1; // power down state
        else state = 2; // core, e.g. crystal on state
        if (!corePd && !biasPd) state = 3; // crystal and bias on state
        if (!corePd && !biasPd && !fsPd) state = 4; // crystal, bias and synth. on
        if (!corePd && !biasPd && !fsPd && !rxtx && !rxPd) state = 5; // receive state
        if (!corePd && !biasPd && !fsPd && rxtx && !txPd) state = PA_POW_reg.getPower() + 6;
        stateMachine.transition(state);
      }

      oldVal = val;
    }
Esempio n. 4
0
    protected void decode(byte val) {
      lockSelect = (val & 0xf0) >> 4;
      int pllLockAccuracy = (val & 0x0c) >> 2;
      setsLockThreshold = SETS_LOCK_THRESHOLD[pllLockAccuracy];
      resetLockThreshold = RESET_LOCK_THRESHOLD[pllLockAccuracy];

      pllLockLength = Arithmetic.getBit(val, 2);
      lockInstant = Arithmetic.getBit(val, 1);
      lockContinuous = Arithmetic.getBit(val, 0);
    }
Esempio n. 5
0
 public void fire() {
   // TODO: multiple calls to decode()
   value = Arithmetic.setBit(value, CAL_START, false);
   decode(value);
   value = Arithmetic.setBit(value, CAL_COMPLETE, true);
   decode(value);
   LOCK_reg.write((byte) ((LOCK_reg.read() & 0x0f) | 0x50)); // LOCK = CAL_COMPLETE
   if (radioPrinter != null) {
     radioPrinter.println("CC1000: Calibration complete ");
   }
   calibrating = false;
 }
Esempio n. 6
0
    protected void decode(byte val) {
      bufCurrent = BUF_CURRENT[(val & 0x20) >> 5];
      lnaCurrent = LNA_CURRENT[(val & 0x18) >> 3];
      ifRSSI = (val & 0x06) >> 1;

      xoscBypassExternal = Arithmetic.getBit(val, 0);
    }
Esempio n. 7
0
 /**
  * The constructor for the <code> Transmission </code> class creates a new transmission with
  * several properties like start and end times, first and last bit to be transmitted and the
  * data itself.
  *
  * @param o Transmitter object
  * @param pow Power for the transmission
  * @param freq the frequency for the transmission
  */
 protected Transmission(Transmitter o, double pow, double freq) {
   origin = o;
   power = pow;
   Pt = pow;
   f = freq;
   start = o.clock.getCount();
   end = Long.MAX_VALUE;
   long l = start + o.leadCycles;
   firstBit = origin.getBitNum(l);
   lastBit = Long.MAX_VALUE;
   data = new byte[Arithmetic.roundup(o.medium.maxLength, BYTE_SIZE)];
 }
Esempio n. 8
0
    protected void decode(byte val) {
      boolean oldCalStart = calStart;
      calStart = Arithmetic.getBit(val, 7);
      calDual = Arithmetic.getBit(val, 6);
      calWait = Arithmetic.getBit(val, 5);
      calCurrent = Arithmetic.getBit(val, 4);
      calComplete = Arithmetic.getBit(val, 3);

      calIterate = (value & 0x7);

      if (!oldCalStart && calStart && !calibrating) {
        calibrating = true;
        // OL: calibration time depends on the reference frequency
        // worst case is 34ms
        // it is determined with: 34ms * 1MHz / (Fxosc / REFDIV)
        // with Fxosc is 14.7456 MHz for CC1000 on Mica2
        // and REFDIV is set in the PLL register
        // in the current TinyOS version (1.1.7) REFDIV seems to be 14
        // resulting in a delay of a little more than 32ms
        // Reference: CC1000 datasheet (rev 2.1) pages 20 and 22
        double calMs = (34.0 * 1000000.0 / FXOSC_FREQUENCY) * PLL_reg.refDiv;
        clock.insertEvent(calibrate, clock.millisToCycles(calMs));
      }
    }
Esempio n. 9
0
 /**
  * The <code>readBit()</code> method reads a single bit from the IO register.
  *
  * @param num the number of the bit to read
  * @return the value of the bit as a boolean
  */
 public boolean readBit(int num) {
   return Arithmetic.getBit(read(), num);
 }
Esempio n. 10
0
 protected void decode(byte val) {
   preSwing = PRE_SWING[(val & 0xc0) >> 6];
   preCurrent = PRE_CURRENT[(val & 0x30) >> 4];
   ifInput = Arithmetic.getBit(val, 3);
   ifFront = Arithmetic.getBit(val, 4);
 }
Esempio n. 11
0
 protected void decode(byte val) {
   fsResetN = Arithmetic.getBit(val, 0);
 }
Esempio n. 12
0
 protected void decode(byte val) {
   peakDetect = Arithmetic.getBit(val, 7);
   peakLevelOffset = val & 0x7f;
 }
Esempio n. 13
0
 private void outputReadBit() {
   PDATA_out.outputPin = Arithmetic.getBit(readData, 14 - bitsRead);
 }