示例#1
0
void rf12_rxdata(uint8_t *data, uint8_t number) {
  rf12_trans(0x82D9);			// RX on
  for (uint8_t i = 0; i < number; i++) {
    rf12_ready();
    *data++ = rf12_trans(0xB000);
  }
  rf12_trans(0x8201);			// RX off
}
示例#2
0
文件: rf12.c 项目: abicash/floodping
void rf12_rxdata(unsigned char *data, unsigned char number)
{
        unsigned char i;
        rf12_trans(0x82C8); // RX on
        rf12_trans(0xCA81); // set FIFO mode
        rf12_trans(0xCA83); // enable FIFO
        for (i = 0; i < number; i++)
        {
                *data++ = rf12_readytrans(0xB000);
        }
        rf12_trans(0x8208); // RX off
}
示例#3
0
文件: rf12.c 项目: abicash/floodping
void rf12_setfreq(unsigned short freq)
{
        if (freq < 96) // 430,2400MHz
                freq = 96;
        else if (freq > 3903) // 439,7575MHz
                freq = 3903;
        rf12_trans(0xA000 | freq);
}
示例#4
0
文件: rf12.c 项目: abicash/floodping
void rf12_setbaud(unsigned short baud)
{
//      if (baud < 663)
//              return;
//      if (baud < 5400) // Baudrate= 344827,58621/(R+1)/(1+CS*7)
                rf12_trans(0xC680 | ((43104 / baud) - 1));
//      else
//              rf12_trans(0xC600 | ((344828UL / baud) - 1));
}
示例#5
0
void send() {
    char buf[16];// = "g123456789012345678901234567890\0\0\0";
    buf[0] = 'g';
    memcpy(buf + 1, &x, 2);
    memcpy(buf + 3, &y, 2);
    memcpy(buf + 5, &z, 2);
    buf[7] = 0;
    memcpy(buf + 8, &x, 2);
    memcpy(buf + 10, &y, 2);
    memcpy(buf + 12, &z, 2);
    buf[14] = 0;

    rf12_init();
    rf12_setall(RF12FREQ868(868.3), 4, 1, 4, 666, 0, 6);

    rf12_txdata(buf, 15);

    rf12_trans(0x8201);
    rf12_trans(0x0);
}
示例#6
0
文件: rf12.c 项目: abicash/floodping
void rf12_setall(unsigned short freq, unsigned char bandwidth, unsigned char gain, unsigned char drssi, unsigned short baud, unsigned char power, unsigned char mod)
{
        if (freq < 96) // 430,2400MHz
                freq = 96;
        else if (freq > 3903) // 439,7575MHz
                freq = 3903;
        rf12_trans(0xA000 | freq);


        rf12_trans(0x9400 | ((bandwidth & 7) << 5) | ((gain & 3) << 3)
                        | (drssi & 7));

        //      if (baud < 663)
//              return;
//      if (baud < 5400) // Baudrate= 344827,58621/(R+1)/(1+CS*7)
                rf12_trans(0xC680 | ((43104 / baud) - 1));
//      else
//              rf12_trans(0xC600 | ((344828UL / baud) - 1));

                rf12_trans(0x9800 | (power & 7) | ((mod & 15) << 4));
}
示例#7
0
文件: rf12.c 项目: abicash/floodping
void rf12_init(void)
{
        rf12_trans(0xC0E0); // AVR CLK: 10MHz
        rf12_trans(0x80E7); // Enable FIFO
        rf12_trans(0xC2AB); // Data Filter: internal
        rf12_trans(0xCA81); // Set FIFO mode
        rf12_trans(0xE000); // disable wakeuptimer
        rf12_trans(0xC800); // disable low duty cycle
        rf12_trans(0xC4F7); // AFC settings: autotuning: -10kHz...+7,5kHz
}
示例#8
0
void rf12_txdata(uint8_t node_id, uint8_t *data, uint8_t number) {
  rf12_trans(0x8239);			// TX on
  rf12_ready();
  rf12_trans(0xB8AA);
  rf12_ready();
  rf12_trans(0xB8AA);
  rf12_ready();
  rf12_trans(0xB8AA);
  rf12_ready();
  rf12_trans(0xB82D);
  rf12_ready();
  rf12_trans(0xB800 | node_id);
  for (uint8_t i = 0; i < number; i++) {
    rf12_ready();
    rf12_trans(0xB800 | (*data++));
  }
  rf12_ready();
  rf12_trans(0xB8AA);
  rf12_ready();
  rf12_trans(0x8201);			// TX off
  rf12_ready();
  rf12_trans(0xB8AA);
}
示例#9
0
文件: rf12.c 项目: abicash/floodping
void rf12_txdata_start()
{
        rf12_trans(0x0000);
        rf12_readytrans(0x8238); // TX on
        rf12_readytrans(0x0000);

        for(int xc = 0;xc<5;xc++)
        {
                rf12_readytrans(0xB8AA);
        }
        rf12_readytrans(0xB82D);
        rf12_readytrans(0xB8D4);
        rf12_readytrans(0x0000);
}
示例#10
0
void rf12_init(uint8_t node_id) {
  DDRB  |= _BV(PIN_SDO) | _BV(PIN_SCK) | _BV(PIN_SEL);
  PORTB |= _BV(PIN_SEL);
  PORTD |= _BV(PIN_IRQ);

  rf12_trans(0x0000);
  rf12_trans(0x8201);
  rf12_trans(0xB800);
  while (bit_is_clear(PIND, PIN_IRQ)) {
    rf12_trans(0x0000);
  }

  rf12_trans(0x80E7);            // enable TX register, enable RX FIFO buffer, 868MHz, 12.0pF
  rf12_trans(0xA460);            // 868.000MHz
  rf12_trans(0xC606);            // 49.26kbps
  rf12_trans(0x94A2);            // VDI,FAST,134kHz,0dBm,-91dBm
  rf12_trans(0xC2AC);            // AL,!ml,DIG,DQD4
  rf12_trans(0xCA83);            // FIFO8,SYNC,!ff,DR
  rf12_trans(0xCE00 | node_id);  // SYNC=2DD4
  rf12_trans(0xC483);            // @PWR,NO RSTRIC,!st,!fi,OE,EN
  rf12_trans(0x9850);            // !mp,90kHz,MAX OUT
  rf12_trans(0xCC77);            // OB1,OB0, LPX,!ddy,DDIT,BW0
  rf12_trans(0xE000);            // NOT USE
  rf12_trans(0xC800);            // NOT USE
  rf12_trans(0xC049);            // 1.66MHz,3.1V
}
示例#11
0
static void rf12_ready(void) {
  loop_until_bit_is_clear(PIND, PIN_IRQ);
  rf12_trans(0x0000);
}
示例#12
0
文件: rf12.c 项目: abicash/floodping
unsigned short noinline rf12_readytrans(unsigned short wert)
{
        rf12_ready();
        return rf12_trans(wert);
}
示例#13
0
文件: rf12.c 项目: abicash/floodping
void rf12_setpower(unsigned char power, unsigned char mod)
{
        rf12_trans(0x9800 | (power & 7) | ((mod & 15) << 4));
}
示例#14
0
文件: rf12.c 项目: abicash/floodping
void rf12_setbandwidth(unsigned char bandwidth, unsigned char gain, unsigned char drssi)
{
        rf12_trans(0x9400 | ((bandwidth & 7) << 5) | ((gain & 3) << 3)
                        | (drssi & 7));
}