#include "rfchannel.h"
/*
 * rfchannel.c
 *
 * Created: 25.3.2012 16:17:33
 *  Author: Kain
 */

uint8_t RF_txbuffer[3];

/* Sestavit paket a poslat ho */
void RF_sendData(uint8_t const address, const uint8_t data) {
	uint8_t crc7;
	RF_txbuffer[0] = address;
	RF_txbuffer[1] = data;
    crc7 = CRC7_get(&RF_txbuffer[0], 2);    // Spocitat CRC7 z adresy a dat (2B)
	RF_txbuffer[2] = crc7;

    // Odeslani celeho ramce
	for(uint8_t i = 0; i < RF_REPEAT_FRAME_NTIMES; i ++) {
		// Odeslani SYNC znacky
        for(uint8_t j = 0; j < RF_REPEAT_SYNC_NTIMES; j ++) {
    		USART_write(RF_SYNCMARK);
    	}
        USART_writeBytes(RF_txbuffer, 3);
	}
}