⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 halsrf04.h

📁 基于CC1100和ATMEGA128开发的无线机器人控制程序
💻 H
📖 第 1 页 / 共 2 页
字号:
    BYTE MDMCFG0;   // Modem configuration.
    BYTE CHANNR;    // Channel number.
    BYTE DEVIATN;   // Modem deviation setting (when FSK modulation is enabled).
    BYTE FREND1;    // Front end RX configuration.
    BYTE FREND0;    // Front end RX configuration.
    BYTE MCSM0;     // Main Radio Control State Machine configuration.
    BYTE FOCCFG;    // Frequency Offset Compensation Configuration.
    BYTE BSCFG;     // Bit synchronization Configuration.
    BYTE AGCCTRL2;  // AGC control.
    BYTE AGCCTRL1;  // AGC control.
    BYTE AGCCTRL0;  // AGC control.
    BYTE FSCAL3;    // Frequency synthesizer calibration.
    BYTE FSCAL2;    // Frequency synthesizer calibration.
    BYTE FSCAL1;    // Frequency synthesizer calibration.
    BYTE FSCAL0;    // Frequency synthesizer calibration.
    BYTE FSTEST;    // Frequency synthesizer calibration control
    BYTE TEST2;     // Various test settings.
    BYTE TEST1;     // Various test settings.
    BYTE TEST0;     // Various test settings.
    BYTE IOCFG2;    // GDO2 output pin configuration
    BYTE IOCFG0;    // GDO0 output pin configuration
    BYTE PKTCTRL1;  // Packet automation control.
    BYTE PKTCTRL0;  // Packet automation control.
    BYTE ADDR;      // Device address.
    BYTE PKTLEN;    // Packet length.
    
} RF_SETTINGS;

    





//-------------------------------------------------------------------------------------------------------




//-------------------------------------------------------------------------------------------------------
//  void RfWriteRfSettings(RF_SETTINGS *pRfSettings)
//
//  DESCRIPTION:
//      This function is used to configure the CC2500 based on a given rf setting
//
//  ARGUMENTS:
//      RF_SETTINGS *pRfSettings
//          Pointer to a struct containing rf register settings
//-------------------------------------------------------------------------------------------------------
void halRfWriteRfSettings(RF_SETTINGS *pRfSettings);




//-------------------------------------------------------------------------------------------------------
//  void halRfSendPacket(BYTE *txBuffer, UINT8 size)
//
//  DESCRIPTION:
//      This function can be used to transmit a packet with packet length up to 63 bytes.
//      To use this function, GD02 must be configured to be asserted when sync word is sent and 
//      de-asserted at the end of the packet => halSpiWriteReg(CCxxx0_IOCFG2, 0x06);
//      The function implements polling of GDO2. First it waits for GD02 to be set and then it waits
//      for it to be cleared.  
//      
//  ARGUMENTS:
//      BYTE *txBuffer
//          Pointer to a buffer containg the data that are going to be transmitted
//
//      UINT8 size
//          The size of the txBuffer
//-------------------------------------------------------------------------------------------------------

void halRfSendPacket(BYTE *txBuffer, UINT8 size);




//-------------------------------------------------------------------------------------------------------
//  BOOL halRfReceivePacket(BYTE *rxBuffer, UINT8 *length)
//
//  DESCRIPTION: 
//      This function can be used to receive a packet of variable packet length (first byte in the packet
//      must be the length byte). The packet length should not exceed the RX FIFO size.
//      To use this function, GD02 must be configured to be asserted when sync word is sent and 
//      de-asserted at the end of the packet => halSpiWriteReg(CCxxx0_IOCFG2, 0x06);
//      The function implements polling of GDO2. First it waits for GD02 to be set and then it waits
//      for it to be cleared.  
//  
//  ARGUMENTS:
//      BYTE *rxBuffer
//          Pointer to the buffer where the incoming data should be stored
//      UINT8 *length
//          Pointer to a variable containing the size of the buffer where the incoming data should be
//          stored. After this function returns, that variable holds the packet length.
//          
//  RETURN VALUE:
//      BOOL
//          TRUE:   CRC OK
//          FALSE:  CRC NOT OK
//-------------------------------------------------------------------------------------------------------
//BOOL halRfReceivePacket(BYTE *rxBuffer, UINT8 *length);

BOOL halRfReceivePacket(BYTE *rxBuffer, UINT8 length);



//-------------------------------------------------------------------------------------------------------
//  void halRfSendPacketSerial(BYTE *txBuffer, UINT8 size, UINT8 startOfPayload, BOOL crcEnable)
//
//  DESCRIPTION:
//      This function transmits a packet using synchronous serial mode. The radio must be configured to 
//      use GIO1 as the serial clock (IOCFG1 = 0x0B) and GDO0 as serial synchronous data output
//      (IOCFG0 = 0x0C).
//      The packet should have the following format:
//      
//      ----------------------------------------------------------------------------------
//      | preamble | sync3 | sync2 | sync1 | sync0 | length byte | payload | crc1 | crc0 |
//      ----------------------------------------------------------------------------------
//
//      The length byte and the crc is optional.
//      Be aware that modifications to this function might be necessary if it is ported to other
//      MCUs or if the data rate is increased, due to timing issues.
//      The function is only meant to give an indication on how to use the serial synchronous mode
//      of the CCxx00.    
//      
//  ARGUMENTS:
//      BYTE *txBuffer
//          Pointer to array containing the packet to be sent.
//          For example:
//          BYTE xdata txBuffer[] = {0x55,  0x55,   0x55,   0x55,  Preamble
//                                   SYNC3, SYNC2,  SYNC1,  SYNC0, Sync word (it is not necessary to
//                                                                 transmit 4 sync bytes but the culSyncSearch
//                                                                 function in the cul library must be  
//                                                                 modified if other sync lengths should be used. 
//                                   3,     'A',    'B',    'C',   length byte + payload (length byte is optional, 
//                                                                 depending on how the receiver is configured
//                                                                 (fixed or variable packet length)
//                                   CRC1, CRC0};                  CRC bytes (optional)
//                                                                 This is just 2 dummy bytes which will be 
//                                                                 replaced with 'real' crc bytes if crc calculation 
//                                                                 is enabled
//
//      UINT8 size
//          Size of the txBuffer
// 
//      UINT8 startOfPayload
//          Indicates where in the txBuffer the crc calculation should start (crc is calculated over the
//          optional length byte and the payload.
//
//      BOOL crcEnable
//          TRUE: Calculate CRC and replace CRC1 and CRC0 in txBuffer with 'real' crc bytes
//          FALSE: CRC is not calculated and TX mode is terminated after the payload has been sent  
//-------------------------------------------------------------------------------------------------------
void halRfSendPacketSerial(BYTE *txBuffer, UINT8 size, UINT8 startOfPayload, BOOL crcEnable);




//-------------------------------------------------------------------------------------------------------
//  BOOL halRfReceivePacketSerial
//  (BYTE *rxBuffer, UINT8 sync3, UINT8 sync2, UINT8 sync1, UINT8 sync0, UINT8 fixedLength, BOOL crcEnable)
//
//  DESCRIPTION:
//      This function receives a packet using synchronous serial mode. The radio must be configured to 
//      use GIO1 as the serial clock (IOCFG1 = 0x0B) and GDO0 as serial synchronous data output
//      (IOCFG0 = 0x0C).
//      The packets received by this function should have the following format:
//      
//      ----------------------------------------------------------------------------------
//      | preamble | sync3 | sync2 | sync1 | sync0 | length byte | payload | crc1 | crc0 |
//      ----------------------------------------------------------------------------------
//
//      The length byte and the crc is optional.
//      Be aware that modifications to this function might be necessary if it is ported to other
//      MCUs or if the data rate is increased, due to timing issues.
//      The function is only meant to give an indication on how to use the serial synchronous mode
//      of the CCxx00.    
//
//  ARGUMENTS:
//      BYTE *rxBuffer
//          Pointer to array where the received packet is being stored
//
//      UINT8 sync3, UINT8 sync2 UINT8 sync1, UINT8 sync0
//          Sync word to search for. If one wants to send a sync word of a different length it is 
//          necessary to modify the culSyncSearch function, found in the cul folder 
//          (cul = Chipcon Utility Library).
//
//      UINT8 fixedLength
//          Length of data to be received after sync word is found. If fixedLength = 0, this means that
//          the length byte is given as the first byte received after sync word is found.
//
//      BOOL crcEnable
//          If crcEnable is TRUE, two bytes are received after the payload. This is crc1 and crc0.
//          A crc check will be performed on the received data and compared to crc1 and crc0.
// 
//  RETURN VALUE:
//      BOOL
//          crcEnable == TRUE =>    TRUE:   CRC OK
//                                  FALSE:  CRC NOT OK
//          crcEnable == FALSE =>   Return TRUE when a packet is received            
//-------------------------------------------------------------------------------------------------------
BOOL halRfReceivePacketSerial
(BYTE *rxBuffer, UINT8 sync3, UINT8 sync2, UINT8 sync1, UINT8 sync0, UINT8 fixedLength, BOOL crcEnable);



/*******************************************************************************************************
 *******************************************************************************************************
 **************************              Utility functions          ************************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
//  DESCRIPTION:
//      Runs an idle loop for [timeout] microseconds.
//-------------------------------------------------------------------------------------------------------
void halWait(BYTE timeout);




#endif//HALSRF04_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -