コード例 #1
0
ファイル: RF12WS.cpp プロジェクト: aj-gh/weatherstationFSK
/// @details
/// This call provides direct access to the RFM12B registers. If you're careful
/// to avoid configuring the wireless module in a way which stops the driver
/// from functioning, this can be used to adjust some settings.
/// See the RFM12B wireless module documentation.
/// One of two commands accessing SPI, so interrupts disabled in here
static uint16_t rf12_xfer (uint16_t cmd) {

	// disable interrupts
#ifdef EIMSK
    bitClear(EIMSK, INT0);
#else
    // ATtiny
    bitClear(GIMSK, INT0);
#endif

	uint16_t res = 0;
    // writing can take place at full speed, even 8 MHz works
    bitClear(SS_PORT, cs_pin);
    res  = rf12_byte(cmd >> 8) << 8;
    res |= rf12_byte(cmd);
    bitSet(SS_PORT, cs_pin);

	// enable interrupts
#ifdef EIMSK
    bitSet(EIMSK, INT0);
#else
    // ATtiny
    bitSet(GIMSK, INT0);
#endif

    return res;
}
コード例 #2
0
ファイル: RF12.cpp プロジェクト: kenpi2b/Desert-Home-Arduino
static void rf12_xfer (uint16_t cmd) {
    // writing can take place at full speed, even 8 MHz works
    bitClear(SS_PORT, cs_pin);
    rf12_byte(cmd >> 8) << 8;
    rf12_byte(cmd);
    bitSet(SS_PORT, cs_pin);
}
コード例 #3
0
ファイル: rf12.c プロジェクト: daspilker/wireless_s88
static uint16_t rf12_trans(uint16_t value) {
  uint16_t result;

  CHIP_SELECT_ON();
  result = rf12_byte(value >> 8) << 8;
  result |= rf12_byte(value);
  CHIP_SELECT_OFF();

  return result;
}
コード例 #4
0
ファイル: RF12mods.cpp プロジェクト: Bra1nK/RFM2Pi
/// @details
/// This call provides direct access to the RFM12B registers. If you're careful
/// to avoid configuring the wireless module in a way which stops the driver
/// from functioning, this can be used to adjust some settings.
/// See the RFM12B wireless module documentation. 
static uint16_t rf12_xfer (uint16_t cmd) {
    blockInterrupts();

    // writing can take place at full speed, even 8 MHz works
    bitClear(SS_PORT, cs_pin);
    uint16_t res  = rf12_byte(cmd >> 8) << 8;
    res |= rf12_byte(cmd);
    bitSet(SS_PORT, cs_pin);

    allowInterrupts();
    return res;
}
コード例 #5
0
ファイル: RF12WS.cpp プロジェクト: aj-gh/weatherstationFSK
/// @details
/// Requests RFM12 state from RF module and reads back a waiting data byte if there is
/// any.
/// One of two commands accessing SPI, so interrupts disabled in here
/// @param *data Pointer to  byte where to write the received data to (if any)
static uint16_t rf12_xferState (uint8_t *data) {

	// disable interrupts
#ifdef EIMSK
    bitClear(EIMSK, INT0);
#else
    // ATtiny
    bitClear(GIMSK, INT0);
#endif

    uint16_t res = 0;
    // writing can take place at full speed, even 8 MHz works
    bitClear(SS_PORT, cs_pin);
    res = rf12_byte(0x00) << 8;
    res|= rf12_byte(0x00);

    if (res & RF_FIFO_BIT && rxstate == TXRECV) {
        // slow down to under 2.5 MHz
#if F_CPU > 10000000
        bitSet(SPCR, SPR0);
#endif
        *data = rf12_byte(0x00);
#if F_CPU > 10000000
        bitClear(SPCR, SPR0);
#endif
    }

    bitSet(SS_PORT, cs_pin);

	// enable interrupts
#ifdef EIMSK
    bitSet(EIMSK, INT0);
#else
    // ATtiny
    bitSet(GIMSK, INT0);
#endif

    return res;
}
コード例 #6
0
ファイル: RF12.cpp プロジェクト: kenpi2b/Desert-Home-Arduino
static uint16_t rf12_xferSlow (uint16_t cmd) {
    // slow down to under 2.5 MHz
#if F_CPU > 10000000
    bitSet(SPCR, SPR0);
#endif
    bitClear(SS_PORT, cs_pin);
    uint16_t reply = rf12_byte(cmd >> 8) << 8;
    reply |= rf12_byte(cmd);
    bitSet(SS_PORT, cs_pin);
#if F_CPU > 10000000
    bitClear(SPCR, SPR0);
#endif
    return reply;
}
コード例 #7
0
ファイル: RF12mods.cpp プロジェクト: Bra1nK/RFM2Pi
/// @details
/// Requests RFM12 state from RF module and reads back a waiting data byte if there is
/// any.
/// One of two commands accessing SPI, so interrupts disabled in here
/// @param *data Pointer to  byte where to write the received data to (if any)
static uint16_t rf12_xferState (uint8_t *data) {
    blockInterrupts();

    // writing can take place at full speed, even 8 MHz works
    bitClear(SS_PORT, cs_pin);
    uint16_t res = rf12_byte(0x00) << 8;
    res |= rf12_byte(0x00);
    
    if (res & RF_FIFO_BIT && rxstate == TXRECV) {
        // slow down to under 2.5 MHz
#if F_CPU > 10000000
        bitSet(SPCR, SPR0);
#endif
        *data = rf12_byte(0x00);
#if F_CPU > 10000000
        bitClear(SPCR, SPR0);
#endif
    }
    
    bitSet(SS_PORT, cs_pin);

    allowInterrupts();
    return res;
}
コード例 #8
0
ファイル: RF12.cpp プロジェクト: cniweb/avr-netino
static void rf12_xfer (uint16_t cmd) {
    // writing can take place at full speed, even 8 MHz works
#ifdef SS_BMSK
    SS_PORT &= ~SS_BMSK;
#else
    bitClear(SS_PORT, cs_pin);
#endif	// SS_BMSK
    rf12_byte(cmd >> 8) << 8;
    rf12_byte(cmd);
#ifdef SS_BMSK
    SS_PORT |= SS_BMSK;
#else
    bitSet(SS_PORT, cs_pin);
#endif	// SS_BMSK
}
コード例 #9
0
ファイル: RF12.cpp プロジェクト: cniweb/avr-netino
static uint16_t rf12_xferSlow (uint16_t cmd) {
    // slow down to under 2.5 MHz
#if F_CPU > 10000000
    bitSet(SPCR, SPR0);
#endif
#ifdef SS_BMSK
    SS_PORT &= ~SS_BMSK;
#else
    bitClear(SS_PORT, cs_pin);
#endif	// BMSK
    uint16_t reply = rf12_byte(cmd >> 8) << 8;
    reply |= rf12_byte(cmd);
#ifdef SS_BMSK
    SS_PORT |= SS_BMSK;
#else
    bitSet(SS_PORT, cs_pin);
#endif	// BMSK
#if F_CPU > 10000000
    bitClear(SPCR, SPR0);
#endif
    return reply;
}