David Rimer / RadioHead-148
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RH_RF24.h Source File

RH_RF24.h

00001 // RH_RF24.h
00002 // Author: Mike McCauley (mikem@airspayce.com)
00003 // Copyright (C) 2014 Mike McCauley
00004 // $Id: RH_RF24.h,v 1.13 2015/08/13 02:45:47 mikem Exp $
00005 //
00006 // Supports RF24/RF26 and RFM24/RFM26 modules in FIFO mode
00007 // also Si4464/63/62/61/60-A1
00008 // Si4063 is the same but Tx only
00009 //
00010 // Per http://www.hoperf.cn/upload/rf/RFM24.pdf
00011 // and http://www.hoperf.cn/upload/rf/RFM26.pdf
00012 // Sigh: the HopeRF documentation is utter rubbish: full of errors and incomplete. The Si446x docs are better:
00013 // http://www.silabs.com/Support%20Documents/TechnicalDocs/Si4464-63-61-60.pdf
00014 // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN626.pdf
00015 // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN627.pdf
00016 // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN647.pdf
00017 // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN633.pdf
00018 // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN736.pdf
00019 // http://nicerf.com/manage/upfile/indexbanner/635231050196868750.pdf    (API description)
00020 // http://www.silabs.com/Support%20Documents/Software/Si446x%20RX_HOP%20PLL%20Calculator.xlsx
00021 #ifndef RH_RF24_h
00022 #define RH_RF24_h
00023 
00024 #include <RHGenericSPI.h>
00025 #include <RHSPIDriver.h>
00026 
00027 // This is the maximum number of interrupts the driver can support
00028 // Most Arduinos can handle 2, Megas can handle more
00029 #define RH_RF24_NUM_INTERRUPTS 3
00030 
00031 // Maximum payload length the RF24 can support, limited by our 1 octet message length
00032 #define RH_RF24_MAX_PAYLOAD_LEN 255
00033 
00034 // The length of the headers we add.
00035 // The headers are inside the RF24's payload
00036 #define RH_RF24_HEADER_LEN 4
00037 
00038 // This is the maximum message length that can be supported by this driver. 
00039 // Can be pre-defined to a smaller size (to save SRAM) prior to including this header
00040 // Here we allow for message length 4 bytes of address and header and payload to be included in payload size limit.
00041 #ifndef RH_RF24_MAX_MESSAGE_LEN
00042 #define RH_RF24_MAX_MESSAGE_LEN (RH_RF24_MAX_PAYLOAD_LEN - RH_RF24_HEADER_LEN - 1)
00043 #endif
00044 
00045 // Max number of times we will try to read CTS from the radio
00046 #define RH_RF24_CTS_RETRIES 2500
00047 
00048 // RF24/RF26 API commands from table 10
00049 // also Si446X API DESCRIPTIONS table 1
00050 #define RH_RF24_CMD_NOP                        0x00
00051 #define RH_RF24_CMD_PART_INFO                  0x01
00052 #define RH_RF24_CMD_POWER_UP                   0x02
00053 #define RH_RF24_CMD_PATCH_IMAGE                0x04
00054 #define RH_RF24_CMD_FUNC_INFO                  0x10
00055 #define RH_RF24_CMD_SET_PROPERTY               0x11
00056 #define RH_RF24_CMD_GET_PROPERTY               0x12
00057 #define RH_RF24_CMD_GPIO_PIN_CFG               0x13
00058 #define RH_RF24_CMD_GET_ADC_READING            0x14
00059 #define RH_RF24_CMD_FIFO_INFO                  0x15
00060 #define RH_RF24_CMD_PACKET_INFO                0x16
00061 #define RH_RF24_CMD_IRCAL                      0x17
00062 #define RH_RF24_CMD_PROTOCOL_CFG               0x18
00063 #define RH_RF24_CMD_GET_INT_STATUS             0x20
00064 #define RH_RF24_CMD_GET_PH_STATUS              0x21
00065 #define RH_RF24_CMD_GET_MODEM_STATUS           0x22
00066 #define RH_RF24_CMD_GET_CHIP_STATUS            0x23
00067 #define RH_RF24_CMD_START_TX                   0x31
00068 #define RH_RF24_CMD_START_RX                   0x32
00069 #define RH_RF24_CMD_REQUEST_DEVICE_STATE       0x33
00070 #define RH_RF24_CMD_CHANGE_STATE               0x34
00071 #define RH_RF24_CMD_RX_HOP                     0x36
00072 #define RH_RF24_CMD_READ_BUF                   0x44
00073 #define RH_RF24_CMD_FAST_RESPONSE_A            0x50
00074 #define RH_RF24_CMD_FAST_RESPONSE_B            0x51
00075 #define RH_RF24_CMD_FAST_RESPONSE_C            0x53
00076 #define RH_RF24_CMD_FAST_RESPONSE_D            0x57
00077 #define RH_RF24_CMD_TX_FIFO_WRITE              0x66
00078 #define RH_RF24_CMD_RX_FIFO_READ               0x77
00079 
00080 // The Clear To Send signal from the radio
00081 #define RH_RF24_REPLY_CTS                      0xff
00082 
00083 //#define RH_RF24_CMD_START_TX                   0x31
00084 #define RH_RF24_CONDITION_TX_COMPLETE_STATE      0xf0
00085 #define RH_RF24_CONDITION_RETRANSMIT_NO          0x00
00086 #define RH_RF24_CONDITION_RETRANSMIT_YES         0x04
00087 #define RH_RF24_CONDITION_START_IMMEDIATE        0x00
00088 #define RH_RF24_CONDITION_START_AFTER_WUT        0x01
00089 
00090 //#define RH_RF24_CMD_START_RX                   0x32
00091 #define RH_RF24_CONDITION_RX_START_IMMEDIATE     0x00
00092 
00093 //#define RH_RF24_CMD_REQUEST_DEVICE_STATE       0x33
00094 #define RH_RF24_DEVICE_STATE_NO_CHANGE           0x00
00095 #define RH_RF24_DEVICE_STATE_SLEEP               0x01
00096 #define RH_RF24_DEVICE_STATE_SPI_ACTIVE          0x02
00097 #define RH_RF24_DEVICE_STATE_READY               0x03
00098 #define RH_RF24_DEVICE_STATE_ALSO_READY          0x04
00099 #define RH_RF24_DEVICE_STATE_TUNE_TX             0x05
00100 #define RH_RF24_DEVICE_STATE_TUNE_RX             0x06
00101 #define RH_RF24_DEVICE_STATE_TX                  0x07
00102 #define RH_RF24_DEVICE_STATE_RX                  0x08
00103 
00104 // Properties for API Description AN625 Section 2.2
00105 #define RH_RF24_PROPERTY_GLOBAL_XO_TUNE                   0x0000
00106 #define RH_RF24_PROPERTY_GLOBAL_CLK_CFG                   0x0001
00107 #define RH_RF24_PROPERTY_GLOBAL_LOW_BATT_THRESH           0x0002
00108 #define RH_RF24_PROPERTY_GLOBAL_CONFIG                    0x0003
00109 #define RH_RF24_PROPERTY_GLOBAL_WUT_CONFIG                0x0004
00110 #define RH_RF24_PROPERTY_GLOBAL_WUT_M_15_8                0x0005
00111 #define RH_RF24_PROPERTY_GLOBAL_WUT_M_7_0                 0x0006
00112 #define RH_RF24_PROPERTY_GLOBAL_WUT_R                     0x0007
00113 #define RH_RF24_PROPERTY_GLOBAL_WUT_LDC                   0x0008
00114 #define RH_RF24_PROPERTY_INT_CTL_ENABLE                   0x0100
00115 #define RH_RF24_PROPERTY_INT_CTL_PH_ENABLE                0x0101
00116 #define RH_RF24_PROPERTY_INT_CTL_MODEM_ENABLE             0x0102
00117 #define RH_RF24_PROPERTY_INT_CTL_CHIP_ENABLE              0x0103
00118 #define RH_RF24_PROPERTY_FRR_CTL_A_MODE                   0x0200
00119 #define RH_RF24_PROPERTY_FRR_CTL_B_MODE                   0x0201
00120 #define RH_RF24_PROPERTY_FRR_CTL_C_MODE                   0x0202
00121 #define RH_RF24_PROPERTY_FRR_CTL_D_MODE                   0x0203
00122 #define RH_RF24_PROPERTY_PREAMBLE_TX_LENGTH               0x1000
00123 #define RH_RF24_PROPERTY_PREAMBLE_CONFIG_STD_1            0x1001
00124 #define RH_RF24_PROPERTY_PREAMBLE_CONFIG_NSTD             0x1002
00125 #define RH_RF24_PROPERTY_PREAMBLE_CONFIG_STD_2            0x1003
00126 #define RH_RF24_PROPERTY_PREAMBLE_CONFIG                  0x1004
00127 #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_31_24           0x1005
00128 #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_23_16           0x1006
00129 #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_15_8            0x1007
00130 #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_7_0             0x1008
00131 #define RH_RF24_PROPERTY_SYNC_CONFIG                      0x1100
00132 #define RH_RF24_PROPERTY_SYNC_BITS_31_24                  0x1101
00133 #define RH_RF24_PROPERTY_SYNC_BITS_23_16                  0x1102
00134 #define RH_RF24_PROPERTY_SYNC_BITS_15_8                   0x1103
00135 #define RH_RF24_PROPERTY_SYNC_BITS_7_0                    0x1104
00136 #define RH_RF24_PROPERTY_PKT_CRC_CONFIG                   0x1200
00137 #define RH_RF24_PROPERTY_PKT_CONFIG1                      0x1206
00138 #define RH_RF24_PROPERTY_PKT_LEN                          0x1208
00139 #define RH_RF24_PROPERTY_PKT_LEN_FIELD_SOURCE             0x1209
00140 #define RH_RF24_PROPERTY_PKT_LEN_ADJUST                   0x120a
00141 #define RH_RF24_PROPERTY_PKT_TX_THRESHOLD                 0x120b
00142 #define RH_RF24_PROPERTY_PKT_RX_THRESHOLD                 0x120c
00143 #define RH_RF24_PROPERTY_PKT_FIELD_1_LENGTH_12_8          0x120d
00144 #define RH_RF24_PROPERTY_PKT_FIELD_1_LENGTH_7_0           0x120e
00145 #define RH_RF24_PROPERTY_PKT_FIELD_1_CONFIG               0x120f
00146 #define RH_RF24_PROPERTY_PKT_FIELD_1_CRC_CONFIG           0x1210
00147 #define RH_RF24_PROPERTY_PKT_FIELD_2_LENGTH_12_8          0x1211
00148 #define RH_RF24_PROPERTY_PKT_FIELD_2_LENGTH_7_0           0x1212
00149 #define RH_RF24_PROPERTY_PKT_FIELD_2_CONFIG               0x1213
00150 #define RH_RF24_PROPERTY_PKT_FIELD_2_CRC_CONFIG           0x1214
00151 #define RH_RF24_PROPERTY_PKT_FIELD_3_LENGTH_12_8          0x1215
00152 #define RH_RF24_PROPERTY_PKT_FIELD_3_LENGTH_7_0           0x1216
00153 #define RH_RF24_PROPERTY_PKT_FIELD_3_CONFIG               0x1217
00154 #define RH_RF24_PROPERTY_PKT_FIELD_3_CRC_CONFIG           0x1218
00155 #define RH_RF24_PROPERTY_PKT_FIELD_4_LENGTH_12_8          0x1219
00156 #define RH_RF24_PROPERTY_PKT_FIELD_4_LENGTH_7_0           0x121a
00157 #define RH_RF24_PROPERTY_PKT_FIELD_4_CONFIG               0x121b
00158 #define RH_RF24_PROPERTY_PKT_FIELD_4_CRC_CONFIG           0x121c
00159 #define RH_RF24_PROPERTY_PKT_FIELD_5_LENGTH_12_8          0x121d
00160 #define RH_RF24_PROPERTY_PKT_FIELD_5_LENGTH_7_0           0x121e
00161 #define RH_RF24_PROPERTY_PKT_FIELD_5_CONFIG               0x121f
00162 #define RH_RF24_PROPERTY_PKT_FIELD_5_CRC_CONFIG           0x1220
00163 #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_LENGTH_12_8       0x1221
00164 #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_LENGTH_7_0        0x1222
00165 #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_CONFIG            0x1223
00166 #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_CRC_CONFIG        0x1224
00167 #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_LENGTH_12_8       0x1225
00168 #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_LENGTH_7_0        0x1226
00169 #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_CONFIG            0x1227
00170 #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_CRC_CONFIG        0x1228
00171 #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_LENGTH_12_8       0x1229
00172 #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_LENGTH_7_0        0x122a
00173 #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_CONFIG            0x122b
00174 #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_CRC_CONFIG        0x122c
00175 #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_LENGTH_12_8       0x122d
00176 #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_LENGTH_7_0        0x122e
00177 #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_CONFIG            0x122f
00178 #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_CRC_CONFIG        0x1230
00179 #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_LENGTH_12_8       0x1231
00180 #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_LENGTH_7_0        0x1232
00181 #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_CONFIG            0x1233
00182 #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_CRC_CONFIG        0x1234
00183 #define RH_RF24_PROPERTY_MODEM_MOD_TYPE                   0x2000
00184 #define RH_RF24_PROPERTY_MODEM_MAP_CONTROL                0x2001
00185 #define RH_RF24_PROPERTY_MODEM_DSM_CTRL                   0x2002
00186 #define RH_RF24_PROPERTY_MODEM_DATA_RATE_2                0x2003
00187 #define RH_RF24_PROPERTY_MODEM_DATA_RATE_1                0x2004
00188 #define RH_RF24_PROPERTY_MODEM_DATA_RATE_0                0x2005
00189 #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_3              0x2006
00190 #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_2              0x2007
00191 #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_1              0x2008
00192 #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_0              0x2009
00193 #define RH_RF24_PROPERTY_MODEM_FREQ_DEV_2                 0x200a
00194 #define RH_RF24_PROPERTY_MODEM_FREQ_DEV_1                 0x200b
00195 #define RH_RF24_PROPERTY_MODEM_FREQ_DEV_0                 0x200c
00196 #define RH_RF24_PROPERTY_MODEM_TX_RAMP_DELAY              0x2018
00197 #define RH_RF24_PROPERTY_MODEM_MDM_CTRL                   0x2019
00198 #define RH_RF24_PROPERTY_MODEM_IF_CONTROL                 0x201a
00199 #define RH_RF24_PROPERTY_MODEM_IF_FREQ_2                  0x201b
00200 #define RH_RF24_PROPERTY_MODEM_IF_FREQ_1                  0x201c
00201 #define RH_RF24_PROPERTY_MODEM_IF_FREQ_0                  0x201d
00202 #define RH_RF24_PROPERTY_MODEM_DECIMATION_CFG1            0x201e
00203 #define RH_RF24_PROPERTY_MODEM_DECIMATION_CFG0            0x201f
00204 #define RH_RF24_PROPERTY_MODEM_BCR_OSR_1                  0x2022
00205 #define RH_RF24_PROPERTY_MODEM_BCR_OSR_0                  0x2023
00206 #define RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_2           0x2024
00207 #define RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_1           0x2025
00208 #define RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_0           0x2026
00209 #define RH_RF24_PROPERTY_MODEM_BCR_GAIN_1                 0x2027
00210 #define RH_RF24_PROPERTY_MODEM_BCR_GAIN_0                 0x2028
00211 #define RH_RF24_PROPERTY_MODEM_BCR_GEAR                   0x2029
00212 #define RH_RF24_PROPERTY_MODEM_BCR_MISC1                  0x202a
00213 #define RH_RF24_PROPERTY_MODEM_AFC_GEAR                   0x202c
00214 #define RH_RF24_PROPERTY_MODEM_AFC_WAIT                   0x202d
00215 #define RH_RF24_PROPERTY_MODEM_AFC_GAIN_1                 0x202e
00216 #define RH_RF24_PROPERTY_MODEM_AFC_GAIN_0                 0x202f
00217 #define RH_RF24_PROPERTY_MODEM_AFC_LIMITER_1              0x2030
00218 #define RH_RF24_PROPERTY_MODEM_AFC_LIMITER_0              0x2031
00219 #define RH_RF24_PROPERTY_MODEM_AFC_MISC                   0x2032
00220 #define RH_RF24_PROPERTY_MODEM_AGC_CONTROL                0x2035
00221 #define RH_RF24_PROPERTY_MODEM_AGC_WINDOW_SIZE            0x2038
00222 #define RH_RF24_PROPERTY_MODEM_AGC_RFPD_DECAY             0x2039
00223 #define RH_RF24_PROPERTY_MODEM_AGC_IFPD_DECAY             0x203a
00224 #define RH_RF24_PROPERTY_MODEM_FSK4_GAIN1                 0x203b
00225 #define RH_RF24_PROPERTY_MODEM_FSK4_GAIN0                 0x203c
00226 #define RH_RF24_PROPERTY_MODEM_FSK4_TH1                   0x203d
00227 #define RH_RF24_PROPERTY_MODEM_FSK4_TH0                   0x203e
00228 #define RH_RF24_PROPERTY_MODEM_FSK4_MAP                   0x203f
00229 #define RH_RF24_PROPERTY_MODEM_OOK_PDTC                   0x2040
00230 #define RH_RF24_PROPERTY_MODEM_OOK_CNT1                   0x2042
00231 #define RH_RF24_PROPERTY_MODEM_OOK_MISC                   0x2043
00232 #define RH_RF24_PROPERTY_MODEM_RAW_SEARCH                 0x2044
00233 #define RH_RF24_PROPERTY_MODEM_RAW_CONTROL                0x2045
00234 #define RH_RF24_PROPERTY_MODEM_RAW_EYE_1                  0x2046
00235 #define RH_RF24_PROPERTY_MODEM_RAW_EYE_0                  0x2047
00236 #define RH_RF24_PROPERTY_MODEM_ANT_DIV_MODE               0x2048
00237 #define RH_RF24_PROPERTY_MODEM_ANT_DIV_CONTROL            0x2049
00238 #define RH_RF24_PROPERTY_MODEM_RSSI_THRESH                0x204a
00239 #define RH_RF24_PROPERTY_MODEM_RSSI_JUMP_THRESH           0x204b
00240 #define RH_RF24_PROPERTY_MODEM_RSSI_CONTROL               0x204c
00241 #define RH_RF24_PROPERTY_MODEM_RSSI_CONTROL2              0x204d
00242 #define RH_RF24_PROPERTY_MODEM_RSSI_COMP                  0x204e
00243 #define RH_RF24_PROPERTY_MODEM_ANT_DIV_CONT               0x2049
00244 #define RH_RF24_PROPERTY_MODEM_CLKGEN_BAND                0x2051
00245 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE13_7_0  0x2100
00246 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE12_7_0  0x2101
00247 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE11_7_0  0x2102
00248 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE10_7_0  0x2103
00249 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE9_7_0   0x2104
00250 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE8_7_0   0x2105
00251 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE7_7_0   0x2106
00252 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE6_7_0   0x2107
00253 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE5_7_0   0x2108
00254 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE4_7_0   0x2109
00255 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE3_7_0   0x210a
00256 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE2_7_0   0x210b
00257 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE1_7_0   0x210c
00258 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE0_7_0   0x210d
00259 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM0      0x210e
00260 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM1      0x210f
00261 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM2      0x2110
00262 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM3      0x2111
00263 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE13_7_0  0x2112
00264 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE12_7_0  0x2113
00265 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE11_7_0  0x2114
00266 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE10_7_0  0x2115
00267 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE9_7_0   0x2116
00268 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE8_7_0   0x2117
00269 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE7_7_0   0x2118
00270 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE6_7_0   0x2119
00271 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE5_7_0   0x211a
00272 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE4_7_0   0x211b
00273 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE3_7_0   0x211c
00274 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE2_7_0   0x211d
00275 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE1_7_0   0x211e
00276 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE0_7_0   0x211f
00277 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM0      0x2120
00278 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM1      0x2121
00279 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM2      0x2122
00280 #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM3      0x2123
00281 #define RH_RF24_PROPERTY_PA_MODE                          0x2200
00282 #define RH_RF24_PROPERTY_PA_PWR_LVL                       0x2201
00283 #define RH_RF24_PROPERTY_PA_BIAS_CLKDUTY                  0x2202
00284 #define RH_RF24_PROPERTY_PA_TC                            0x2203
00285 #define RH_RF24_PROPERTY_SYNTH_PFDCP_CPFF                 0x2300
00286 #define RH_RF24_PROPERTY_SYNTH_PFDCP_CPINT                0x2301
00287 #define RH_RF24_PROPERTY_SYNTH_VCO_KV                     0x2302
00288 #define RH_RF24_PROPERTY_SYNTH_LPFILT3                    0x2303
00289 #define RH_RF24_PROPERTY_SYNTH_LPFILT2                    0x2304
00290 #define RH_RF24_PROPERTY_SYNTH_LPFILT1                    0x2305
00291 #define RH_RF24_PROPERTY_SYNTH_LPFILT0                    0x2306
00292 #define RH_RF24_PROPERTY_MATCH_VALUE_1                    0x3000
00293 #define RH_RF24_PROPERTY_MATCH_MASK_1                     0x3001
00294 #define RH_RF24_PROPERTY_MATCH_CTRL_1                     0x3002
00295 #define RH_RF24_PROPERTY_MATCH_VALUE_2                    0x3003
00296 #define RH_RF24_PROPERTY_MATCH_MASK_2                     0x3004
00297 #define RH_RF24_PROPERTY_MATCH_CTRL_2                     0x3005
00298 #define RH_RF24_PROPERTY_MATCH_VALUE_3                    0x3006
00299 #define RH_RF24_PROPERTY_MATCH_MASK_3                     0x3007
00300 #define RH_RF24_PROPERTY_MATCH_CTRL_3                     0x3008
00301 #define RH_RF24_PROPERTY_MATCH_VALUE_4                    0x3009
00302 #define RH_RF24_PROPERTY_MATCH_MASK_4                     0x300a
00303 #define RH_RF24_PROPERTY_MATCH_CTRL_4                     0x300b
00304 #define RH_RF24_PROPERTY_FREQ_CONTROL_INTE                0x4000
00305 #define RH_RF24_PROPERTY_FREQ_CONTROL_FRAC_2              0x4001
00306 #define RH_RF24_PROPERTY_FREQ_CONTROL_FRAC_1              0x4002
00307 #define RH_RF24_PROPERTY_FREQ_CONTROL_FRAC_0              0x4003
00308 #define RH_RF24_PROPERTY_FREQ_CONTROL_CHANNEL_STEP_SIZE_1 0x4004
00309 #define RH_RF24_PROPERTY_FREQ_CONTROL_CHANNEL_STEP_SIZE_0 0x4005
00310 #define RH_RF24_PROPERTY_FREQ_CONTROL_VCOCNT_RX_ADJ       0x4007
00311 #define RH_RF24_PROPERTY_RX_HOP_CONTROL                   0x5000
00312 #define RH_RF24_PROPERTY_RX_HOP_TABLE_SIZE                0x5001
00313 #define RH_RF24_PROPERTY_RX_HOP_TABLE_ENTRY_0             0x5002
00314 
00315 //#define RH_RF24_CMD_GPIO_PIN_CFG               0x13
00316 #define RH_RF24_GPIO_NO_CHANGE                   0
00317 #define RH_RF24_GPIO_DISABLED                    1
00318 #define RH_RF24_GPIO_LOW                         2
00319 #define RH_RF24_GPIO_HIGH                        3
00320 #define RH_RF24_GPIO_INPUT                       4
00321 #define RH_RF24_GPIO_32_KHZ_CLOCK                5
00322 #define RH_RF24_GPIO_BOOT_CLOCK                  6
00323 #define RH_RF24_GPIO_DIVIDED_MCU_CLOCK           7
00324 #define RH_RF24_GPIO_CTS                         8
00325 #define RH_RF24_GPIO_INV_CTS                     9
00326 #define RH_RF24_GPIO_HIGH_ON_CMD_OVERLAP         10
00327 #define RH_RF24_GPIO_SPI_DATA_OUT                11
00328 #define RH_RF24_GPIO_HIGH_AFTER_RESET            12
00329 #define RH_RF24_GPIO_HIGH_AFTER_CALIBRATION      13
00330 #define RH_RF24_GPIO_HIGH_AFTER_WUT              14
00331 #define RH_RF24_GPIO_UNUSED_0                    15
00332 #define RH_RF24_GPIO_TX_DATA_CLOCK               16
00333 #define RH_RF24_GPIO_RX_DATA_CLOCK               17
00334 #define RH_RF24_GPIO_UNUSED_1                    18
00335 #define RH_RF24_GPIO_TX_DATA                     19
00336 #define RH_RF24_GPIO_RX_DATA                     20
00337 #define RH_RF24_GPIO_RX_RAW_DATA                 21
00338 #define RH_RF24_GPIO_ANTENNA_1_SWITCH            22
00339 #define RH_RF24_GPIO_ANTENNA_2_SWITCH            23
00340 #define RH_RF24_GPIO_VALID_PREAMBLE              24
00341 #define RH_RF24_GPIO_INVALID_PREAMBLE            25
00342 #define RH_RF24_GPIO_SYNC_DETECTED               26
00343 #define RH_RF24_GPIO_RSSI_ABOVE_CAT              27
00344 #define RH_RF24_GPIO_TX_STATE                    32
00345 #define RH_RF24_GPIO_RX_STATE                    33
00346 #define RH_RF24_GPIO_RX_FIFO_ALMOST_FULL         34
00347 #define RH_RF24_GPIO_TX_FIFO_ALMOST_EMPTY        35
00348 #define RH_RF24_GPIO_BATT_LOW                    36
00349 #define RH_RF24_GPIO_RSSI_ABOVE_CAT_LOW          37
00350 #define RH_RF24_GPIO_HOP                         38
00351 #define RH_RF24_GPIO_HOP_TABLE_WRAPPED           39
00352 
00353 // #define RH_RF24_CMD_GET_INT_STATUS             0x20
00354 #define RH_RF24_INT_STATUS_CHIP_INT_STATUS                0x04
00355 #define RH_RF24_INT_STATUS_MODEM_INT_STATUS               0x02
00356 #define RH_RF24_INT_STATUS_PH_INT_STATUS                  0x01
00357 #define RH_RF24_INT_STATUS_FILTER_MATCH                   0x80
00358 #define RH_RF24_INT_STATUS_FILTER_MISS                    0x40
00359 #define RH_RF24_INT_STATUS_PACKET_SENT                    0x20
00360 #define RH_RF24_INT_STATUS_PACKET_RX                      0x10
00361 #define RH_RF24_INT_STATUS_CRC_ERROR                      0x08
00362 #define RH_RF24_INT_STATUS_TX_FIFO_ALMOST_EMPTY           0x02
00363 #define RH_RF24_INT_STATUS_RX_FIFO_ALMOST_FULL            0x01
00364 #define RH_RF24_INT_STATUS_INVALID_SYNC                   0x20
00365 #define RH_RF24_INT_STATUS_RSSI_JUMP                      0x10
00366 #define RH_RF24_INT_STATUS_RSSI                           0x08
00367 #define RH_RF24_INT_STATUS_INVALID_PREAMBLE               0x04
00368 #define RH_RF24_INT_STATUS_PREAMBLE_DETECT                0x02
00369 #define RH_RF24_INT_STATUS_SYNC_DETECT                    0x01
00370 #define RH_RF24_INT_STATUS_CAL                            0x40
00371 #define RH_RF24_INT_STATUS_FIFO_UNDERFLOW_OVERFLOW_ERROR  0x20
00372 #define RH_RF24_INT_STATUS_STATE_CHANGE                   0x10
00373 #define RH_RF24_INT_STATUS_CMD_ERROR                      0x08
00374 #define RH_RF24_INT_STATUS_CHIP_READY                     0x04
00375 #define RH_RF24_INT_STATUS_LOW_BATT                       0x02
00376 #define RH_RF24_INT_STATUS_WUT                            0x01
00377 
00378 //#define RH_RF24_PROPERTY_FRR_CTL_A_MODE                   0x0200
00379 //#define RH_RF24_PROPERTY_FRR_CTL_B_MODE                   0x0201
00380 //#define RH_RF24_PROPERTY_FRR_CTL_C_MODE                   0x0202
00381 //#define RH_RF24_PROPERTY_FRR_CTL_D_MODE                   0x0203
00382 #define RH_RF24_FRR_MODE_DISABLED                         0
00383 #define RH_RF24_FRR_MODE_GLOBAL_STATUS                    1
00384 #define RH_RF24_FRR_MODE_GLOBAL_INTERRUPT_PENDING         2
00385 #define RH_RF24_FRR_MODE_PACKET_HANDLER_STATUS            3
00386 #define RH_RF24_FRR_MODE_PACKET_HANDLER_INTERRUPT_PENDING 4
00387 #define RH_RF24_FRR_MODE_MODEM_STATUS                     5
00388 #define RH_RF24_FRR_MODE_MODEM_INTERRUPT_PENDING          6
00389 #define RH_RF24_FRR_MODE_CHIP_STATUS                      7
00390 #define RH_RF24_FRR_MODE_CHIP_INTERRUPT_PENDING           8
00391 #define RH_RF24_FRR_MODE_CURRENT_STATE                    9
00392 #define RH_RF24_FRR_MODE_LATCHED_RSSI                     10
00393 
00394 //#define RH_RF24_PROPERTY_INT_CTL_ENABLE                   0x0100
00395 #define RH_RF24_CHIP_INT_STATUS_EN                        0x04
00396 #define RH_RF24_MODEM_INT_STATUS_EN                       0x02
00397 #define RH_RF24_PH_INT_STATUS_EN                          0x01
00398 
00399 //#define RH_RF24_PROPERTY_PREAMBLE_CONFIG                  0x1004
00400 #define RH_RF24_PREAMBLE_FIRST_1                          0x20
00401 #define RH_RF24_PREAMBLE_FIRST_0                          0x00
00402 #define RH_RF24_PREAMBLE_LENGTH_NIBBLES                   0x00
00403 #define RH_RF24_PREAMBLE_LENGTH_BYTES                     0x10
00404 #define RH_RF24_PREAMBLE_MAN_CONST                        0x08
00405 #define RH_RF24_PREAMBLE_MAN_ENABLE                       0x02
00406 #define RH_RF24_PREAMBLE_NON_STANDARD                     0x00
00407 #define RH_RF24_PREAMBLE_STANDARD_1010                    0x01
00408 #define RH_RF24_PREAMBLE_STANDARD_0101                    0x02
00409 
00410 //#define RH_RF24_PROPERTY_SYNC_CONFIG                      0x1100
00411 #define RH_RF24_SYNC_CONFIG_SKIP_TX                       0x80
00412 #define RH_RF24_SYNC_CONFIG_RX_ERRORS_MASK                0x70
00413 #define RH_RF24_SYNC_CONFIG_4FSK                          0x08
00414 #define RH_RF24_SYNC_CONFIG_MANCH                         0x04
00415 #define RH_RF24_SYNC_CONFIG_LENGTH_MASK                   0x03
00416 
00417 //#define RH_RF24_PROPERTY_PKT_CRC_CONFIG                   0x1200
00418 #define RH_RF24_CRC_SEED_ALL_0S                           0x00
00419 #define RH_RF24_CRC_SEED_ALL_1S                           0x80
00420 #define RH_RF24_CRC_MASK                                  0x0f
00421 #define RH_RF24_CRC_NONE                                  0x00
00422 #define RH_RF24_CRC_ITU_T                                 0x01
00423 #define RH_RF24_CRC_IEC_16                                0x02
00424 #define RH_RF24_CRC_BIACHEVA                              0x03
00425 #define RH_RF24_CRC_16_IBM                                0x04
00426 #define RH_RF24_CRC_CCITT                                 0x05
00427 #define RH_RF24_CRC_KOOPMAN                               0x06
00428 #define RH_RF24_CRC_IEEE_802_3                            0x07
00429 #define RH_RF24_CRC_CASTAGNOLI                            0x08
00430 
00431 //#define RH_RF24_PROPERTY_PKT_CONFIG1                      0x1206
00432 #define RH_RF24_PH_FIELD_SPLIT                            0x80
00433 #define RH_RF24_PH_RX_DISABLE                             0x40
00434 #define RH_RF24_4FSK_EN                                   0x20
00435 #define RH_RF24_RX_MULTI_PKT                              0x10
00436 #define RH_RF24_MANCH_POL                                 0x08
00437 #define RH_RF24_CRC_INVERT                                0x04
00438 #define RH_RF24_CRC_ENDIAN                                0x02
00439 #define RH_RF24_BIT_ORDER                                 0x01
00440 
00441 //#define RH_RF24_PROPERTY_PKT_FIELD_1_CONFIG               0x120f
00442 //#define RH_RF24_PROPERTY_PKT_FIELD_2_CONFIG               0x1213
00443 //#define RH_RF24_PROPERTY_PKT_FIELD_3_CONFIG               0x1217
00444 //#define RH_RF24_PROPERTY_PKT_FIELD_4_CONFIG               0x121b
00445 //#define RH_RF24_PROPERTY_PKT_FIELD_5_CONFIG               0x121f
00446 #define RH_RF24_FIELD_CONFIG_4FSK                         0x10
00447 #define RH_RF24_FIELD_CONFIG_WHITEN                       0x02
00448 #define RH_RF24_FIELD_CONFIG_MANCH                        0x01
00449 
00450 //#define RH_RF24_PROPERTY_PKT_RX_FIELD_1_CRC_CONFIG        0x1224
00451 //#define RH_RF24_PROPERTY_PKT_RX_FIELD_2_CRC_CONFIG        0x1228
00452 //#define RH_RF24_PROPERTY_PKT_RX_FIELD_3_CRC_CONFIG        0x122c
00453 //#define RH_RF24_PROPERTY_PKT_RX_FIELD_4_CRC_CONFIG        0x1230
00454 //#define RH_RF24_PROPERTY_PKT_RX_FIELD_5_CRC_CONFIG        0x1234
00455 #define RH_RF24_FIELD_CONFIG_CRC_START                     0x80
00456 #define RH_RF24_FIELD_CONFIG_SEND_CRC                      0x20
00457 #define RH_RF24_FIELD_CONFIG_CHECK_CRC                     0x08
00458 #define RH_RF24_FIELD_CONFIG_CRC_ENABLE                    0x02
00459 
00460 
00461 
00462 
00463 //#define RH_RF24_PROPERTY_MODEM_MOD_TYPE                   0x2000
00464 #define RH_RF24_TX_DIRECT_MODE_TYPE_SYNCHRONOUS           0x00
00465 #define RH_RF24_TX_DIRECT_MODE_TYPE_ASYNCHRONOUS          0x80
00466 #define RH_RF24_TX_DIRECT_MODE_GPIO0                      0x00
00467 #define RH_RF24_TX_DIRECT_MODE_GPIO1                      0x20
00468 #define RH_RF24_TX_DIRECT_MODE_GPIO2                      0x40
00469 #define RH_RF24_TX_DIRECT_MODE_GPIO3                      0x60
00470 #define RH_RF24_MOD_SOURCE_PACKET_HANDLER                 0x00
00471 #define RH_RF24_MOD_SOURCE_DIRECT_MODE                    0x08
00472 #define RH_RF24_MOD_SOURCE_RANDOM_GENERATOR               0x10
00473 #define RH_RF24_MOD_TYPE_CW                               0x00
00474 #define RH_RF24_MOD_TYPE_OOK                              0x01
00475 #define RH_RF24_MOD_TYPE_2FSK                             0x02
00476 #define RH_RF24_MOD_TYPE_2GFSK                            0x03
00477 #define RH_RF24_MOD_TYPE_4FSK                             0x04
00478 #define RH_RF24_MOD_TYPE_4GFSK                            0x05
00479 
00480 //    RH_RF24_PROPERTY_PA_MODE                          0x2200
00481 #define RH_RF24_PA_MODE_1_GROUP                           0x04
00482 #define RH_RF24_PA_MODE_2_GROUPS                          0x08
00483 #define RH_RF24_PA_MODE_CLASS_E                           0x00
00484 #define RH_RF24_PA_MODE_SWITCH_CURRENT                    0x01
00485 
00486 
00487 /////////////////////////////////////////////////////////////////////
00488 /// \class RH_RF24 RH_RF24.h <RH_RF24.h>
00489 /// \brief Driver to send and receive unaddressed, unreliable datagrams via an RF24 and compatible radio transceiver.
00490 ///
00491 /// Works with 
00492 /// - Silicon Labs Si4460/1/2/3/4 transceiver chips
00493 /// - The equivalent HopeRF RF24/25/26/27 transceiver chips
00494 /// - HopeRF Complete modules: RFM24W/26W/27W
00495 ///
00496 /// \par Overview
00497 ///
00498 /// This class provides basic functions for sending and receiving unaddressed, 
00499 /// unreliable datagrams of arbitrary length to 250 octets per packet.
00500 ///
00501 /// Manager classes may use this class to implement reliable, addressed datagrams and streams, 
00502 /// mesh routers, repeaters, translators etc.
00503 ///
00504 /// Naturally, for any 2 radios to communicate that must be configured to use the same frequency and 
00505 /// modulation scheme.
00506 ///
00507 /// This Driver provides an object-oriented interface for sending and receiving data messages with Hope-RF
00508 /// RF24 and compatible radio modules, such as the RFM24W module.
00509 ///
00510 /// The Hope-RF (http://www.hoperf.com) RF24 family is a low-cost ISM transceiver
00511 /// chip. It supports FSK, GFSK, OOK over a wide range of frequencies and
00512 /// programmable data rates. HopeRF also sell these chips on modules which includes
00513 /// a crystal and antenna coupling circuits: RFM24W, RFM26W and RFM27W
00514 ///
00515 /// This Driver provides functions for sending and receiving messages of up
00516 /// to 250 octets on any frequency supported by the RF24, in a range of
00517 /// predefined data rates and frequency deviations. Frequency can be set
00518 /// to any frequency from 142.0MHz to 1050.0MHz. Caution: most modules only support a more limited
00519 /// range of frequencies due to antenna tuning.
00520 ///
00521 /// Up to 2 RFM24 modules can be connected to an Arduino (3 on a Mega),
00522 /// permitting the construction of translators and frequency changers, etc.
00523 ///
00524 /// The following modulation types are suppported with a range of modem configurations for 
00525 /// common data rates and frequency deviations:
00526 /// - OOK On-Off Keying
00527 /// - GFSK Gaussian Frequency Shift Keying
00528 /// - FSK Frequency Shift Keying
00529 ///
00530 /// Support for other RF24 features such as on-chip temperature measurement, 
00531 /// transmitter power control etc is also provided.
00532 ///
00533 /// RH_RF24 uses interrupts to detect and handle events in the radio chip. The RF24 family has
00534 /// TX and RX FIFOs of 64 bytes, but through the use of interrupt, the RH_RF24 driver can send longer 
00535 /// messages by filling or emptying the FIFOs on-the-fly.
00536 ///
00537 /// Tested on Anarduino Mini http://www.anarduino.com/mini/ with arduino-1.0.5
00538 /// on OpenSuSE 13.1
00539 ///
00540 /// \par Packet Format
00541 ///
00542 /// All messages sent and received by this RH_RF24 Driver conform to this packet format:
00543 ///
00544 /// - 4 octets PREAMBLE (configurable)
00545 /// - 2 octets SYNC 0x2d, 0xd4 (configurable, so you can use this as a network filter)
00546 /// - Field containing 1 octet of message length and 2 octet CRC protecting this field
00547 /// - Field 2 containing at least 4 octets, and 2 octet CRC protecting this field:
00548 ///  + 4 octets HEADER: (TO, FROM, ID, FLAGS)
00549 ///  + 0 to 250 octets DATA 
00550 ///  + 2 octets CRC, computed on HEADER and DATA
00551 ///
00552 /// \par Connecting RFM-24 to Arduino
00553 ///
00554 /// For RFM24/RFM26 and Teensy 3.1 or Anarduino Mini
00555 /// \code
00556 ///                 Teensy      RFM-24/RFM26
00557 ///                 GND----------GND (ground in)
00558 ///                 3V3----------VCC   (3.3V in)
00559 /// interrupt 2 pin D2-----------NIRQ  (interrupt request out)
00560 ///          SS pin D10----------NSEL  (chip select in)
00561 ///         SCK pin D13----------SCK   (SPI clock in)
00562 ///        MOSI pin D11----------SDI   (SPI Data in)
00563 ///        MISO pin D12----------SDO   (SPI data out)
00564 ///                 D9-----------SDN   (shutdown in)
00565 ///                           /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
00566 ///                           \--TX_ANT (TX antenna control in) RFM22B only
00567 ///                           /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
00568 ///                           \--RX_ANT (RX antenna control in) RFM22B only
00569 /// \endcode
00570 /// Caution: tying the radio SDN pin to ground (though it might appear from the data sheets to make sense) 
00571 /// does not always produce a reliable radio startup. So this driver controls the SDN pin directly.
00572 /// Note: the GPIO0-TX_ANT and GPIO1-RX_ANT connections are not required for the 11dBm RFM24W, 
00573 /// which has no antenna switch.
00574 ///
00575 /// \par Customising
00576 ///
00577 /// The library will work out of the box with the provided examples, over the full frequency range and with
00578 /// a wide range of predefined modem configurations schemes and speeds. However, you may want to 
00579 /// change the default behaviour of this library. There are several ways you can do this:
00580 ///
00581 /// - Use the RH_RF24 API based on this documentation
00582 /// - Create your own ModemConfig and pass it to setModemreeegisters()
00583 /// - Generate a new radio_config_Si4460.h using the Silicon Labs WDS software package
00584 /// - Write directly to the radio registers and properties using command() and set_properties()
00585 ///
00586 /// \par RSSI
00587 ///
00588 /// The RSSI (Received Signal Strength Indicator) is measured and latched after the message sync bytes are received.
00589 /// The latched RSSI is available from the lastRssi() member functionafter the complete message is received. 
00590 /// Although lastRssi() 
00591 /// supposedly returns a signed integer, in the case of this radio it actually returns an unsigned 8 bit integer (uint8_t)
00592 /// and you will have to cast the return value to use it:
00593 /// \code
00594 /// uint8_t lastRssi = (uint8_t)rf24.lastRssi();
00595 /// \endcode
00596 /// The units of RSSI are arbitrary and relative, with larger unsigned numbers indicating a stronger signal. Values up to 255
00597 /// are seen with radios in close proximity to each other. Lower limit of receivable strength is about 70.
00598 ///
00599 /// \par Transmitter Power
00600 ///
00601 /// You can control the transmitter power on the RF24/25/26/27 transceiver
00602 /// with the RH_RF24::setTxPower() function. The argument can be any of
00603 /// 0x00 to 0x4f (for RFM24/Si4460) or
00604 /// 0x00 to 0x7f (for others)
00605 /// 0x00 will yield no measurable power. For other settings there is a non-linear correlation with actual
00606 /// RF power output (see below)
00607 /// The default is 0x10. Eg:
00608 /// \code
00609 /// driver.setTxPower(0x10);
00610 /// \endcode
00611 ///
00612 /// We have made some actual power measurements against
00613 /// programmed power
00614 /// - Anarduino Mini with RFM24-433 and RFM26-433 at Vcc = 3.3V, in CW mode, 434MHz
00615 /// - 10cm RG58C/U soldered direct to RFM69 module ANT and GND
00616 /// - bnc connecteor
00617 /// - 12dB attenuator
00618 /// - BNC-SMA adapter
00619 /// - MiniKits AD8307 HF/VHF Power Head (calibrated against Rohde&Schwartz 806.2020 test set)
00620 /// - Digitech QM-1460 digital multimeter
00621 /// \code
00622 /// Program power           Measured Power dBm
00623 ///    HEX                  RFM24                RFM26
00624 ///    0x00                 not measurable       not measurable
00625 ///    0x01                 -20.4                -20.6
00626 ///    0x0f                 2.4                  4.8
00627 ///    0x1f                 9.4                  11.0
00628 ///    0x2f                 11.2                 14.2
00629 ///    0x3f                 11.6                 16.4
00630 ///    0x4f                 11.6                 18.0
00631 ///    0x5f                                      18.6
00632 ///    0x6f                                      19.0
00633 ///    0x7f                                      19.2
00634 /// \endcode
00635 /// Caution: the actual radiated power output will depend heavily on the power supply voltage and the antenna.
00636 
00637 class RH_RF24 : public RHSPIDriver
00638 {
00639 public:
00640     /// \brief Defines property values for a set of modem configuration registers
00641     ///
00642     /// Defines property values for a set of modem configuration registers
00643     /// that can be passed to setModemRegisters() if none of the choices in
00644     /// ModemConfigChoice suit your need setModemRegisters() writes the
00645     /// property values from this structure to the appropriate RF24 properties
00646     /// to set the desired modulation type, data rate and deviation/bandwidth.
00647     typedef struct
00648     {
00649     uint8_t   prop_2000;   ///< Value for property RH_RF24_PROPERTY_MODEM_MOD_TYPE
00650     uint8_t   prop_2003;   ///< Value for property RH_RF24_PROPERTY_MODEM_DATA_RATE_2
00651     uint8_t   prop_2004;   ///< Value for property RH_RF24_PROPERTY_MODEM_DATA_RATE_1
00652     uint8_t   prop_2005;   ///< Value for property RH_RF24_PROPERTY_MODEM_DATA_RATE_0
00653     uint8_t   prop_2006;   ///< Value for property RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_3
00654     uint8_t   prop_200a;   ///< Value for property RH_RF24_PROPERTY_MODEM_FREQ_DEV_2
00655     uint8_t   prop_200b;   ///< Value for property RH_RF24_PROPERTY_MODEM_FREQ_DEV_1
00656     uint8_t   prop_200c;   ///< Value for property RH_RF24_PROPERTY_MODEM_FREQ_DEV_0
00657     uint8_t   prop_2018;   ///< Value for property RH_RF24_PROPERTY_MODEM_TX_RAMP_DELAY
00658     uint8_t   prop_201e;   ///< Value for property RH_RF24_PROPERTY_MODEM_DECIMATION_CFG1
00659     uint8_t   prop_201f;   ///< Value for property RH_RF24_PROPERTY_MODEM_DECIMATION_CFG0
00660     uint8_t   prop_2022;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_OSR_1
00661     uint8_t   prop_2023;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_OSR_0
00662     uint8_t   prop_2024;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_2
00663     uint8_t   prop_2025;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_1
00664     uint8_t   prop_2026;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_0
00665     uint8_t   prop_2027;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_GAIN_1
00666     uint8_t   prop_2028;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_GAIN_0
00667     uint8_t   prop_2029;   ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_GEAR
00668     uint8_t   prop_202d;   ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_WAIT
00669     uint8_t   prop_202e;   ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_GAIN_1
00670     uint8_t   prop_202f;   ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_GAIN_0
00671     uint8_t   prop_2030;   ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_LIMITER_1
00672     uint8_t   prop_2031;   ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_LIMITER_0
00673     uint8_t   prop_2035;   ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_CONTROL
00674     uint8_t   prop_2038;   ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_WINDOW_SIZE
00675     uint8_t   prop_2039;   ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_RFPD_DECAY
00676     uint8_t   prop_203a;   ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_IFPD_DECAY
00677     uint8_t   prop_203b;   ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_GAIN1
00678     uint8_t   prop_203c;   ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_GAIN0
00679     uint8_t   prop_203d;   ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_TH1
00680     uint8_t   prop_203e;   ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_TH0
00681     uint8_t   prop_203f;   ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_MAP
00682     uint8_t   prop_2040;   ///< Value for property RH_RF24_PROPERTY_MODEM_OOK_PDTC
00683     uint8_t   prop_2043;   ///< Value for property RH_RF24_PROPERTY_MODEM_OOK_MISC
00684     uint8_t   prop_2045;   ///< Value for property RH_RF24_PROPERTY_MODEM_RAW_CONTROL
00685     uint8_t   prop_2046;   ///< Value for property RH_RF24_PROPERTY_MODEM_RAW_EYE_1
00686     uint8_t   prop_2047;   ///< Value for property RH_RF24_PROPERTY_MODEM_RAW_EYE_0
00687     uint8_t   prop_204e;   ///< Value for property RH_RF24_PROPERTY_MODEM_RSSI_COMP
00688     uint8_t   prop_2100;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE13_7_0
00689     uint8_t   prop_2101;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE12_7_0
00690     uint8_t   prop_2102;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE11_7_0
00691     uint8_t   prop_2103;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE10_7_0
00692     uint8_t   prop_2104;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE9_7_0
00693     uint8_t   prop_2105;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE8_7_0
00694     uint8_t   prop_2106;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE7_7_0
00695     uint8_t   prop_2107;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE6_7_0
00696     uint8_t   prop_2108;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE5_7_0
00697     uint8_t   prop_2109;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE4_7_0
00698     uint8_t   prop_210a;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE3_7_0
00699     uint8_t   prop_210b;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE2_7_0
00700     uint8_t   prop_210c;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE1_7_0
00701     uint8_t   prop_210d;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE0_7_0
00702     uint8_t   prop_210e;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM0
00703     uint8_t   prop_210f;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM1
00704     uint8_t   prop_2110;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM2
00705     uint8_t   prop_2111;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM3
00706     uint8_t   prop_2112;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE13_7_0
00707     uint8_t   prop_2113;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE12_7_0
00708     uint8_t   prop_2114;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE11_7_0
00709     uint8_t   prop_2115;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE10_7_0
00710     uint8_t   prop_2116;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE9_7_0
00711     uint8_t   prop_2117;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE8_7_0
00712     uint8_t   prop_2118;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE7_7_0
00713     uint8_t   prop_2119;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE6_7_0
00714     uint8_t   prop_211a;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE5_7_0
00715     uint8_t   prop_211b;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE4_7_0
00716     uint8_t   prop_211c;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE3_7_0
00717     uint8_t   prop_211d;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE2_7_0
00718     uint8_t   prop_211e;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE1_7_0
00719     uint8_t   prop_211f;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE0_7_0
00720     uint8_t   prop_2120;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM0
00721     uint8_t   prop_2121;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM1
00722     uint8_t   prop_2122;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM2
00723     uint8_t   prop_2123;   ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM3
00724     uint8_t   prop_2203;   ///< Value for property RH_RF24_PROPERTY_PA_TC
00725     uint8_t   prop_2300;   ///< Value for property RH_RF24_PROPERTY_SYNTH_PFDCP_CPFF
00726     uint8_t   prop_2301;   ///< Value for property RH_RF24_PROPERTY_SYNTH_PFDCP_CPINT
00727     uint8_t   prop_2303;   ///< Value for property RH_RF24_PROPERTY_SYNTH_LPFILT3
00728     uint8_t   prop_2304;   ///< Value for property RH_RF24_PROPERTY_SYNTH_LPFILT2
00729     uint8_t   prop_2305;   ///< Value for property RH_RF24_PROPERTY_SYNTH_LPFILT1
00730     } ModemConfig;
00731   
00732     /// Choices for setModemConfig() for a selected subset of common
00733     /// modulation types, and data rates. If you need another configuration,
00734     /// use the register calculator.  and call setModemRegisters() with your
00735     /// desired settings.  
00736     /// These are indexes into MODEM_CONFIG_TABLE. We strongly recommend you use these symbolic
00737     /// definitions and not their integer equivalents: its possible that values will be
00738     /// changed in later versions (though we will try to avoid it).
00739     /// Contributions of new complete and tested ModemConfigs ready to add to this list will be readily accepted.
00740     typedef enum
00741     {
00742     FSK_Rb0_5Fd1 = 0,         ///< FSK  Rb = 0.5kbs, Fd = 1kHz
00743     FSK_Rb5Fd10,              ///< FSK  Rb = 5kbs,   Fd = 10kHz
00744     FSK_Rb50Fd100,            ///< FSK  Rb = 50kbs,  Fd = 100kHz
00745     FSK_Rb150Fd300,           ///< FSK  Rb = 50kbs,  Fd = 100kHz
00746 
00747     GFSK_Rb0_5Fd1,            ///< GFSK Rb = 0.5kbs, Fd = 1kHz
00748     GFSK_Rb5Fd10,             ///< GFSK Rb = 5kbs,   Fd = 10kHz
00749     GFSK_Rb50Fd100,           ///< GFSK Rb = 50kbs,  Fd = 100kHz
00750     GFSK_Rb150Fd300,          ///< GFSK Rb = 150kbs, Fd = 300kHz
00751     
00752     // We were unable to get any other OOKs to work
00753     OOK_Rb5Bw30,              ///< OOK  Rb = 5kbs,   Bw = 30kHz
00754     OOK_Rb10Bw40,             ///< OOK  Rb = 10kbs,  Bw = 40kHz
00755 
00756     // We were unable to get any 4FSK or 4GFSK schemes to work
00757 
00758     } ModemConfigChoice;
00759 
00760     /// \brief Defines the available choices for CRC
00761     /// Types of permitted CRC polynomials, to be passed to setCRCPolynomial()
00762     /// They deliberately have the same numeric values as the CRC_POLYNOMIAL field of PKT_CRC_CONFIG
00763     typedef enum
00764     {
00765     CRC_NONE = 0,
00766     CRC_ITU_T,
00767     CRC_IEC_16,
00768     CRC_Biacheva,
00769     CRC_16_IBM,
00770     CRC_CCITT,
00771     CRC_Koopman,
00772     CRC_IEEE_802_3,
00773     CRC_Castagnoli,
00774     } CRCPolynomial;
00775 
00776     /// \brief Defines the commands we can interrogate in printRegisters
00777     typedef struct
00778     {
00779     uint8_t      cmd;       ///< The command number
00780     uint8_t      replyLen;  ///< Number of bytes in the reply stream (after the CTS)
00781     }   CommandInfo;
00782 
00783     /// Constructor. You can have multiple instances, but each instance must have its own
00784     /// interrupt and slave select pin. After constructing, you must call init() to initialise the interface
00785     /// and the radio module. A maximum of 3 instances can co-exist on one processor, provided there are sufficient
00786     /// distinct interrupt lines, one for each instance.
00787     /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RF24 before
00788     /// accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega, D10 for Maple)
00789     /// \param[in] interruptPin The interrupt Pin number that is connected to the RF24 DIO0 interrupt line. 
00790     /// Defaults to pin 2.
00791     /// Caution: You must specify an interrupt capable pin.
00792     /// On many Arduino boards, there are limitations as to which pins may be used as interrupts.
00793     /// On Leonardo pins 0, 1, 2 or 3. On Mega2560 pins 2, 3, 18, 19, 20, 21. On Due and Teensy, any digital pin.
00794     /// On other Arduinos pins 2 or 3. 
00795     /// See http://arduino.cc/en/Reference/attachInterrupt for more details.
00796     /// On Chipkit Uno32, pins 38, 2, 7, 8, 35.
00797     /// On other boards, any digital pin may be used.
00798     /// \param [in] sdnPin The pin number connected to SDN on the radio. Defaults to pin 9. 
00799     ///                     Connecting SDN directly to ground does not aloways provide reliable radio startup.
00800     /// \param[in] spi Pointer to the SPI interface object to use. 
00801     ///                Defaults to the standard Arduino hardware SPI interface
00802     RH_RF24(PINS slaveSelectPin, PINS interruptPin, PINS sdnPin, RHGenericSPI& spi = hardware_spi);
00803   
00804     /// Initialises this instance and the radio module connected to it.
00805     /// The following steps are taken:
00806     /// - Initialise the slave select and shutdown pins and the SPI interface library
00807     /// - Checks the connected RF24 module can be communicated
00808     /// - Attaches an interrupt handler
00809     /// - Configures the RF24 module
00810     /// - Sets the frequency to 434.0 MHz
00811     /// - Sets the modem data rate to GFSK_Rb5Fd10
00812     /// - Sets the tranmitter power level to 16 (about 2.4dBm on RFM4)
00813     /// \return  true if everything was successful
00814     bool        init();
00815     
00816     /// Sets the chip mode that will be used when the RH_RF24 driver is idle (ie not transmitting or receiving)
00817     /// You can use this to control the power level consumed while idle, at the cost of slower
00818     /// transition to tranmit or receive states
00819     /// \param[in] idleMode The chip state to use when idle. Sensible choices might be RH_RF24_DEVICE_STATE_SLEEP or RH_RF24_DEVICE_STATE_READY
00820     void        setIdleMode(uint8_t idleMode);
00821 
00822     /// Sets the transmitter and receiver 
00823     /// centre frequency.
00824     /// Valid frequency ranges for RFM24/Si4460, Si4461, RFM25/Si4463 are:
00825     /// 142MHz to 175Mhz, 284MHz to 350MHz, 425MHz to 525MHz, 850MHz to 1050MHz.
00826     /// Valid frequency ranges for RFM26/Si4464 are:
00827     /// 119MHz to 960MHz.
00828     /// Caution: RFM modules are designed with antenna coupling components to suit a limited band
00829     /// of frequencies (marked underneath the module). It is possible to set frequencies in other bands,
00830     /// but you may only get little or no power radiated.
00831     /// \param[in] centre Frequency in MHz. 
00832     /// \param[in] afcPullInRange Not used
00833     /// \return true if the selected frequency is within a valid range for the connected radio and if
00834     ///         setting the new frequency succeeded.
00835     bool        setFrequency(float centre, float afcPullInRange = 0.05);
00836 
00837     /// Sets all the properties required to configure the data modem in the RF24, including the data rate, 
00838     /// bandwidths etc. You can use this to configure the modem with custom configurations if none of the 
00839     /// canned configurations in ModemConfigChoice suit you.
00840     /// \param[in] config A ModemConfig structure containing values for the modem configuration registers.
00841     void           setModemRegisters(const ModemConfig* config);
00842 
00843     /// Select one of the predefined modem configurations. If you need a modem configuration not provided 
00844     /// here, use setModemRegisters() with your own ModemConfig. The default after init() is RH_RF24::GFSK_Rb5Fd10.
00845     /// \param[in] index The configuration choice.
00846     /// \return true if index is a valid choice.
00847     bool        setModemConfig(ModemConfigChoice index);
00848 
00849     /// Starts the receiver and checks whether a received message is available.
00850     /// This can be called multiple times in a timeout loop
00851     /// \return true if a complete, valid message has been received and is able to be retrieved by
00852     /// recv()
00853     bool        available();
00854 
00855     /// Turns the receiver on if it not already on.
00856     /// If there is a valid message available, copy it to buf and return true
00857     /// else return false.
00858     /// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted).
00859     /// You should be sure to call this function frequently enough to not miss any messages
00860     /// It is recommended that you call it in your main loop.
00861     /// \param[in] buf Location to copy the received message
00862     /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
00863     /// \return true if a valid message was copied to buf
00864     bool        recv(uint8_t* buf, uint8_t* len);
00865 
00866     /// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
00867     /// Then loads a message into the transmitter and starts the transmitter. Note that a message length
00868     /// of 0 is NOT permitted. 
00869     /// \param[in] data Array of data to be sent
00870     /// \param[in] len Number of bytes of data to send (> 0)
00871     /// \return true if the message length was valid and it was correctly queued for transmit
00872     bool        send(const uint8_t* data, uint8_t len);
00873 
00874     /// The maximum message length supported by this driver
00875     /// \return The maximum message length supported by this driver
00876     uint8_t maxMessageLength();
00877 
00878     /// Sets the length of the preamble
00879     /// in bytes. 
00880     /// Caution: this should be set to the same 
00881     /// value on all nodes in your network. Default is 4.
00882     /// \param[in] bytes Preamble length in bytes.  
00883     void           setPreambleLength(uint16_t bytes);
00884 
00885     /// Sets the sync words for transmit and receive 
00886     /// Caution: SyncWords should be set to the same 
00887     /// value on all nodes in your network. Nodes with different SyncWords set will never receive
00888     /// each others messages, so different SyncWords can be used to isolate different
00889     /// networks from each other. Default is { 0x2d, 0xd4 }.
00890     /// \param[in] syncWords Array of sync words, 1 to 4 octets long. NULL if no sync words to be used.
00891     /// \param[in] len Number of sync words to set, 1 to 4. 0 if no sync words to be used.
00892     void           setSyncWords(const uint8_t* syncWords = NULL, uint8_t len = 0);
00893 
00894     /// Sets the CRC polynomial to be used to generate the CRC for both receive and transmit
00895     /// otherwise the default of CRC_16_IBM will be used.
00896     /// \param[in] polynomial One of RH_RF24::CRCPolynomial choices CRC_*
00897     /// \return true if polynomial is a valid option for this radio.
00898     bool setCRCPolynomial(CRCPolynomial polynomial);
00899 
00900     /// If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running, 
00901     /// disables them.
00902     void           setModeIdle();
00903 
00904     /// If current mode is Tx or Idle, changes it to Rx. 
00905     /// Starts the receiver in the RF24.
00906     void           setModeRx();
00907 
00908     /// If current mode is Rx or Idle, changes it to Rx. F
00909     /// Starts the transmitter in the RF24.
00910     void           setModeTx();
00911 
00912     /// Sets the transmitter power output level register PA_PWR_LVL
00913     /// The power argument to this function has a non-linear correlation with the actual RF power output.
00914     /// See the transmitter power table above for some examples.
00915     /// Also the Si446x Data Sheet section 5.4.2 may be helpful.
00916     /// Be a good neighbour and set the lowest power level you need.
00917     /// Caution: legal power limits may apply in certain countries.
00918     /// After init(), the power will be set to 0x10.
00919     /// \param[in] power Transmitter power level. For RFM24/Si4460, valid values are 0x00 to 0x4f. For others, 0x00 to 0x7f
00920     void           setTxPower(uint8_t power);
00921 
00922     /// Dump the values of available command replies and properties
00923     /// to the Serial device if RH_HAVE_SERIAL is defined for the current platform
00924     /// Not all commands have valid replies, therefore they are not all printed.
00925     /// Caution: the list is very long
00926     bool           printRegisters();
00927 
00928     /// Send a string of command bytes to the chip and get a string of reply bytes
00929     /// Different RFM24 commands take different numbers of command bytes and send back different numbers
00930     /// of reply bytes. See the Si446x documentaiton for more details.
00931     /// Both command bytes and reply bytes are optional
00932     /// \param[in] cmd The command number. One of RH_RF24_CMD_*
00933     /// \param[in] write_buf Pointer to write_len bytes of command input bytes to send. If there are none, set to NULL.
00934     /// \param[in] write_len The number of bytes to send from write_buf. If there are none, set to 0
00935     /// \param[out] read_buf Pointer to read_len bytes of storage where the reply stream from the comand will be written.
00936     ///            If none are required, set to NULL
00937     /// \param[in] read_len The number of bytes to read from the reply stream. If none required, set to 0.
00938     /// \return true if the command succeeeded.
00939     bool           command(uint8_t cmd, const uint8_t* write_buf = 0, uint8_t write_len = 0, uint8_t* read_buf = 0, uint8_t read_len = 0);
00940 
00941     /// Set one or more chip properties using the RH_RF24_CMD_SET_PROPERTY
00942     /// command. See the Si446x API Description AN625 for details on what properties are available.
00943     /// param[in] firstProperty The property number of the first property to set. The first value in the values array
00944     ///           will be used to set this property, and any subsequent values will be used to set the following properties.
00945     ///           One of RH_RF24_PROPERTY_*
00946     /// param[in] values Array of 0 or more values to write the firstProperty and subsequent proerties
00947     /// param[in] count The number of values in the values array
00948     /// \return true if the command succeeeded.
00949     bool           set_properties(uint16_t firstProperty, const uint8_t* values, uint8_t count);
00950 
00951     /// Get one or more chip properties using the RH_RF24_CMD_GET_PROPERTY
00952     /// command. See the Si446x API Description AN625 for details on what properties are available.
00953     /// param[in] firstProperty The property number of the first property to get. The first value in the values array
00954     ///           will be set with this property, and any subsequent values will be set from the following properties.
00955     ///           One of RH_RF24_PROPERTY_*
00956     /// param[out] values Array of 0 or more values to receive the firstProperty and subsequent proerties
00957     /// param[in] count The number of values in the values array
00958     /// \return true if the command succeeeded.
00959     bool           get_properties(uint16_t firstProperty, uint8_t* values, uint8_t count);
00960 
00961     /// Measures and returns the current
00962     /// Chip temperature.
00963     /// \return The current chip temperature in degrees Centigrade
00964     float          get_temperature();
00965 
00966     /// Measures and returns the current
00967     /// Chip Vcc supply voltage.
00968     /// \return The current chip Vcc supply voltage in Volts.
00969     float          get_battery_voltage();
00970 
00971     /// Measures and returns the current
00972     /// voltage applied to a GPIO pin (which has previously been configured as a voltage input)
00973     /// \param[in] gpio The GPIO pin to read. 0 to 3.
00974     /// \return The current pin voltage in Volts.
00975     float          get_gpio_voltage(uint8_t gpio);
00976 
00977     /// Read one of the Fast Read Response registers.
00978     /// The Fast Read Response register must be previously configured with the matching
00979     /// RH_RF24_PROPERTY_FRR_CTL_?_MODE property to select what chip property will be available in that register.
00980     /// \param[in] reg The index of the FRR register to read. 0 means FRR A, 1 means B etc.
00981     /// \return the value read from the specified Fast Read Response register.
00982     uint8_t        frr_read(uint8_t reg);
00983 
00984     /// Sets the radio into low-power sleep mode.
00985     /// If successful, the transport will stay in sleep mode until woken by 
00986     /// changing mode it idle, transmit or receive (eg by calling send(), recv(), available() etc)
00987     /// Caution: there is a time penalty as the radio takes a finte time to wake from sleep mode.
00988     /// \return true if sleep mode was successfully entered.
00989     virtual bool    sleep();
00990 
00991 protected:
00992     /// This is a low level function to handle the interrupts for one instance of RF24.
00993     /// Called automatically by isr*()
00994     /// Should not need to be called by user code.
00995     void           handleInterrupt();
00996 
00997     /// Clears the chips RX FIFO
00998     /// \return true if successful
00999     bool           clearRxFifo();
01000 
01001     /// Clears RH_RF24's internal TX and RX buffers and counters
01002     void           clearBuffer();
01003 
01004     /// Loads the next part of the currently transmitting message 
01005     /// into the chips TX buffer
01006     void           sendNextFragment();
01007 
01008     /// Copies the next part of the currenrtly received message from the chips RX FIFO to the 
01009     /// receive buffer
01010     void           readNextFragment();
01011 
01012     /// Loads data into the chips TX FIFO
01013     /// \param[in] data Array of data bytes to be loaded
01014     /// \param[in] len Number of bytes in data to be loaded
01015     /// \return true if successful
01016     bool           writeTxFifo(uint8_t *data, uint8_t len);
01017 
01018     /// Checks the contents of the RX buffer.
01019     /// If it contans a valid message adressed to this node
01020     /// sets _rxBufValid.
01021     void           validateRxBuf();
01022 
01023     /// Cycles the Shutdown pin to force the cradio chip to reset
01024     void           power_on_reset();
01025 
01026     /// Sets registers, commands and properties
01027     /// in the ratio according to the data in the commands array
01028     /// \param[in] commands Array of data containing radio commands in the format provided by radio_config_Si4460.h
01029     /// \return true if successful
01030     bool           configure(const uint8_t* commands);
01031 
01032     /// Clears all pending interrutps in the radio chip.
01033     bool           cmd_clear_all_interrupts();
01034 
01035 private:
01036 
01037     /// Low level interrupt service routine for RF24 connected to interrupt 0
01038     static void         isr0();
01039 
01040     /// Low level interrupt service routine for RF24 connected to interrupt 1
01041     static void         isr1();
01042 
01043     /// Low level interrupt service routine for RF24 connected to interrupt 1
01044     static void         isr2();
01045 
01046     /// Array of instances connected to interrupts 0 and 1
01047     static RH_RF24*     _deviceForInterrupt[];
01048 
01049     /// Index of next interrupt number to use in _deviceForInterrupt
01050     static uint8_t      _interruptCount;
01051 
01052 #if (RH_PLATFORM == RH_PLATFORM_MBED)
01053     /// The configured interrupt pin connected to this instance
01054     InterruptIn             _interruptPin;
01055 #else
01056     /// The configured interrupt pin connected to this instance
01057     uint8_t             _interruptPin;
01058 #endif
01059 
01060     /// The index into _deviceForInterrupt[] for this device (if an interrupt is already allocated)
01061     /// else 0xff
01062     uint8_t             _myInterruptIndex;
01063 
01064 #if (RH_PLATFORM == RH_PLATFORM_MBED)
01065     /// The configured pin connected to the SDN pin of the radio
01066     DigitalOut             _sdnPin;
01067 #else
01068     /// The configured pin connected to the SDN pin of the radio
01069     uint8_t             _sdnPin;
01070 #endif
01071 
01072     /// The radio OP mode to use when mode is RHModeIdle
01073     uint8_t             _idleMode; 
01074 
01075     /// The reported PART device type
01076     uint16_t             _deviceType;
01077 
01078     /// The selected output power in dBm
01079     int8_t              _power;
01080 
01081     /// The message length in _buf
01082     volatile uint8_t    _bufLen;
01083 
01084     /// Array of octets of the last received message or the next to transmit message
01085     uint8_t             _buf[RH_RF24_MAX_PAYLOAD_LEN];
01086 
01087     /// True when there is a valid message in the Rx buffer
01088     volatile bool       _rxBufValid;
01089 
01090     /// Index into TX buffer of the next to send chunk
01091     volatile uint8_t    _txBufSentIndex;
01092   
01093     /// Time in millis since the last preamble was received (and the last time the RSSI was measured)
01094     uint32_t            _lastPreambleTime;
01095 
01096 };
01097 
01098 /// @example rf24_client.pde
01099 /// @example rf24_server.pde
01100 /// @example rf24_reliable_datagram_client.pde
01101 /// @example rf24_reliable_datagram_server.pde
01102 
01103 #endif