Ejemplo n.º 1
0
  public CC1000Radio(Microcontroller mcu, long xfreq) {
    xoscFrequency = xfreq;

    this.mcu = mcu;
    this.sim = mcu.getSimulator();
    this.clock = sim.getClock();

    radioPrinter = sim.getPrinter("radio.cc1000");

    for (int i = 0x14; i < registers.length; i++) {
      registers[i] = new DummyRegister(i);
    }

    registers[MAIN] = MAIN_reg = new MainRegister();

    FREQ_A_reg = new FrequencyRegister("A");
    registers[FREQ_2A] = FREQ_A_reg.reg2;
    registers[FREQ_1A] = FREQ_A_reg.reg1;
    registers[FREQ_0A] = FREQ_A_reg.reg0;

    FREQ_B_reg = new FrequencyRegister("B");
    registers[FREQ_2B] = FREQ_B_reg.reg2;
    registers[FREQ_1B] = FREQ_B_reg.reg1;
    registers[FREQ_0B] = FREQ_B_reg.reg0;

    FSEP_reg = new FrequencySeparationRegister();
    registers[FSEP1] = FSEP_reg.reg1;
    registers[FSEP0] = FSEP_reg.reg0;

    registers[CURRENT] = CURRENT_reg = new CurrentRegister();
    registers[FRONT_END] = FRONT_END_reg = new FrontEndRegister();
    registers[PA_POW] = PA_POW_reg = new PA_POWRegister();
    registers[PLL] = PLL_reg = new PLLRegister();
    registers[LOCK] = LOCK_reg = new LockRegister();
    registers[CAL] = CAL_reg = new CALRegister();
    registers[MODEM2] = MODEM_2_reg = new Modem2Register();
    registers[MODEM1] = MODEM_1_reg = new Modem1Register();
    registers[MODEM0] = MODEM_0_reg = new Modem0Register();
    registers[MATCH] = MATCH_reg = new MatchRegister();
    registers[FSCTRL] = FSCTRL_reg = new FSCTRLRegister();
    registers[PRESCALER] = PRESCALER_reg = new PrescalerRegister();

    // setup energy recording
    Simulator simulator = mcu.getSimulator();

    stateMachine =
        new FiniteStateMachine(simulator.getClock(), RadioEnergy.startMode, allModeNames, ttm);

    new Energy(
        "Radio", RadioEnergy.modeAmpere, stateMachine, sim.getSimulation().getEnergyControl());

    ATMegaFamily amcu = (ATMegaFamily) mcu;
    ticker = new SPITicker();
    ticker.spiDevice = (SPIDevice) amcu.getDevice("spi");
    setMedium(createMedium(null, null));
    rssiOutput = new RSSIOutput();
    ADC adc = ((ADC) amcu.getDevice("adc"));
    adc.connectADCInput(rssiOutput, 0);
    config = new SerialConfigurationInterface();
  }
Ejemplo n.º 2
0
 public LightSensor(AtmelMicrocontroller m, int adcChannel, String onPin) {
   mcu = m;
   channel = adcChannel;
   mcu.getPin(onPin).connectOutput(new OnPin());
   fsm = new FiniteStateMachine(mcu.getClockDomain().getMainClock(), 0, names, 0);
   adcDevice = (ADC) mcu.getDevice("adc");
   adcDevice.connectADCInput(new ADCInput(), channel);
 }