void RADIOClass::SendData(byte *txBuffer,byte size) { WriteSingleReg(RADIO_TXFIFO,size); WriteBurstReg(RADIO_TXFIFO,txBuffer,size); //write data to send Strobe(RADIO_STX); //start send while (!digitalRead(GDO0)); // Wait for GDO0 to be set -> sync transmitted while (digitalRead(GDO0)); // Wait for GDO0 to be cleared -> end of packet Strobe(RADIO_SFTX); //flush TXfifo }
void Transmit(unsigned char *buffer, unsigned char length) { RF1AIES |= BIT9; RF1AIFG &= ~BIT9; // Clear pending interrupts RF1AIE |= BIT9; // Enable TX end-of-packet interrupt WriteBurstReg(RF_TXFIFOWR, buffer, length); Strobe( RF_STX ); // Strobe STX }
void it_tx_cmd(uint8_t prefix, uint8_t cmd) { uint8_t p = 0; uint8_t rprefix; uint8_t it_buff[INTERTECHNO_SEQ_SIZE]; int8_t i; rprefix = rotate_byte(prefix); // replace 1 with 0x8e and 0 with 0x88 for (i = 7; i >= 0; i--) { if (rprefix & (1 << i)) { it_buff[p] = 0x8e; } else { it_buff[p] = 0x88; } p++; } for (i = 3; i >= 0; i--) { if (cmd & (1 << i)) { it_buff[p] = 0x8e; } else { it_buff[p] = 0x88; } p++; } // sync sequence it_buff[p++] = 0x80; it_buff[p++] = 0; it_buff[p++] = 0; it_buff[p] = 0; // display RF symbol display_symbol(0, LCD_ICON_BEEPER1, SEG_ON); display_symbol(0, LCD_ICON_BEEPER2, SEG_ON); display_symbol(0, LCD_ICON_BEEPER3, SEG_ON); it_rf_init(); Strobe(RF_SCAL); // re-calibrate radio // set an interrupt to trigger when the packet is fully sent RF1AIES |= BIT9; RF1AIFG &= ~BIT9; // Clear pending interrupts RF1AIE |= BIT9; // Enable TX end-of-packet interrupt // factory remotes send the command sequence 4 times for (i = 0; i < 4; i++) { WriteBurstReg(RF_TXFIFOWR, it_buff, INTERTECHNO_SEQ_SIZE); } Strobe(RF_STX); // transmit }
void tx_data_isr() { //Calculate number of free bytes in TXFIFO uint8_t txBytes = 64 - ReadSingleReg(TXBYTES); #ifdef D7_PHY_USE_FEC if(fec) { uint8_t fecbuffer[4]; //If remaining bytes is equal or less than 255 - fifo size, set length to fixed if(remainingBytes < 192) set_length_infinite(false); while (txBytes >= 4) { //Get encoded data, stop when no more data available if(fec_encode(fecbuffer) == false) break; //Write data to tx fifo WriteBurstReg(TXFIFO, fecbuffer, 4); remainingBytes -= 4; txBytes -= 4; } } else { #endif //Limit number of bytes to remaining bytes if(txBytes > remainingBytes) txBytes = remainingBytes; //Write data to tx fifo WriteBurstReg(TXFIFO, bufferPosition, txBytes); remainingBytes -= txBytes; bufferPosition += txBytes; #ifdef D7_PHY_USE_FEC } #endif }
void Init_RF(void){ // Increase PMMCOREV level to 2 in order to avoid low voltage error // when the RF core is enabled SetVCore(2); ResetRadioCore(); WriteBurstReg(IOCFG2, (unsigned char*)RF1A_REGISTER_CONFIG, CONF_REG_SIZE); WritePATable(); InitButtonLed(); ReceiveOn(); //Wait for RX status to be reached while((Strobe(RF_SNOP) & 0x70) != 0x10); }
void RADIOClass::PATABLE(void) { WriteBurstReg(RADIO_PATABLE, PaTabel, 8); }