#ifndef RF_PROTOCOL_H #define RF_PROTOCOL_H /*================================================================================================ rfProtocol.h SiWiCom copyright 2006 v1.0 (2006-06-16) Name: Christoffer Martinsson E-mail: cm@cmtec.se Name: Joakim Nilsson E-mail: mail@jopin.se Description: Routines for rfProtocol. Uses cc1100.h as tranceiver. Overhead and CRC is added in cc1100 hardware. BytePos: 0 1 2 3 5 ------------ ------------ --------- ------ ------ Outgoing packet: | targetAddr | deviceAddr | command | data | ... | data | ------------ ------------ --------- ------ ------ BytePos: 0 1 2 3 5 6 7 ------------ ------------ --------- ------ ------ ------ --------- Incoming packet: | targetAddr | deviceAddr | command | data | ... | data | RSSI | LQI/CRC | ------------ ------------ --------- ------ ------ ------ --------- -------------------------------------------------------------------------------------------- Name: nrOfBytes: Value: Master: Slave: -------------------------------------------------------------------------------------------- targetAddr 1 Target address R/W R/W deviceAddr 1 Device address R/W R/W Command 1 0x11 – DATA R W 0xFA – ACK + UPDATE W R 0xFE – ACK R/W R/W Data 3 Value for the specified command above. R/W R/W DATA: Byte0 – data[0] Byte1 – data[1] Byte2 – data[2] ACK + UPDATE: Byte0 – New master address (0x00 = no change) Byte1 – New device address (0x00 = no change) Byte2 – New wakeup time (0x00 = no change) ACK: Byte0 – 0x55 Byte1 – 0x55 Byte2 – 0x55 ================================================================================================*/ #define RF_COMMAND_DATA 0x11 #define RF_COMMAND_ACK_AND_UPDATE 0xFA #define RF_COMMAND_ACK 0xFE #define RF_PADDING 0x55 /*================================================================================================ Functions ================================================================================================*/ /*================================================================================================ rfProtocolSendData Description: Write a data packet to the cc1100 (command = DATA). Input: *data (3byte data array) Return: - ------------------------------------------------------------------------------------------------*/ void rfProtocolSendData(uint8_t *data); /*================================================================================================ rfProtocolSendACK Description: Write a data packet to the cc1100 (command = ACK). Input: targetAddr (specific address for the slave device) Return: - ------------------------------------------------------------------------------------------------*/ void rfProtocolSendACK(uint8_t targetAddr); /*================================================================================================ rfProtocolSendACKAndUpdate Description: Write a data packet to the cc1100 (command = ACK_AND_UPDATE). Input: targetAddr (specific address for the slave device) *data (3byte data array) Return: - ------------------------------------------------------------------------------------------------*/ void rfProtocolSendACKAndUpdate(uint8_t targetAddr, uint8_t *data); /*================================================================================================ rfProtocolReadPacket Description: Add one byte to the input buffer and validate packet when buffer is full. Input: *dataBuffer (Pointer to array[5] for storing data) Return: type of packet. 0 = Packer ERROR ------------------------------------------------------------------------------------------------*/ uint8_t rfProtocolReadPacket(uint8_t *dataBuffer); /*================================================================================================ rfProtocolSetDeviceAddr Description: Set new device address. Input: newDeviceAddr (New device address) Return: - ------------------------------------------------------------------------------------------------*/ void rfProtocolSetDeviceAddr(uint8_t newDeviceAddr); /*================================================================================================ rfProtocolGetDeviceAddr Description: Get current device address Input: - Return: deviceAddr ------------------------------------------------------------------------------------------------*/ uint8_t rfProtocolGetDeviceAddr(void); /*================================================================================================ rfProtocolSetMasterAddr Description: Set new master device address. Input: newMasterAddr (New device address) Return: - ------------------------------------------------------------------------------------------------*/ void rfProtocolSetMasterAddr(uint8_t newMasterAddr); /*================================================================================================ rfProtocolGetMasterAddr Description: Get current master device address Input: - Return: masterAddr ------------------------------------------------------------------------------------------------*/ uint8_t rfProtocolGetMasterAddr(void); /*================================================================================================ End ================================================================================================*/ #endif // RF_PROTOCOL_H