CC1101.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef RF_TASK_H
  2. #define RF_TASK_H
  3. //------------------------------------------------------------------------------------------------------
  4. // CCxxx0 STROBE, CONTROL AND STATUS REGSITER
  5. #define CCxx0x_IOCFG2 0x00 // GDO2 output pin configuration
  6. #define CCxx0x_IOCFG1 0x01 // GDO1 output pin configuration
  7. #define CCxx0x_IOCFG0 0x02 // GDO0 output pin configuration
  8. #define CCxx0x_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds
  9. #define CCxx0x_SYNC1 0x04 // Sync word, high byte
  10. #define CCxx0x_SYNC0 0x05 // Sync word, low byte
  11. #define CCxx0x_PKTLEN 0x06 // Packet length
  12. #define CCxx0x_PKTCTRL1 0x07 // Packet automation control
  13. #define CCxx0x_PKTCTRL0 0x08 // Packet automation control
  14. #define CCxx0x_ADDR 0x09 // Device address
  15. #define CCxx0x_CHANNR 0x0A // Channel number
  16. #define CCxx0x_FSCTRL1 0x0B // Frequency synthesizer control
  17. #define CCxx0x_FSCTRL0 0x0C // Frequency synthesizer control
  18. #define CCxx0x_FREQ2 0x0D // Frequency control word, high byte
  19. #define CCxx0x_FREQ1 0x0E // Frequency control word, middle byte
  20. #define CCxx0x_FREQ0 0x0F // Frequency control word, low byte
  21. #define CCxx0x_MDMCFG4 0x10 // Modem configuration
  22. #define CCxx0x_MDMCFG3 0x11 // Modem configuration
  23. #define CCxx0x_MDMCFG2 0x12 // Modem configuration
  24. #define CCxx0x_MDMCFG1 0x13 // Modem configuration
  25. #define CCxx0x_MDMCFG0 0x14 // Modem configuration
  26. #define CCxx0x_DEVIATN 0x15 // Modem deviation setting
  27. #define CCxx0x_MCSM2 0x16 // Main Radio Control State Machine configuration
  28. #define CCxx0x_MCSM1 0x17 // Main Radio Control State Machine configuration
  29. #define CCxx0x_MCSM0 0x18 // Main Radio Control State Machine configuration
  30. #define CCxx0x_FOCCFG 0x19 // Frequency Offset Compensation configuration
  31. #define CCxx0x_BSCFG 0x1A // Bit Synchronization configuration
  32. #define CCxx0x_AGCCTRL2 0x1B // AGC control
  33. #define CCxx0x_AGCCTRL1 0x1C // AGC control
  34. #define CCxx0x_AGCCTRL0 0x1D // AGC control
  35. #define CCxx0x_WOREVT1 0x1E // High byte Event 0 timeout
  36. #define CCxx0x_WOREVT0 0x1F // Low byte Event 0 timeout
  37. #define CCxx0x_WORCTRL 0x20 // Wake On Radio control
  38. #define CCxx0x_FREND1 0x21 // Front end RX configuration
  39. #define CCxx0x_FREND0 0x22 // Front end TX configuration
  40. #define CCxx0x_FSCAL3 0x23 // Frequency synthesizer calibration
  41. #define CCxx0x_FSCAL2 0x24 // Frequency synthesizer calibration
  42. #define CCxx0x_FSCAL1 0x25 // Frequency synthesizer calibration
  43. #define CCxx0x_FSCAL0 0x26 // Frequency synthesizer calibration
  44. #define CCxx0x_RCCTRL1 0x27 // RC oscillator configuration
  45. #define CCxx0x_RCCTRL0 0x28 // RC oscillator configuration
  46. #define CCxx0x_FSTEST 0x29 // Frequency synthesizer calibration control
  47. #define CCxx0x_PTEST 0x2A // Production test
  48. #define CCxx0x_AGCTEST 0x2B // AGC test
  49. #define CCxx0x_TEST2 0x2C // Various test settings
  50. #define CCxx0x_TEST1 0x2D // Various test settings
  51. #define CCxx0x_TEST0 0x2E // Various test settings
  52. // Strobe commands
  53. #define CCxx0x_SRES 0x30 // Reset chip.
  54. #define CCxx0x_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
  55. // If in RX/TX: Go to a wait state where only the synthesizer is
  56. // running (for quick RX / TX turnaround).
  57. #define CCxx0x_SXOFF 0x32 // Turn off crystal oscillator.
  58. #define CCxx0x_SCAL 0x33 // Calibrate frequency synthesizer and turn it off
  59. // (enables quick start).
  60. #define CCxx0x_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and
  61. // MCSM0.FS_AUTOCAL=1.
  62. #define CCxx0x_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if
  63. // MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
  64. // Only go to TX if channel is clear.
  65. #define CCxx0x_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit
  66. // Wake-On-Radio mode if applicable.
  67. #define CCxx0x_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
  68. #define CCxx0x_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
  69. #define CCxx0x_SPWD 0x39 // Enter power down mode when CSn goes high.
  70. #define CCxx0x_SFRX 0x3A // Flush the RX FIFO buffer.
  71. #define CCxx0x_SFTX 0x3B // Flush the TX FIFO buffer.
  72. #define CCxx0x_SWORRST 0x3C // Reset real time clock.
  73. #define CCxx0x_SNOP 0x3D // No operation. May be used to pad strobe commands to two
  74. // bytes for simpler software.
  75. #define CCxx0x_PARTNUM 0x30
  76. #define CCxx0x_VERSION 0x31
  77. #define CCxx0x_FREQEST 0x32
  78. #define CCxx0x_LQI 0x33
  79. #define CCxx0x_RSSI 0x34
  80. #define CCxx0x_MARCSTATE 0x35
  81. #define CCxx0x_WORTIME1 0x36
  82. #define CCxx0x_WORTIME0 0x37
  83. #define CCxx0x_PKTSTATUS 0x38
  84. #define CCxx0x_VCO_VC_DAC 0x39
  85. #define CCxx0x_TXBYTES 0x3A
  86. #define CCxx0x_RXBYTES 0x3B
  87. #define CCxx0x_PATABLE 0x3E
  88. #define CCxx0x_TXFIFO 0x3F
  89. #define CCxx0x_RXFIFO 0x3F
  90. #define CRC_OK 0x80
  91. #define RSSI 0
  92. #define LQI 1
  93. #define BYTES_IN_RXFIFO 0x7F
  94. #define KEY_LIGHT 1
  95. #define RF_RX 0
  96. #define RF_TX 1
  97. extern void WriteBurstReg(unsigned char addr, unsigned char *buffer, unsigned char count);
  98. extern void ReadBurstReg(unsigned char addr, unsigned char *buffer, unsigned char count);
  99. extern void WriteReg(unsigned char addr, unsigned char value);
  100. extern void Strobe(unsigned char strobe);
  101. extern unsigned char ReadReg(unsigned char addr);
  102. extern unsigned char ReadStatus(unsigned char addr);
  103. extern void halRfWriteRfSettings(void);
  104. extern void RfInit(void);
  105. extern void RfSetup(void);
  106. extern unsigned char SendPacket(unsigned char *txBuffer, unsigned char length);
  107. extern unsigned char ReceivePacket(unsigned char *rxBuffer, unsigned char max_length);
  108. #endif