put send function into rfm02 class

master
ArcticSaturn 2014-11-13 20:31:04 +01:00
rodzic 2dbe034300
commit 21cbf91cbe
2 zmienionych plików z 46 dodań i 25 usunięć

Wyświetl plik

@ -112,3 +112,44 @@ uint8_t i=8;
}
}
void RFM02::sendMessage(uint8_t *txData, uint8_t size)
{
//digitalWrite(_pinChipSelect, LOW); // CS LOW
writeRegister(0xC0,0x39); // enable TX
//digitalWrite(_pinChipSelect, HIGH); // CS HIGH
//delay(1000);
RFM02_TX_DataByte_FSK(0xAA); // preamble
RFM02_TX_DataByte_FSK(0xAA); // preamble
RFM02_TX_DataByte_FSK(0xAA); // preamble
RFM02_TX_DataByte_FSK(0x2D); // sync word high
RFM02_TX_DataByte_FSK(0xD4); // sync word low
for(int myLoop=0;myLoop<MESSAGELENGTH;myLoop++)
{
RFM02_TX_DataByte_FSK(txData[myLoop]); // sync word lowtxData[myLoop] = myLoop;
}
/*
RFM02_TX_DataByte_FSK('H'); // data
RFM02_TX_DataByte_FSK('E'); // data
RFM02_TX_DataByte_FSK('L'); // data
RFM02_TX_DataByte_FSK('L'); // data
RFM02_TX_DataByte_FSK('O'); // data
RFM02_TX_DataByte_FSK(1); // data
RFM02_TX_DataByte_FSK(2); // data
RFM02_TX_DataByte_FSK(3); // data
RFM02_TX_DataByte_FSK(4); // data
RFM02_TX_DataByte_FSK(0xA5); // ende zeichen
*/
delay(1); // delay until carrier turn off
//digitalWrite(_pinChipSelect, LOW); // CS LOW
writeRegister(0xC0,0x01); // disable TX
//digitalWrite(_pinChipSelect, HIGH); // CS HIGH
}

30
rfm02.h
Wyświetl plik

@ -1,4 +1,7 @@
#ifndef MESSAGELENGTH
#define MESSAGELENGTH 10// expect 10 bytes to receive
#endif
#ifndef RFM02_h
#define RFM02_h
@ -15,38 +18,15 @@ class RFM02 {
public:
RFM02();
RFM02(uint8_t pinChipSelect, uint8_t pinFSK, uint8_t pinNIRQ);
//CC2500(uint8_t deviceAddress);
//CC2500(uint8_t deviceAddress, uint8_t channel);
void begin();
//void setDeviceAddress(uint8_t deviceAddress);
//void setChannel(uint8_t channel);
//uint8_t getChipVersion();
//uint8_t getStatusByte();
void sendMessage(uint8_t *txData, uint8_t size);
//private:
private:
void writeRegister(uint8_t HighByte, uint8_t LowByte);
void configureDeviceSettings();
void RFM02_TX_DataByte_FSK(uint8_t DataByte);
/*
uint8_t _channel;
uint8_t _deviceAddress;
uint8_t _gdo0;
void writeRegister(uint8_t addr, uint8_t data);
void writeRegisterBurst(uint8_t saddr, uint8_t *data, uint8_t size);
uint8_t readRegister(uint8_t addr);
void readRegisterBurst(uint8_t saddr, uint8_t *data, uint8_t size);
uint8_t readStatusRegister(uint8_t addr);
void sendTxBuffer(uint8_t *txBuffer, uint8_t size);
int8_t receiveRxBuffer(uint8_t *rxBuffer, uint8_t size);
void execStrobeCommand(uint8_t command);
void resetDevice();
*/
};
#endif