V148
Fork of RadioHead-148 by
RH_RF24.h@1:b7641da2b203, 2017-10-25 (annotated)
- Committer:
- ilkaykozak
- Date:
- Wed Oct 25 05:14:09 2017 +0000
- Revision:
- 1:b7641da2b203
- Parent:
- 0:ab4e012489ef
V148
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
davidr99 | 0:ab4e012489ef | 1 | // RH_RF24.h |
davidr99 | 0:ab4e012489ef | 2 | // Author: Mike McCauley (mikem@airspayce.com) |
davidr99 | 0:ab4e012489ef | 3 | // Copyright (C) 2014 Mike McCauley |
davidr99 | 0:ab4e012489ef | 4 | // $Id: RH_RF24.h,v 1.13 2015/08/13 02:45:47 mikem Exp $ |
davidr99 | 0:ab4e012489ef | 5 | // |
davidr99 | 0:ab4e012489ef | 6 | // Supports RF24/RF26 and RFM24/RFM26 modules in FIFO mode |
davidr99 | 0:ab4e012489ef | 7 | // also Si4464/63/62/61/60-A1 |
davidr99 | 0:ab4e012489ef | 8 | // Si4063 is the same but Tx only |
davidr99 | 0:ab4e012489ef | 9 | // |
davidr99 | 0:ab4e012489ef | 10 | // Per http://www.hoperf.cn/upload/rf/RFM24.pdf |
davidr99 | 0:ab4e012489ef | 11 | // and http://www.hoperf.cn/upload/rf/RFM26.pdf |
davidr99 | 0:ab4e012489ef | 12 | // Sigh: the HopeRF documentation is utter rubbish: full of errors and incomplete. The Si446x docs are better: |
davidr99 | 0:ab4e012489ef | 13 | // http://www.silabs.com/Support%20Documents/TechnicalDocs/Si4464-63-61-60.pdf |
davidr99 | 0:ab4e012489ef | 14 | // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN626.pdf |
davidr99 | 0:ab4e012489ef | 15 | // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN627.pdf |
davidr99 | 0:ab4e012489ef | 16 | // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN647.pdf |
davidr99 | 0:ab4e012489ef | 17 | // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN633.pdf |
davidr99 | 0:ab4e012489ef | 18 | // http://www.silabs.com/Support%20Documents/TechnicalDocs/AN736.pdf |
davidr99 | 0:ab4e012489ef | 19 | // http://nicerf.com/manage/upfile/indexbanner/635231050196868750.pdf (API description) |
davidr99 | 0:ab4e012489ef | 20 | // http://www.silabs.com/Support%20Documents/Software/Si446x%20RX_HOP%20PLL%20Calculator.xlsx |
davidr99 | 0:ab4e012489ef | 21 | #ifndef RH_RF24_h |
davidr99 | 0:ab4e012489ef | 22 | #define RH_RF24_h |
davidr99 | 0:ab4e012489ef | 23 | |
davidr99 | 0:ab4e012489ef | 24 | #include <RHGenericSPI.h> |
davidr99 | 0:ab4e012489ef | 25 | #include <RHSPIDriver.h> |
davidr99 | 0:ab4e012489ef | 26 | |
davidr99 | 0:ab4e012489ef | 27 | // This is the maximum number of interrupts the driver can support |
davidr99 | 0:ab4e012489ef | 28 | // Most Arduinos can handle 2, Megas can handle more |
davidr99 | 0:ab4e012489ef | 29 | #define RH_RF24_NUM_INTERRUPTS 3 |
davidr99 | 0:ab4e012489ef | 30 | |
davidr99 | 0:ab4e012489ef | 31 | // Maximum payload length the RF24 can support, limited by our 1 octet message length |
davidr99 | 0:ab4e012489ef | 32 | #define RH_RF24_MAX_PAYLOAD_LEN 255 |
davidr99 | 0:ab4e012489ef | 33 | |
davidr99 | 0:ab4e012489ef | 34 | // The length of the headers we add. |
davidr99 | 0:ab4e012489ef | 35 | // The headers are inside the RF24's payload |
davidr99 | 0:ab4e012489ef | 36 | #define RH_RF24_HEADER_LEN 4 |
davidr99 | 0:ab4e012489ef | 37 | |
davidr99 | 0:ab4e012489ef | 38 | // This is the maximum message length that can be supported by this driver. |
davidr99 | 0:ab4e012489ef | 39 | // Can be pre-defined to a smaller size (to save SRAM) prior to including this header |
davidr99 | 0:ab4e012489ef | 40 | // Here we allow for message length 4 bytes of address and header and payload to be included in payload size limit. |
davidr99 | 0:ab4e012489ef | 41 | #ifndef RH_RF24_MAX_MESSAGE_LEN |
davidr99 | 0:ab4e012489ef | 42 | #define RH_RF24_MAX_MESSAGE_LEN (RH_RF24_MAX_PAYLOAD_LEN - RH_RF24_HEADER_LEN - 1) |
davidr99 | 0:ab4e012489ef | 43 | #endif |
davidr99 | 0:ab4e012489ef | 44 | |
davidr99 | 0:ab4e012489ef | 45 | // Max number of times we will try to read CTS from the radio |
davidr99 | 0:ab4e012489ef | 46 | #define RH_RF24_CTS_RETRIES 2500 |
davidr99 | 0:ab4e012489ef | 47 | |
davidr99 | 0:ab4e012489ef | 48 | // RF24/RF26 API commands from table 10 |
davidr99 | 0:ab4e012489ef | 49 | // also Si446X API DESCRIPTIONS table 1 |
davidr99 | 0:ab4e012489ef | 50 | #define RH_RF24_CMD_NOP 0x00 |
davidr99 | 0:ab4e012489ef | 51 | #define RH_RF24_CMD_PART_INFO 0x01 |
davidr99 | 0:ab4e012489ef | 52 | #define RH_RF24_CMD_POWER_UP 0x02 |
davidr99 | 0:ab4e012489ef | 53 | #define RH_RF24_CMD_PATCH_IMAGE 0x04 |
davidr99 | 0:ab4e012489ef | 54 | #define RH_RF24_CMD_FUNC_INFO 0x10 |
davidr99 | 0:ab4e012489ef | 55 | #define RH_RF24_CMD_SET_PROPERTY 0x11 |
davidr99 | 0:ab4e012489ef | 56 | #define RH_RF24_CMD_GET_PROPERTY 0x12 |
davidr99 | 0:ab4e012489ef | 57 | #define RH_RF24_CMD_GPIO_PIN_CFG 0x13 |
davidr99 | 0:ab4e012489ef | 58 | #define RH_RF24_CMD_GET_ADC_READING 0x14 |
davidr99 | 0:ab4e012489ef | 59 | #define RH_RF24_CMD_FIFO_INFO 0x15 |
davidr99 | 0:ab4e012489ef | 60 | #define RH_RF24_CMD_PACKET_INFO 0x16 |
davidr99 | 0:ab4e012489ef | 61 | #define RH_RF24_CMD_IRCAL 0x17 |
davidr99 | 0:ab4e012489ef | 62 | #define RH_RF24_CMD_PROTOCOL_CFG 0x18 |
davidr99 | 0:ab4e012489ef | 63 | #define RH_RF24_CMD_GET_INT_STATUS 0x20 |
davidr99 | 0:ab4e012489ef | 64 | #define RH_RF24_CMD_GET_PH_STATUS 0x21 |
davidr99 | 0:ab4e012489ef | 65 | #define RH_RF24_CMD_GET_MODEM_STATUS 0x22 |
davidr99 | 0:ab4e012489ef | 66 | #define RH_RF24_CMD_GET_CHIP_STATUS 0x23 |
davidr99 | 0:ab4e012489ef | 67 | #define RH_RF24_CMD_START_TX 0x31 |
davidr99 | 0:ab4e012489ef | 68 | #define RH_RF24_CMD_START_RX 0x32 |
davidr99 | 0:ab4e012489ef | 69 | #define RH_RF24_CMD_REQUEST_DEVICE_STATE 0x33 |
davidr99 | 0:ab4e012489ef | 70 | #define RH_RF24_CMD_CHANGE_STATE 0x34 |
davidr99 | 0:ab4e012489ef | 71 | #define RH_RF24_CMD_RX_HOP 0x36 |
davidr99 | 0:ab4e012489ef | 72 | #define RH_RF24_CMD_READ_BUF 0x44 |
davidr99 | 0:ab4e012489ef | 73 | #define RH_RF24_CMD_FAST_RESPONSE_A 0x50 |
davidr99 | 0:ab4e012489ef | 74 | #define RH_RF24_CMD_FAST_RESPONSE_B 0x51 |
davidr99 | 0:ab4e012489ef | 75 | #define RH_RF24_CMD_FAST_RESPONSE_C 0x53 |
davidr99 | 0:ab4e012489ef | 76 | #define RH_RF24_CMD_FAST_RESPONSE_D 0x57 |
davidr99 | 0:ab4e012489ef | 77 | #define RH_RF24_CMD_TX_FIFO_WRITE 0x66 |
davidr99 | 0:ab4e012489ef | 78 | #define RH_RF24_CMD_RX_FIFO_READ 0x77 |
davidr99 | 0:ab4e012489ef | 79 | |
davidr99 | 0:ab4e012489ef | 80 | // The Clear To Send signal from the radio |
davidr99 | 0:ab4e012489ef | 81 | #define RH_RF24_REPLY_CTS 0xff |
davidr99 | 0:ab4e012489ef | 82 | |
davidr99 | 0:ab4e012489ef | 83 | //#define RH_RF24_CMD_START_TX 0x31 |
davidr99 | 0:ab4e012489ef | 84 | #define RH_RF24_CONDITION_TX_COMPLETE_STATE 0xf0 |
davidr99 | 0:ab4e012489ef | 85 | #define RH_RF24_CONDITION_RETRANSMIT_NO 0x00 |
davidr99 | 0:ab4e012489ef | 86 | #define RH_RF24_CONDITION_RETRANSMIT_YES 0x04 |
davidr99 | 0:ab4e012489ef | 87 | #define RH_RF24_CONDITION_START_IMMEDIATE 0x00 |
davidr99 | 0:ab4e012489ef | 88 | #define RH_RF24_CONDITION_START_AFTER_WUT 0x01 |
davidr99 | 0:ab4e012489ef | 89 | |
davidr99 | 0:ab4e012489ef | 90 | //#define RH_RF24_CMD_START_RX 0x32 |
davidr99 | 0:ab4e012489ef | 91 | #define RH_RF24_CONDITION_RX_START_IMMEDIATE 0x00 |
davidr99 | 0:ab4e012489ef | 92 | |
davidr99 | 0:ab4e012489ef | 93 | //#define RH_RF24_CMD_REQUEST_DEVICE_STATE 0x33 |
davidr99 | 0:ab4e012489ef | 94 | #define RH_RF24_DEVICE_STATE_NO_CHANGE 0x00 |
davidr99 | 0:ab4e012489ef | 95 | #define RH_RF24_DEVICE_STATE_SLEEP 0x01 |
davidr99 | 0:ab4e012489ef | 96 | #define RH_RF24_DEVICE_STATE_SPI_ACTIVE 0x02 |
davidr99 | 0:ab4e012489ef | 97 | #define RH_RF24_DEVICE_STATE_READY 0x03 |
davidr99 | 0:ab4e012489ef | 98 | #define RH_RF24_DEVICE_STATE_ALSO_READY 0x04 |
davidr99 | 0:ab4e012489ef | 99 | #define RH_RF24_DEVICE_STATE_TUNE_TX 0x05 |
davidr99 | 0:ab4e012489ef | 100 | #define RH_RF24_DEVICE_STATE_TUNE_RX 0x06 |
davidr99 | 0:ab4e012489ef | 101 | #define RH_RF24_DEVICE_STATE_TX 0x07 |
davidr99 | 0:ab4e012489ef | 102 | #define RH_RF24_DEVICE_STATE_RX 0x08 |
davidr99 | 0:ab4e012489ef | 103 | |
davidr99 | 0:ab4e012489ef | 104 | // Properties for API Description AN625 Section 2.2 |
davidr99 | 0:ab4e012489ef | 105 | #define RH_RF24_PROPERTY_GLOBAL_XO_TUNE 0x0000 |
davidr99 | 0:ab4e012489ef | 106 | #define RH_RF24_PROPERTY_GLOBAL_CLK_CFG 0x0001 |
davidr99 | 0:ab4e012489ef | 107 | #define RH_RF24_PROPERTY_GLOBAL_LOW_BATT_THRESH 0x0002 |
davidr99 | 0:ab4e012489ef | 108 | #define RH_RF24_PROPERTY_GLOBAL_CONFIG 0x0003 |
davidr99 | 0:ab4e012489ef | 109 | #define RH_RF24_PROPERTY_GLOBAL_WUT_CONFIG 0x0004 |
davidr99 | 0:ab4e012489ef | 110 | #define RH_RF24_PROPERTY_GLOBAL_WUT_M_15_8 0x0005 |
davidr99 | 0:ab4e012489ef | 111 | #define RH_RF24_PROPERTY_GLOBAL_WUT_M_7_0 0x0006 |
davidr99 | 0:ab4e012489ef | 112 | #define RH_RF24_PROPERTY_GLOBAL_WUT_R 0x0007 |
davidr99 | 0:ab4e012489ef | 113 | #define RH_RF24_PROPERTY_GLOBAL_WUT_LDC 0x0008 |
davidr99 | 0:ab4e012489ef | 114 | #define RH_RF24_PROPERTY_INT_CTL_ENABLE 0x0100 |
davidr99 | 0:ab4e012489ef | 115 | #define RH_RF24_PROPERTY_INT_CTL_PH_ENABLE 0x0101 |
davidr99 | 0:ab4e012489ef | 116 | #define RH_RF24_PROPERTY_INT_CTL_MODEM_ENABLE 0x0102 |
davidr99 | 0:ab4e012489ef | 117 | #define RH_RF24_PROPERTY_INT_CTL_CHIP_ENABLE 0x0103 |
davidr99 | 0:ab4e012489ef | 118 | #define RH_RF24_PROPERTY_FRR_CTL_A_MODE 0x0200 |
davidr99 | 0:ab4e012489ef | 119 | #define RH_RF24_PROPERTY_FRR_CTL_B_MODE 0x0201 |
davidr99 | 0:ab4e012489ef | 120 | #define RH_RF24_PROPERTY_FRR_CTL_C_MODE 0x0202 |
davidr99 | 0:ab4e012489ef | 121 | #define RH_RF24_PROPERTY_FRR_CTL_D_MODE 0x0203 |
davidr99 | 0:ab4e012489ef | 122 | #define RH_RF24_PROPERTY_PREAMBLE_TX_LENGTH 0x1000 |
davidr99 | 0:ab4e012489ef | 123 | #define RH_RF24_PROPERTY_PREAMBLE_CONFIG_STD_1 0x1001 |
davidr99 | 0:ab4e012489ef | 124 | #define RH_RF24_PROPERTY_PREAMBLE_CONFIG_NSTD 0x1002 |
davidr99 | 0:ab4e012489ef | 125 | #define RH_RF24_PROPERTY_PREAMBLE_CONFIG_STD_2 0x1003 |
davidr99 | 0:ab4e012489ef | 126 | #define RH_RF24_PROPERTY_PREAMBLE_CONFIG 0x1004 |
davidr99 | 0:ab4e012489ef | 127 | #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_31_24 0x1005 |
davidr99 | 0:ab4e012489ef | 128 | #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_23_16 0x1006 |
davidr99 | 0:ab4e012489ef | 129 | #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_15_8 0x1007 |
davidr99 | 0:ab4e012489ef | 130 | #define RH_RF24_PROPERTY_PREAMBLE_PATTERN_7_0 0x1008 |
davidr99 | 0:ab4e012489ef | 131 | #define RH_RF24_PROPERTY_SYNC_CONFIG 0x1100 |
davidr99 | 0:ab4e012489ef | 132 | #define RH_RF24_PROPERTY_SYNC_BITS_31_24 0x1101 |
davidr99 | 0:ab4e012489ef | 133 | #define RH_RF24_PROPERTY_SYNC_BITS_23_16 0x1102 |
davidr99 | 0:ab4e012489ef | 134 | #define RH_RF24_PROPERTY_SYNC_BITS_15_8 0x1103 |
davidr99 | 0:ab4e012489ef | 135 | #define RH_RF24_PROPERTY_SYNC_BITS_7_0 0x1104 |
davidr99 | 0:ab4e012489ef | 136 | #define RH_RF24_PROPERTY_PKT_CRC_CONFIG 0x1200 |
davidr99 | 0:ab4e012489ef | 137 | #define RH_RF24_PROPERTY_PKT_CONFIG1 0x1206 |
davidr99 | 0:ab4e012489ef | 138 | #define RH_RF24_PROPERTY_PKT_LEN 0x1208 |
davidr99 | 0:ab4e012489ef | 139 | #define RH_RF24_PROPERTY_PKT_LEN_FIELD_SOURCE 0x1209 |
davidr99 | 0:ab4e012489ef | 140 | #define RH_RF24_PROPERTY_PKT_LEN_ADJUST 0x120a |
davidr99 | 0:ab4e012489ef | 141 | #define RH_RF24_PROPERTY_PKT_TX_THRESHOLD 0x120b |
davidr99 | 0:ab4e012489ef | 142 | #define RH_RF24_PROPERTY_PKT_RX_THRESHOLD 0x120c |
davidr99 | 0:ab4e012489ef | 143 | #define RH_RF24_PROPERTY_PKT_FIELD_1_LENGTH_12_8 0x120d |
davidr99 | 0:ab4e012489ef | 144 | #define RH_RF24_PROPERTY_PKT_FIELD_1_LENGTH_7_0 0x120e |
davidr99 | 0:ab4e012489ef | 145 | #define RH_RF24_PROPERTY_PKT_FIELD_1_CONFIG 0x120f |
davidr99 | 0:ab4e012489ef | 146 | #define RH_RF24_PROPERTY_PKT_FIELD_1_CRC_CONFIG 0x1210 |
davidr99 | 0:ab4e012489ef | 147 | #define RH_RF24_PROPERTY_PKT_FIELD_2_LENGTH_12_8 0x1211 |
davidr99 | 0:ab4e012489ef | 148 | #define RH_RF24_PROPERTY_PKT_FIELD_2_LENGTH_7_0 0x1212 |
davidr99 | 0:ab4e012489ef | 149 | #define RH_RF24_PROPERTY_PKT_FIELD_2_CONFIG 0x1213 |
davidr99 | 0:ab4e012489ef | 150 | #define RH_RF24_PROPERTY_PKT_FIELD_2_CRC_CONFIG 0x1214 |
davidr99 | 0:ab4e012489ef | 151 | #define RH_RF24_PROPERTY_PKT_FIELD_3_LENGTH_12_8 0x1215 |
davidr99 | 0:ab4e012489ef | 152 | #define RH_RF24_PROPERTY_PKT_FIELD_3_LENGTH_7_0 0x1216 |
davidr99 | 0:ab4e012489ef | 153 | #define RH_RF24_PROPERTY_PKT_FIELD_3_CONFIG 0x1217 |
davidr99 | 0:ab4e012489ef | 154 | #define RH_RF24_PROPERTY_PKT_FIELD_3_CRC_CONFIG 0x1218 |
davidr99 | 0:ab4e012489ef | 155 | #define RH_RF24_PROPERTY_PKT_FIELD_4_LENGTH_12_8 0x1219 |
davidr99 | 0:ab4e012489ef | 156 | #define RH_RF24_PROPERTY_PKT_FIELD_4_LENGTH_7_0 0x121a |
davidr99 | 0:ab4e012489ef | 157 | #define RH_RF24_PROPERTY_PKT_FIELD_4_CONFIG 0x121b |
davidr99 | 0:ab4e012489ef | 158 | #define RH_RF24_PROPERTY_PKT_FIELD_4_CRC_CONFIG 0x121c |
davidr99 | 0:ab4e012489ef | 159 | #define RH_RF24_PROPERTY_PKT_FIELD_5_LENGTH_12_8 0x121d |
davidr99 | 0:ab4e012489ef | 160 | #define RH_RF24_PROPERTY_PKT_FIELD_5_LENGTH_7_0 0x121e |
davidr99 | 0:ab4e012489ef | 161 | #define RH_RF24_PROPERTY_PKT_FIELD_5_CONFIG 0x121f |
davidr99 | 0:ab4e012489ef | 162 | #define RH_RF24_PROPERTY_PKT_FIELD_5_CRC_CONFIG 0x1220 |
davidr99 | 0:ab4e012489ef | 163 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_LENGTH_12_8 0x1221 |
davidr99 | 0:ab4e012489ef | 164 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_LENGTH_7_0 0x1222 |
davidr99 | 0:ab4e012489ef | 165 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_CONFIG 0x1223 |
davidr99 | 0:ab4e012489ef | 166 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_1_CRC_CONFIG 0x1224 |
davidr99 | 0:ab4e012489ef | 167 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_LENGTH_12_8 0x1225 |
davidr99 | 0:ab4e012489ef | 168 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_LENGTH_7_0 0x1226 |
davidr99 | 0:ab4e012489ef | 169 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_CONFIG 0x1227 |
davidr99 | 0:ab4e012489ef | 170 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_2_CRC_CONFIG 0x1228 |
davidr99 | 0:ab4e012489ef | 171 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_LENGTH_12_8 0x1229 |
davidr99 | 0:ab4e012489ef | 172 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_LENGTH_7_0 0x122a |
davidr99 | 0:ab4e012489ef | 173 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_CONFIG 0x122b |
davidr99 | 0:ab4e012489ef | 174 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_3_CRC_CONFIG 0x122c |
davidr99 | 0:ab4e012489ef | 175 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_LENGTH_12_8 0x122d |
davidr99 | 0:ab4e012489ef | 176 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_LENGTH_7_0 0x122e |
davidr99 | 0:ab4e012489ef | 177 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_CONFIG 0x122f |
davidr99 | 0:ab4e012489ef | 178 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_4_CRC_CONFIG 0x1230 |
davidr99 | 0:ab4e012489ef | 179 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_LENGTH_12_8 0x1231 |
davidr99 | 0:ab4e012489ef | 180 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_LENGTH_7_0 0x1232 |
davidr99 | 0:ab4e012489ef | 181 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_CONFIG 0x1233 |
davidr99 | 0:ab4e012489ef | 182 | #define RH_RF24_PROPERTY_PKT_RX_FIELD_5_CRC_CONFIG 0x1234 |
davidr99 | 0:ab4e012489ef | 183 | #define RH_RF24_PROPERTY_MODEM_MOD_TYPE 0x2000 |
davidr99 | 0:ab4e012489ef | 184 | #define RH_RF24_PROPERTY_MODEM_MAP_CONTROL 0x2001 |
davidr99 | 0:ab4e012489ef | 185 | #define RH_RF24_PROPERTY_MODEM_DSM_CTRL 0x2002 |
davidr99 | 0:ab4e012489ef | 186 | #define RH_RF24_PROPERTY_MODEM_DATA_RATE_2 0x2003 |
davidr99 | 0:ab4e012489ef | 187 | #define RH_RF24_PROPERTY_MODEM_DATA_RATE_1 0x2004 |
davidr99 | 0:ab4e012489ef | 188 | #define RH_RF24_PROPERTY_MODEM_DATA_RATE_0 0x2005 |
davidr99 | 0:ab4e012489ef | 189 | #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_3 0x2006 |
davidr99 | 0:ab4e012489ef | 190 | #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_2 0x2007 |
davidr99 | 0:ab4e012489ef | 191 | #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_1 0x2008 |
davidr99 | 0:ab4e012489ef | 192 | #define RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_0 0x2009 |
davidr99 | 0:ab4e012489ef | 193 | #define RH_RF24_PROPERTY_MODEM_FREQ_DEV_2 0x200a |
davidr99 | 0:ab4e012489ef | 194 | #define RH_RF24_PROPERTY_MODEM_FREQ_DEV_1 0x200b |
davidr99 | 0:ab4e012489ef | 195 | #define RH_RF24_PROPERTY_MODEM_FREQ_DEV_0 0x200c |
davidr99 | 0:ab4e012489ef | 196 | #define RH_RF24_PROPERTY_MODEM_TX_RAMP_DELAY 0x2018 |
davidr99 | 0:ab4e012489ef | 197 | #define RH_RF24_PROPERTY_MODEM_MDM_CTRL 0x2019 |
davidr99 | 0:ab4e012489ef | 198 | #define RH_RF24_PROPERTY_MODEM_IF_CONTROL 0x201a |
davidr99 | 0:ab4e012489ef | 199 | #define RH_RF24_PROPERTY_MODEM_IF_FREQ_2 0x201b |
davidr99 | 0:ab4e012489ef | 200 | #define RH_RF24_PROPERTY_MODEM_IF_FREQ_1 0x201c |
davidr99 | 0:ab4e012489ef | 201 | #define RH_RF24_PROPERTY_MODEM_IF_FREQ_0 0x201d |
davidr99 | 0:ab4e012489ef | 202 | #define RH_RF24_PROPERTY_MODEM_DECIMATION_CFG1 0x201e |
davidr99 | 0:ab4e012489ef | 203 | #define RH_RF24_PROPERTY_MODEM_DECIMATION_CFG0 0x201f |
davidr99 | 0:ab4e012489ef | 204 | #define RH_RF24_PROPERTY_MODEM_BCR_OSR_1 0x2022 |
davidr99 | 0:ab4e012489ef | 205 | #define RH_RF24_PROPERTY_MODEM_BCR_OSR_0 0x2023 |
davidr99 | 0:ab4e012489ef | 206 | #define RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_2 0x2024 |
davidr99 | 0:ab4e012489ef | 207 | #define RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_1 0x2025 |
davidr99 | 0:ab4e012489ef | 208 | #define RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_0 0x2026 |
davidr99 | 0:ab4e012489ef | 209 | #define RH_RF24_PROPERTY_MODEM_BCR_GAIN_1 0x2027 |
davidr99 | 0:ab4e012489ef | 210 | #define RH_RF24_PROPERTY_MODEM_BCR_GAIN_0 0x2028 |
davidr99 | 0:ab4e012489ef | 211 | #define RH_RF24_PROPERTY_MODEM_BCR_GEAR 0x2029 |
davidr99 | 0:ab4e012489ef | 212 | #define RH_RF24_PROPERTY_MODEM_BCR_MISC1 0x202a |
davidr99 | 0:ab4e012489ef | 213 | #define RH_RF24_PROPERTY_MODEM_AFC_GEAR 0x202c |
davidr99 | 0:ab4e012489ef | 214 | #define RH_RF24_PROPERTY_MODEM_AFC_WAIT 0x202d |
davidr99 | 0:ab4e012489ef | 215 | #define RH_RF24_PROPERTY_MODEM_AFC_GAIN_1 0x202e |
davidr99 | 0:ab4e012489ef | 216 | #define RH_RF24_PROPERTY_MODEM_AFC_GAIN_0 0x202f |
davidr99 | 0:ab4e012489ef | 217 | #define RH_RF24_PROPERTY_MODEM_AFC_LIMITER_1 0x2030 |
davidr99 | 0:ab4e012489ef | 218 | #define RH_RF24_PROPERTY_MODEM_AFC_LIMITER_0 0x2031 |
davidr99 | 0:ab4e012489ef | 219 | #define RH_RF24_PROPERTY_MODEM_AFC_MISC 0x2032 |
davidr99 | 0:ab4e012489ef | 220 | #define RH_RF24_PROPERTY_MODEM_AGC_CONTROL 0x2035 |
davidr99 | 0:ab4e012489ef | 221 | #define RH_RF24_PROPERTY_MODEM_AGC_WINDOW_SIZE 0x2038 |
davidr99 | 0:ab4e012489ef | 222 | #define RH_RF24_PROPERTY_MODEM_AGC_RFPD_DECAY 0x2039 |
davidr99 | 0:ab4e012489ef | 223 | #define RH_RF24_PROPERTY_MODEM_AGC_IFPD_DECAY 0x203a |
davidr99 | 0:ab4e012489ef | 224 | #define RH_RF24_PROPERTY_MODEM_FSK4_GAIN1 0x203b |
davidr99 | 0:ab4e012489ef | 225 | #define RH_RF24_PROPERTY_MODEM_FSK4_GAIN0 0x203c |
davidr99 | 0:ab4e012489ef | 226 | #define RH_RF24_PROPERTY_MODEM_FSK4_TH1 0x203d |
davidr99 | 0:ab4e012489ef | 227 | #define RH_RF24_PROPERTY_MODEM_FSK4_TH0 0x203e |
davidr99 | 0:ab4e012489ef | 228 | #define RH_RF24_PROPERTY_MODEM_FSK4_MAP 0x203f |
davidr99 | 0:ab4e012489ef | 229 | #define RH_RF24_PROPERTY_MODEM_OOK_PDTC 0x2040 |
davidr99 | 0:ab4e012489ef | 230 | #define RH_RF24_PROPERTY_MODEM_OOK_CNT1 0x2042 |
davidr99 | 0:ab4e012489ef | 231 | #define RH_RF24_PROPERTY_MODEM_OOK_MISC 0x2043 |
davidr99 | 0:ab4e012489ef | 232 | #define RH_RF24_PROPERTY_MODEM_RAW_SEARCH 0x2044 |
davidr99 | 0:ab4e012489ef | 233 | #define RH_RF24_PROPERTY_MODEM_RAW_CONTROL 0x2045 |
davidr99 | 0:ab4e012489ef | 234 | #define RH_RF24_PROPERTY_MODEM_RAW_EYE_1 0x2046 |
davidr99 | 0:ab4e012489ef | 235 | #define RH_RF24_PROPERTY_MODEM_RAW_EYE_0 0x2047 |
davidr99 | 0:ab4e012489ef | 236 | #define RH_RF24_PROPERTY_MODEM_ANT_DIV_MODE 0x2048 |
davidr99 | 0:ab4e012489ef | 237 | #define RH_RF24_PROPERTY_MODEM_ANT_DIV_CONTROL 0x2049 |
davidr99 | 0:ab4e012489ef | 238 | #define RH_RF24_PROPERTY_MODEM_RSSI_THRESH 0x204a |
davidr99 | 0:ab4e012489ef | 239 | #define RH_RF24_PROPERTY_MODEM_RSSI_JUMP_THRESH 0x204b |
davidr99 | 0:ab4e012489ef | 240 | #define RH_RF24_PROPERTY_MODEM_RSSI_CONTROL 0x204c |
davidr99 | 0:ab4e012489ef | 241 | #define RH_RF24_PROPERTY_MODEM_RSSI_CONTROL2 0x204d |
davidr99 | 0:ab4e012489ef | 242 | #define RH_RF24_PROPERTY_MODEM_RSSI_COMP 0x204e |
davidr99 | 0:ab4e012489ef | 243 | #define RH_RF24_PROPERTY_MODEM_ANT_DIV_CONT 0x2049 |
davidr99 | 0:ab4e012489ef | 244 | #define RH_RF24_PROPERTY_MODEM_CLKGEN_BAND 0x2051 |
davidr99 | 0:ab4e012489ef | 245 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE13_7_0 0x2100 |
davidr99 | 0:ab4e012489ef | 246 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE12_7_0 0x2101 |
davidr99 | 0:ab4e012489ef | 247 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE11_7_0 0x2102 |
davidr99 | 0:ab4e012489ef | 248 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE10_7_0 0x2103 |
davidr99 | 0:ab4e012489ef | 249 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE9_7_0 0x2104 |
davidr99 | 0:ab4e012489ef | 250 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE8_7_0 0x2105 |
davidr99 | 0:ab4e012489ef | 251 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE7_7_0 0x2106 |
davidr99 | 0:ab4e012489ef | 252 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE6_7_0 0x2107 |
davidr99 | 0:ab4e012489ef | 253 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE5_7_0 0x2108 |
davidr99 | 0:ab4e012489ef | 254 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE4_7_0 0x2109 |
davidr99 | 0:ab4e012489ef | 255 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE3_7_0 0x210a |
davidr99 | 0:ab4e012489ef | 256 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE2_7_0 0x210b |
davidr99 | 0:ab4e012489ef | 257 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE1_7_0 0x210c |
davidr99 | 0:ab4e012489ef | 258 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE0_7_0 0x210d |
davidr99 | 0:ab4e012489ef | 259 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM0 0x210e |
davidr99 | 0:ab4e012489ef | 260 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM1 0x210f |
davidr99 | 0:ab4e012489ef | 261 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM2 0x2110 |
davidr99 | 0:ab4e012489ef | 262 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM3 0x2111 |
davidr99 | 0:ab4e012489ef | 263 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE13_7_0 0x2112 |
davidr99 | 0:ab4e012489ef | 264 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE12_7_0 0x2113 |
davidr99 | 0:ab4e012489ef | 265 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE11_7_0 0x2114 |
davidr99 | 0:ab4e012489ef | 266 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE10_7_0 0x2115 |
davidr99 | 0:ab4e012489ef | 267 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE9_7_0 0x2116 |
davidr99 | 0:ab4e012489ef | 268 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE8_7_0 0x2117 |
davidr99 | 0:ab4e012489ef | 269 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE7_7_0 0x2118 |
davidr99 | 0:ab4e012489ef | 270 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE6_7_0 0x2119 |
davidr99 | 0:ab4e012489ef | 271 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE5_7_0 0x211a |
davidr99 | 0:ab4e012489ef | 272 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE4_7_0 0x211b |
davidr99 | 0:ab4e012489ef | 273 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE3_7_0 0x211c |
davidr99 | 0:ab4e012489ef | 274 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE2_7_0 0x211d |
davidr99 | 0:ab4e012489ef | 275 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE1_7_0 0x211e |
davidr99 | 0:ab4e012489ef | 276 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE0_7_0 0x211f |
davidr99 | 0:ab4e012489ef | 277 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM0 0x2120 |
davidr99 | 0:ab4e012489ef | 278 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM1 0x2121 |
davidr99 | 0:ab4e012489ef | 279 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM2 0x2122 |
davidr99 | 0:ab4e012489ef | 280 | #define RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM3 0x2123 |
davidr99 | 0:ab4e012489ef | 281 | #define RH_RF24_PROPERTY_PA_MODE 0x2200 |
davidr99 | 0:ab4e012489ef | 282 | #define RH_RF24_PROPERTY_PA_PWR_LVL 0x2201 |
davidr99 | 0:ab4e012489ef | 283 | #define RH_RF24_PROPERTY_PA_BIAS_CLKDUTY 0x2202 |
davidr99 | 0:ab4e012489ef | 284 | #define RH_RF24_PROPERTY_PA_TC 0x2203 |
davidr99 | 0:ab4e012489ef | 285 | #define RH_RF24_PROPERTY_SYNTH_PFDCP_CPFF 0x2300 |
davidr99 | 0:ab4e012489ef | 286 | #define RH_RF24_PROPERTY_SYNTH_PFDCP_CPINT 0x2301 |
davidr99 | 0:ab4e012489ef | 287 | #define RH_RF24_PROPERTY_SYNTH_VCO_KV 0x2302 |
davidr99 | 0:ab4e012489ef | 288 | #define RH_RF24_PROPERTY_SYNTH_LPFILT3 0x2303 |
davidr99 | 0:ab4e012489ef | 289 | #define RH_RF24_PROPERTY_SYNTH_LPFILT2 0x2304 |
davidr99 | 0:ab4e012489ef | 290 | #define RH_RF24_PROPERTY_SYNTH_LPFILT1 0x2305 |
davidr99 | 0:ab4e012489ef | 291 | #define RH_RF24_PROPERTY_SYNTH_LPFILT0 0x2306 |
davidr99 | 0:ab4e012489ef | 292 | #define RH_RF24_PROPERTY_MATCH_VALUE_1 0x3000 |
davidr99 | 0:ab4e012489ef | 293 | #define RH_RF24_PROPERTY_MATCH_MASK_1 0x3001 |
davidr99 | 0:ab4e012489ef | 294 | #define RH_RF24_PROPERTY_MATCH_CTRL_1 0x3002 |
davidr99 | 0:ab4e012489ef | 295 | #define RH_RF24_PROPERTY_MATCH_VALUE_2 0x3003 |
davidr99 | 0:ab4e012489ef | 296 | #define RH_RF24_PROPERTY_MATCH_MASK_2 0x3004 |
davidr99 | 0:ab4e012489ef | 297 | #define RH_RF24_PROPERTY_MATCH_CTRL_2 0x3005 |
davidr99 | 0:ab4e012489ef | 298 | #define RH_RF24_PROPERTY_MATCH_VALUE_3 0x3006 |
davidr99 | 0:ab4e012489ef | 299 | #define RH_RF24_PROPERTY_MATCH_MASK_3 0x3007 |
davidr99 | 0:ab4e012489ef | 300 | #define RH_RF24_PROPERTY_MATCH_CTRL_3 0x3008 |
davidr99 | 0:ab4e012489ef | 301 | #define RH_RF24_PROPERTY_MATCH_VALUE_4 0x3009 |
davidr99 | 0:ab4e012489ef | 302 | #define RH_RF24_PROPERTY_MATCH_MASK_4 0x300a |
davidr99 | 0:ab4e012489ef | 303 | #define RH_RF24_PROPERTY_MATCH_CTRL_4 0x300b |
davidr99 | 0:ab4e012489ef | 304 | #define RH_RF24_PROPERTY_FREQ_CONTROL_INTE 0x4000 |
davidr99 | 0:ab4e012489ef | 305 | #define RH_RF24_PROPERTY_FREQ_CONTROL_FRAC_2 0x4001 |
davidr99 | 0:ab4e012489ef | 306 | #define RH_RF24_PROPERTY_FREQ_CONTROL_FRAC_1 0x4002 |
davidr99 | 0:ab4e012489ef | 307 | #define RH_RF24_PROPERTY_FREQ_CONTROL_FRAC_0 0x4003 |
davidr99 | 0:ab4e012489ef | 308 | #define RH_RF24_PROPERTY_FREQ_CONTROL_CHANNEL_STEP_SIZE_1 0x4004 |
davidr99 | 0:ab4e012489ef | 309 | #define RH_RF24_PROPERTY_FREQ_CONTROL_CHANNEL_STEP_SIZE_0 0x4005 |
davidr99 | 0:ab4e012489ef | 310 | #define RH_RF24_PROPERTY_FREQ_CONTROL_VCOCNT_RX_ADJ 0x4007 |
davidr99 | 0:ab4e012489ef | 311 | #define RH_RF24_PROPERTY_RX_HOP_CONTROL 0x5000 |
davidr99 | 0:ab4e012489ef | 312 | #define RH_RF24_PROPERTY_RX_HOP_TABLE_SIZE 0x5001 |
davidr99 | 0:ab4e012489ef | 313 | #define RH_RF24_PROPERTY_RX_HOP_TABLE_ENTRY_0 0x5002 |
davidr99 | 0:ab4e012489ef | 314 | |
davidr99 | 0:ab4e012489ef | 315 | //#define RH_RF24_CMD_GPIO_PIN_CFG 0x13 |
davidr99 | 0:ab4e012489ef | 316 | #define RH_RF24_GPIO_NO_CHANGE 0 |
davidr99 | 0:ab4e012489ef | 317 | #define RH_RF24_GPIO_DISABLED 1 |
davidr99 | 0:ab4e012489ef | 318 | #define RH_RF24_GPIO_LOW 2 |
davidr99 | 0:ab4e012489ef | 319 | #define RH_RF24_GPIO_HIGH 3 |
davidr99 | 0:ab4e012489ef | 320 | #define RH_RF24_GPIO_INPUT 4 |
davidr99 | 0:ab4e012489ef | 321 | #define RH_RF24_GPIO_32_KHZ_CLOCK 5 |
davidr99 | 0:ab4e012489ef | 322 | #define RH_RF24_GPIO_BOOT_CLOCK 6 |
davidr99 | 0:ab4e012489ef | 323 | #define RH_RF24_GPIO_DIVIDED_MCU_CLOCK 7 |
davidr99 | 0:ab4e012489ef | 324 | #define RH_RF24_GPIO_CTS 8 |
davidr99 | 0:ab4e012489ef | 325 | #define RH_RF24_GPIO_INV_CTS 9 |
davidr99 | 0:ab4e012489ef | 326 | #define RH_RF24_GPIO_HIGH_ON_CMD_OVERLAP 10 |
davidr99 | 0:ab4e012489ef | 327 | #define RH_RF24_GPIO_SPI_DATA_OUT 11 |
davidr99 | 0:ab4e012489ef | 328 | #define RH_RF24_GPIO_HIGH_AFTER_RESET 12 |
davidr99 | 0:ab4e012489ef | 329 | #define RH_RF24_GPIO_HIGH_AFTER_CALIBRATION 13 |
davidr99 | 0:ab4e012489ef | 330 | #define RH_RF24_GPIO_HIGH_AFTER_WUT 14 |
davidr99 | 0:ab4e012489ef | 331 | #define RH_RF24_GPIO_UNUSED_0 15 |
davidr99 | 0:ab4e012489ef | 332 | #define RH_RF24_GPIO_TX_DATA_CLOCK 16 |
davidr99 | 0:ab4e012489ef | 333 | #define RH_RF24_GPIO_RX_DATA_CLOCK 17 |
davidr99 | 0:ab4e012489ef | 334 | #define RH_RF24_GPIO_UNUSED_1 18 |
davidr99 | 0:ab4e012489ef | 335 | #define RH_RF24_GPIO_TX_DATA 19 |
davidr99 | 0:ab4e012489ef | 336 | #define RH_RF24_GPIO_RX_DATA 20 |
davidr99 | 0:ab4e012489ef | 337 | #define RH_RF24_GPIO_RX_RAW_DATA 21 |
davidr99 | 0:ab4e012489ef | 338 | #define RH_RF24_GPIO_ANTENNA_1_SWITCH 22 |
davidr99 | 0:ab4e012489ef | 339 | #define RH_RF24_GPIO_ANTENNA_2_SWITCH 23 |
davidr99 | 0:ab4e012489ef | 340 | #define RH_RF24_GPIO_VALID_PREAMBLE 24 |
davidr99 | 0:ab4e012489ef | 341 | #define RH_RF24_GPIO_INVALID_PREAMBLE 25 |
davidr99 | 0:ab4e012489ef | 342 | #define RH_RF24_GPIO_SYNC_DETECTED 26 |
davidr99 | 0:ab4e012489ef | 343 | #define RH_RF24_GPIO_RSSI_ABOVE_CAT 27 |
davidr99 | 0:ab4e012489ef | 344 | #define RH_RF24_GPIO_TX_STATE 32 |
davidr99 | 0:ab4e012489ef | 345 | #define RH_RF24_GPIO_RX_STATE 33 |
davidr99 | 0:ab4e012489ef | 346 | #define RH_RF24_GPIO_RX_FIFO_ALMOST_FULL 34 |
davidr99 | 0:ab4e012489ef | 347 | #define RH_RF24_GPIO_TX_FIFO_ALMOST_EMPTY 35 |
davidr99 | 0:ab4e012489ef | 348 | #define RH_RF24_GPIO_BATT_LOW 36 |
davidr99 | 0:ab4e012489ef | 349 | #define RH_RF24_GPIO_RSSI_ABOVE_CAT_LOW 37 |
davidr99 | 0:ab4e012489ef | 350 | #define RH_RF24_GPIO_HOP 38 |
davidr99 | 0:ab4e012489ef | 351 | #define RH_RF24_GPIO_HOP_TABLE_WRAPPED 39 |
davidr99 | 0:ab4e012489ef | 352 | |
davidr99 | 0:ab4e012489ef | 353 | // #define RH_RF24_CMD_GET_INT_STATUS 0x20 |
davidr99 | 0:ab4e012489ef | 354 | #define RH_RF24_INT_STATUS_CHIP_INT_STATUS 0x04 |
davidr99 | 0:ab4e012489ef | 355 | #define RH_RF24_INT_STATUS_MODEM_INT_STATUS 0x02 |
davidr99 | 0:ab4e012489ef | 356 | #define RH_RF24_INT_STATUS_PH_INT_STATUS 0x01 |
davidr99 | 0:ab4e012489ef | 357 | #define RH_RF24_INT_STATUS_FILTER_MATCH 0x80 |
davidr99 | 0:ab4e012489ef | 358 | #define RH_RF24_INT_STATUS_FILTER_MISS 0x40 |
davidr99 | 0:ab4e012489ef | 359 | #define RH_RF24_INT_STATUS_PACKET_SENT 0x20 |
davidr99 | 0:ab4e012489ef | 360 | #define RH_RF24_INT_STATUS_PACKET_RX 0x10 |
davidr99 | 0:ab4e012489ef | 361 | #define RH_RF24_INT_STATUS_CRC_ERROR 0x08 |
davidr99 | 0:ab4e012489ef | 362 | #define RH_RF24_INT_STATUS_TX_FIFO_ALMOST_EMPTY 0x02 |
davidr99 | 0:ab4e012489ef | 363 | #define RH_RF24_INT_STATUS_RX_FIFO_ALMOST_FULL 0x01 |
davidr99 | 0:ab4e012489ef | 364 | #define RH_RF24_INT_STATUS_INVALID_SYNC 0x20 |
davidr99 | 0:ab4e012489ef | 365 | #define RH_RF24_INT_STATUS_RSSI_JUMP 0x10 |
davidr99 | 0:ab4e012489ef | 366 | #define RH_RF24_INT_STATUS_RSSI 0x08 |
davidr99 | 0:ab4e012489ef | 367 | #define RH_RF24_INT_STATUS_INVALID_PREAMBLE 0x04 |
davidr99 | 0:ab4e012489ef | 368 | #define RH_RF24_INT_STATUS_PREAMBLE_DETECT 0x02 |
davidr99 | 0:ab4e012489ef | 369 | #define RH_RF24_INT_STATUS_SYNC_DETECT 0x01 |
davidr99 | 0:ab4e012489ef | 370 | #define RH_RF24_INT_STATUS_CAL 0x40 |
davidr99 | 0:ab4e012489ef | 371 | #define RH_RF24_INT_STATUS_FIFO_UNDERFLOW_OVERFLOW_ERROR 0x20 |
davidr99 | 0:ab4e012489ef | 372 | #define RH_RF24_INT_STATUS_STATE_CHANGE 0x10 |
davidr99 | 0:ab4e012489ef | 373 | #define RH_RF24_INT_STATUS_CMD_ERROR 0x08 |
davidr99 | 0:ab4e012489ef | 374 | #define RH_RF24_INT_STATUS_CHIP_READY 0x04 |
davidr99 | 0:ab4e012489ef | 375 | #define RH_RF24_INT_STATUS_LOW_BATT 0x02 |
davidr99 | 0:ab4e012489ef | 376 | #define RH_RF24_INT_STATUS_WUT 0x01 |
davidr99 | 0:ab4e012489ef | 377 | |
davidr99 | 0:ab4e012489ef | 378 | //#define RH_RF24_PROPERTY_FRR_CTL_A_MODE 0x0200 |
davidr99 | 0:ab4e012489ef | 379 | //#define RH_RF24_PROPERTY_FRR_CTL_B_MODE 0x0201 |
davidr99 | 0:ab4e012489ef | 380 | //#define RH_RF24_PROPERTY_FRR_CTL_C_MODE 0x0202 |
davidr99 | 0:ab4e012489ef | 381 | //#define RH_RF24_PROPERTY_FRR_CTL_D_MODE 0x0203 |
davidr99 | 0:ab4e012489ef | 382 | #define RH_RF24_FRR_MODE_DISABLED 0 |
davidr99 | 0:ab4e012489ef | 383 | #define RH_RF24_FRR_MODE_GLOBAL_STATUS 1 |
davidr99 | 0:ab4e012489ef | 384 | #define RH_RF24_FRR_MODE_GLOBAL_INTERRUPT_PENDING 2 |
davidr99 | 0:ab4e012489ef | 385 | #define RH_RF24_FRR_MODE_PACKET_HANDLER_STATUS 3 |
davidr99 | 0:ab4e012489ef | 386 | #define RH_RF24_FRR_MODE_PACKET_HANDLER_INTERRUPT_PENDING 4 |
davidr99 | 0:ab4e012489ef | 387 | #define RH_RF24_FRR_MODE_MODEM_STATUS 5 |
davidr99 | 0:ab4e012489ef | 388 | #define RH_RF24_FRR_MODE_MODEM_INTERRUPT_PENDING 6 |
davidr99 | 0:ab4e012489ef | 389 | #define RH_RF24_FRR_MODE_CHIP_STATUS 7 |
davidr99 | 0:ab4e012489ef | 390 | #define RH_RF24_FRR_MODE_CHIP_INTERRUPT_PENDING 8 |
davidr99 | 0:ab4e012489ef | 391 | #define RH_RF24_FRR_MODE_CURRENT_STATE 9 |
davidr99 | 0:ab4e012489ef | 392 | #define RH_RF24_FRR_MODE_LATCHED_RSSI 10 |
davidr99 | 0:ab4e012489ef | 393 | |
davidr99 | 0:ab4e012489ef | 394 | //#define RH_RF24_PROPERTY_INT_CTL_ENABLE 0x0100 |
davidr99 | 0:ab4e012489ef | 395 | #define RH_RF24_CHIP_INT_STATUS_EN 0x04 |
davidr99 | 0:ab4e012489ef | 396 | #define RH_RF24_MODEM_INT_STATUS_EN 0x02 |
davidr99 | 0:ab4e012489ef | 397 | #define RH_RF24_PH_INT_STATUS_EN 0x01 |
davidr99 | 0:ab4e012489ef | 398 | |
davidr99 | 0:ab4e012489ef | 399 | //#define RH_RF24_PROPERTY_PREAMBLE_CONFIG 0x1004 |
davidr99 | 0:ab4e012489ef | 400 | #define RH_RF24_PREAMBLE_FIRST_1 0x20 |
davidr99 | 0:ab4e012489ef | 401 | #define RH_RF24_PREAMBLE_FIRST_0 0x00 |
davidr99 | 0:ab4e012489ef | 402 | #define RH_RF24_PREAMBLE_LENGTH_NIBBLES 0x00 |
davidr99 | 0:ab4e012489ef | 403 | #define RH_RF24_PREAMBLE_LENGTH_BYTES 0x10 |
davidr99 | 0:ab4e012489ef | 404 | #define RH_RF24_PREAMBLE_MAN_CONST 0x08 |
davidr99 | 0:ab4e012489ef | 405 | #define RH_RF24_PREAMBLE_MAN_ENABLE 0x02 |
davidr99 | 0:ab4e012489ef | 406 | #define RH_RF24_PREAMBLE_NON_STANDARD 0x00 |
davidr99 | 0:ab4e012489ef | 407 | #define RH_RF24_PREAMBLE_STANDARD_1010 0x01 |
davidr99 | 0:ab4e012489ef | 408 | #define RH_RF24_PREAMBLE_STANDARD_0101 0x02 |
davidr99 | 0:ab4e012489ef | 409 | |
davidr99 | 0:ab4e012489ef | 410 | //#define RH_RF24_PROPERTY_SYNC_CONFIG 0x1100 |
davidr99 | 0:ab4e012489ef | 411 | #define RH_RF24_SYNC_CONFIG_SKIP_TX 0x80 |
davidr99 | 0:ab4e012489ef | 412 | #define RH_RF24_SYNC_CONFIG_RX_ERRORS_MASK 0x70 |
davidr99 | 0:ab4e012489ef | 413 | #define RH_RF24_SYNC_CONFIG_4FSK 0x08 |
davidr99 | 0:ab4e012489ef | 414 | #define RH_RF24_SYNC_CONFIG_MANCH 0x04 |
davidr99 | 0:ab4e012489ef | 415 | #define RH_RF24_SYNC_CONFIG_LENGTH_MASK 0x03 |
davidr99 | 0:ab4e012489ef | 416 | |
davidr99 | 0:ab4e012489ef | 417 | //#define RH_RF24_PROPERTY_PKT_CRC_CONFIG 0x1200 |
davidr99 | 0:ab4e012489ef | 418 | #define RH_RF24_CRC_SEED_ALL_0S 0x00 |
davidr99 | 0:ab4e012489ef | 419 | #define RH_RF24_CRC_SEED_ALL_1S 0x80 |
davidr99 | 0:ab4e012489ef | 420 | #define RH_RF24_CRC_MASK 0x0f |
davidr99 | 0:ab4e012489ef | 421 | #define RH_RF24_CRC_NONE 0x00 |
davidr99 | 0:ab4e012489ef | 422 | #define RH_RF24_CRC_ITU_T 0x01 |
davidr99 | 0:ab4e012489ef | 423 | #define RH_RF24_CRC_IEC_16 0x02 |
davidr99 | 0:ab4e012489ef | 424 | #define RH_RF24_CRC_BIACHEVA 0x03 |
davidr99 | 0:ab4e012489ef | 425 | #define RH_RF24_CRC_16_IBM 0x04 |
davidr99 | 0:ab4e012489ef | 426 | #define RH_RF24_CRC_CCITT 0x05 |
davidr99 | 0:ab4e012489ef | 427 | #define RH_RF24_CRC_KOOPMAN 0x06 |
davidr99 | 0:ab4e012489ef | 428 | #define RH_RF24_CRC_IEEE_802_3 0x07 |
davidr99 | 0:ab4e012489ef | 429 | #define RH_RF24_CRC_CASTAGNOLI 0x08 |
davidr99 | 0:ab4e012489ef | 430 | |
davidr99 | 0:ab4e012489ef | 431 | //#define RH_RF24_PROPERTY_PKT_CONFIG1 0x1206 |
davidr99 | 0:ab4e012489ef | 432 | #define RH_RF24_PH_FIELD_SPLIT 0x80 |
davidr99 | 0:ab4e012489ef | 433 | #define RH_RF24_PH_RX_DISABLE 0x40 |
davidr99 | 0:ab4e012489ef | 434 | #define RH_RF24_4FSK_EN 0x20 |
davidr99 | 0:ab4e012489ef | 435 | #define RH_RF24_RX_MULTI_PKT 0x10 |
davidr99 | 0:ab4e012489ef | 436 | #define RH_RF24_MANCH_POL 0x08 |
davidr99 | 0:ab4e012489ef | 437 | #define RH_RF24_CRC_INVERT 0x04 |
davidr99 | 0:ab4e012489ef | 438 | #define RH_RF24_CRC_ENDIAN 0x02 |
davidr99 | 0:ab4e012489ef | 439 | #define RH_RF24_BIT_ORDER 0x01 |
davidr99 | 0:ab4e012489ef | 440 | |
davidr99 | 0:ab4e012489ef | 441 | //#define RH_RF24_PROPERTY_PKT_FIELD_1_CONFIG 0x120f |
davidr99 | 0:ab4e012489ef | 442 | //#define RH_RF24_PROPERTY_PKT_FIELD_2_CONFIG 0x1213 |
davidr99 | 0:ab4e012489ef | 443 | //#define RH_RF24_PROPERTY_PKT_FIELD_3_CONFIG 0x1217 |
davidr99 | 0:ab4e012489ef | 444 | //#define RH_RF24_PROPERTY_PKT_FIELD_4_CONFIG 0x121b |
davidr99 | 0:ab4e012489ef | 445 | //#define RH_RF24_PROPERTY_PKT_FIELD_5_CONFIG 0x121f |
davidr99 | 0:ab4e012489ef | 446 | #define RH_RF24_FIELD_CONFIG_4FSK 0x10 |
davidr99 | 0:ab4e012489ef | 447 | #define RH_RF24_FIELD_CONFIG_WHITEN 0x02 |
davidr99 | 0:ab4e012489ef | 448 | #define RH_RF24_FIELD_CONFIG_MANCH 0x01 |
davidr99 | 0:ab4e012489ef | 449 | |
davidr99 | 0:ab4e012489ef | 450 | //#define RH_RF24_PROPERTY_PKT_RX_FIELD_1_CRC_CONFIG 0x1224 |
davidr99 | 0:ab4e012489ef | 451 | //#define RH_RF24_PROPERTY_PKT_RX_FIELD_2_CRC_CONFIG 0x1228 |
davidr99 | 0:ab4e012489ef | 452 | //#define RH_RF24_PROPERTY_PKT_RX_FIELD_3_CRC_CONFIG 0x122c |
davidr99 | 0:ab4e012489ef | 453 | //#define RH_RF24_PROPERTY_PKT_RX_FIELD_4_CRC_CONFIG 0x1230 |
davidr99 | 0:ab4e012489ef | 454 | //#define RH_RF24_PROPERTY_PKT_RX_FIELD_5_CRC_CONFIG 0x1234 |
davidr99 | 0:ab4e012489ef | 455 | #define RH_RF24_FIELD_CONFIG_CRC_START 0x80 |
davidr99 | 0:ab4e012489ef | 456 | #define RH_RF24_FIELD_CONFIG_SEND_CRC 0x20 |
davidr99 | 0:ab4e012489ef | 457 | #define RH_RF24_FIELD_CONFIG_CHECK_CRC 0x08 |
davidr99 | 0:ab4e012489ef | 458 | #define RH_RF24_FIELD_CONFIG_CRC_ENABLE 0x02 |
davidr99 | 0:ab4e012489ef | 459 | |
davidr99 | 0:ab4e012489ef | 460 | |
davidr99 | 0:ab4e012489ef | 461 | |
davidr99 | 0:ab4e012489ef | 462 | |
davidr99 | 0:ab4e012489ef | 463 | //#define RH_RF24_PROPERTY_MODEM_MOD_TYPE 0x2000 |
davidr99 | 0:ab4e012489ef | 464 | #define RH_RF24_TX_DIRECT_MODE_TYPE_SYNCHRONOUS 0x00 |
davidr99 | 0:ab4e012489ef | 465 | #define RH_RF24_TX_DIRECT_MODE_TYPE_ASYNCHRONOUS 0x80 |
davidr99 | 0:ab4e012489ef | 466 | #define RH_RF24_TX_DIRECT_MODE_GPIO0 0x00 |
davidr99 | 0:ab4e012489ef | 467 | #define RH_RF24_TX_DIRECT_MODE_GPIO1 0x20 |
davidr99 | 0:ab4e012489ef | 468 | #define RH_RF24_TX_DIRECT_MODE_GPIO2 0x40 |
davidr99 | 0:ab4e012489ef | 469 | #define RH_RF24_TX_DIRECT_MODE_GPIO3 0x60 |
davidr99 | 0:ab4e012489ef | 470 | #define RH_RF24_MOD_SOURCE_PACKET_HANDLER 0x00 |
davidr99 | 0:ab4e012489ef | 471 | #define RH_RF24_MOD_SOURCE_DIRECT_MODE 0x08 |
davidr99 | 0:ab4e012489ef | 472 | #define RH_RF24_MOD_SOURCE_RANDOM_GENERATOR 0x10 |
davidr99 | 0:ab4e012489ef | 473 | #define RH_RF24_MOD_TYPE_CW 0x00 |
davidr99 | 0:ab4e012489ef | 474 | #define RH_RF24_MOD_TYPE_OOK 0x01 |
davidr99 | 0:ab4e012489ef | 475 | #define RH_RF24_MOD_TYPE_2FSK 0x02 |
davidr99 | 0:ab4e012489ef | 476 | #define RH_RF24_MOD_TYPE_2GFSK 0x03 |
davidr99 | 0:ab4e012489ef | 477 | #define RH_RF24_MOD_TYPE_4FSK 0x04 |
davidr99 | 0:ab4e012489ef | 478 | #define RH_RF24_MOD_TYPE_4GFSK 0x05 |
davidr99 | 0:ab4e012489ef | 479 | |
davidr99 | 0:ab4e012489ef | 480 | // RH_RF24_PROPERTY_PA_MODE 0x2200 |
davidr99 | 0:ab4e012489ef | 481 | #define RH_RF24_PA_MODE_1_GROUP 0x04 |
davidr99 | 0:ab4e012489ef | 482 | #define RH_RF24_PA_MODE_2_GROUPS 0x08 |
davidr99 | 0:ab4e012489ef | 483 | #define RH_RF24_PA_MODE_CLASS_E 0x00 |
davidr99 | 0:ab4e012489ef | 484 | #define RH_RF24_PA_MODE_SWITCH_CURRENT 0x01 |
davidr99 | 0:ab4e012489ef | 485 | |
davidr99 | 0:ab4e012489ef | 486 | |
davidr99 | 0:ab4e012489ef | 487 | ///////////////////////////////////////////////////////////////////// |
davidr99 | 0:ab4e012489ef | 488 | /// \class RH_RF24 RH_RF24.h <RH_RF24.h> |
davidr99 | 0:ab4e012489ef | 489 | /// \brief Driver to send and receive unaddressed, unreliable datagrams via an RF24 and compatible radio transceiver. |
davidr99 | 0:ab4e012489ef | 490 | /// |
davidr99 | 0:ab4e012489ef | 491 | /// Works with |
davidr99 | 0:ab4e012489ef | 492 | /// - Silicon Labs Si4460/1/2/3/4 transceiver chips |
davidr99 | 0:ab4e012489ef | 493 | /// - The equivalent HopeRF RF24/25/26/27 transceiver chips |
davidr99 | 0:ab4e012489ef | 494 | /// - HopeRF Complete modules: RFM24W/26W/27W |
davidr99 | 0:ab4e012489ef | 495 | /// |
davidr99 | 0:ab4e012489ef | 496 | /// \par Overview |
davidr99 | 0:ab4e012489ef | 497 | /// |
davidr99 | 0:ab4e012489ef | 498 | /// This class provides basic functions for sending and receiving unaddressed, |
davidr99 | 0:ab4e012489ef | 499 | /// unreliable datagrams of arbitrary length to 250 octets per packet. |
davidr99 | 0:ab4e012489ef | 500 | /// |
davidr99 | 0:ab4e012489ef | 501 | /// Manager classes may use this class to implement reliable, addressed datagrams and streams, |
davidr99 | 0:ab4e012489ef | 502 | /// mesh routers, repeaters, translators etc. |
davidr99 | 0:ab4e012489ef | 503 | /// |
davidr99 | 0:ab4e012489ef | 504 | /// Naturally, for any 2 radios to communicate that must be configured to use the same frequency and |
davidr99 | 0:ab4e012489ef | 505 | /// modulation scheme. |
davidr99 | 0:ab4e012489ef | 506 | /// |
davidr99 | 0:ab4e012489ef | 507 | /// This Driver provides an object-oriented interface for sending and receiving data messages with Hope-RF |
davidr99 | 0:ab4e012489ef | 508 | /// RF24 and compatible radio modules, such as the RFM24W module. |
davidr99 | 0:ab4e012489ef | 509 | /// |
davidr99 | 0:ab4e012489ef | 510 | /// The Hope-RF (http://www.hoperf.com) RF24 family is a low-cost ISM transceiver |
davidr99 | 0:ab4e012489ef | 511 | /// chip. It supports FSK, GFSK, OOK over a wide range of frequencies and |
davidr99 | 0:ab4e012489ef | 512 | /// programmable data rates. HopeRF also sell these chips on modules which includes |
davidr99 | 0:ab4e012489ef | 513 | /// a crystal and antenna coupling circuits: RFM24W, RFM26W and RFM27W |
davidr99 | 0:ab4e012489ef | 514 | /// |
davidr99 | 0:ab4e012489ef | 515 | /// This Driver provides functions for sending and receiving messages of up |
davidr99 | 0:ab4e012489ef | 516 | /// to 250 octets on any frequency supported by the RF24, in a range of |
davidr99 | 0:ab4e012489ef | 517 | /// predefined data rates and frequency deviations. Frequency can be set |
davidr99 | 0:ab4e012489ef | 518 | /// to any frequency from 142.0MHz to 1050.0MHz. Caution: most modules only support a more limited |
davidr99 | 0:ab4e012489ef | 519 | /// range of frequencies due to antenna tuning. |
davidr99 | 0:ab4e012489ef | 520 | /// |
davidr99 | 0:ab4e012489ef | 521 | /// Up to 2 RFM24 modules can be connected to an Arduino (3 on a Mega), |
davidr99 | 0:ab4e012489ef | 522 | /// permitting the construction of translators and frequency changers, etc. |
davidr99 | 0:ab4e012489ef | 523 | /// |
davidr99 | 0:ab4e012489ef | 524 | /// The following modulation types are suppported with a range of modem configurations for |
davidr99 | 0:ab4e012489ef | 525 | /// common data rates and frequency deviations: |
davidr99 | 0:ab4e012489ef | 526 | /// - OOK On-Off Keying |
davidr99 | 0:ab4e012489ef | 527 | /// - GFSK Gaussian Frequency Shift Keying |
davidr99 | 0:ab4e012489ef | 528 | /// - FSK Frequency Shift Keying |
davidr99 | 0:ab4e012489ef | 529 | /// |
davidr99 | 0:ab4e012489ef | 530 | /// Support for other RF24 features such as on-chip temperature measurement, |
davidr99 | 0:ab4e012489ef | 531 | /// transmitter power control etc is also provided. |
davidr99 | 0:ab4e012489ef | 532 | /// |
davidr99 | 0:ab4e012489ef | 533 | /// RH_RF24 uses interrupts to detect and handle events in the radio chip. The RF24 family has |
davidr99 | 0:ab4e012489ef | 534 | /// TX and RX FIFOs of 64 bytes, but through the use of interrupt, the RH_RF24 driver can send longer |
davidr99 | 0:ab4e012489ef | 535 | /// messages by filling or emptying the FIFOs on-the-fly. |
davidr99 | 0:ab4e012489ef | 536 | /// |
davidr99 | 0:ab4e012489ef | 537 | /// Tested on Anarduino Mini http://www.anarduino.com/mini/ with arduino-1.0.5 |
davidr99 | 0:ab4e012489ef | 538 | /// on OpenSuSE 13.1 |
davidr99 | 0:ab4e012489ef | 539 | /// |
davidr99 | 0:ab4e012489ef | 540 | /// \par Packet Format |
davidr99 | 0:ab4e012489ef | 541 | /// |
davidr99 | 0:ab4e012489ef | 542 | /// All messages sent and received by this RH_RF24 Driver conform to this packet format: |
davidr99 | 0:ab4e012489ef | 543 | /// |
davidr99 | 0:ab4e012489ef | 544 | /// - 4 octets PREAMBLE (configurable) |
davidr99 | 0:ab4e012489ef | 545 | /// - 2 octets SYNC 0x2d, 0xd4 (configurable, so you can use this as a network filter) |
davidr99 | 0:ab4e012489ef | 546 | /// - Field containing 1 octet of message length and 2 octet CRC protecting this field |
davidr99 | 0:ab4e012489ef | 547 | /// - Field 2 containing at least 4 octets, and 2 octet CRC protecting this field: |
davidr99 | 0:ab4e012489ef | 548 | /// + 4 octets HEADER: (TO, FROM, ID, FLAGS) |
davidr99 | 0:ab4e012489ef | 549 | /// + 0 to 250 octets DATA |
davidr99 | 0:ab4e012489ef | 550 | /// + 2 octets CRC, computed on HEADER and DATA |
davidr99 | 0:ab4e012489ef | 551 | /// |
davidr99 | 0:ab4e012489ef | 552 | /// \par Connecting RFM-24 to Arduino |
davidr99 | 0:ab4e012489ef | 553 | /// |
davidr99 | 0:ab4e012489ef | 554 | /// For RFM24/RFM26 and Teensy 3.1 or Anarduino Mini |
davidr99 | 0:ab4e012489ef | 555 | /// \code |
davidr99 | 0:ab4e012489ef | 556 | /// Teensy RFM-24/RFM26 |
davidr99 | 0:ab4e012489ef | 557 | /// GND----------GND (ground in) |
davidr99 | 0:ab4e012489ef | 558 | /// 3V3----------VCC (3.3V in) |
davidr99 | 0:ab4e012489ef | 559 | /// interrupt 2 pin D2-----------NIRQ (interrupt request out) |
davidr99 | 0:ab4e012489ef | 560 | /// SS pin D10----------NSEL (chip select in) |
davidr99 | 0:ab4e012489ef | 561 | /// SCK pin D13----------SCK (SPI clock in) |
davidr99 | 0:ab4e012489ef | 562 | /// MOSI pin D11----------SDI (SPI Data in) |
davidr99 | 0:ab4e012489ef | 563 | /// MISO pin D12----------SDO (SPI data out) |
davidr99 | 0:ab4e012489ef | 564 | /// D9-----------SDN (shutdown in) |
davidr99 | 0:ab4e012489ef | 565 | /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT) |
davidr99 | 0:ab4e012489ef | 566 | /// \--TX_ANT (TX antenna control in) RFM22B only |
davidr99 | 0:ab4e012489ef | 567 | /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT) |
davidr99 | 0:ab4e012489ef | 568 | /// \--RX_ANT (RX antenna control in) RFM22B only |
davidr99 | 0:ab4e012489ef | 569 | /// \endcode |
davidr99 | 0:ab4e012489ef | 570 | /// Caution: tying the radio SDN pin to ground (though it might appear from the data sheets to make sense) |
davidr99 | 0:ab4e012489ef | 571 | /// does not always produce a reliable radio startup. So this driver controls the SDN pin directly. |
davidr99 | 0:ab4e012489ef | 572 | /// Note: the GPIO0-TX_ANT and GPIO1-RX_ANT connections are not required for the 11dBm RFM24W, |
davidr99 | 0:ab4e012489ef | 573 | /// which has no antenna switch. |
davidr99 | 0:ab4e012489ef | 574 | /// |
davidr99 | 0:ab4e012489ef | 575 | /// \par Customising |
davidr99 | 0:ab4e012489ef | 576 | /// |
davidr99 | 0:ab4e012489ef | 577 | /// The library will work out of the box with the provided examples, over the full frequency range and with |
davidr99 | 0:ab4e012489ef | 578 | /// a wide range of predefined modem configurations schemes and speeds. However, you may want to |
davidr99 | 0:ab4e012489ef | 579 | /// change the default behaviour of this library. There are several ways you can do this: |
davidr99 | 0:ab4e012489ef | 580 | /// |
davidr99 | 0:ab4e012489ef | 581 | /// - Use the RH_RF24 API based on this documentation |
davidr99 | 0:ab4e012489ef | 582 | /// - Create your own ModemConfig and pass it to setModemreeegisters() |
davidr99 | 0:ab4e012489ef | 583 | /// - Generate a new radio_config_Si4460.h using the Silicon Labs WDS software package |
davidr99 | 0:ab4e012489ef | 584 | /// - Write directly to the radio registers and properties using command() and set_properties() |
davidr99 | 0:ab4e012489ef | 585 | /// |
davidr99 | 0:ab4e012489ef | 586 | /// \par RSSI |
davidr99 | 0:ab4e012489ef | 587 | /// |
davidr99 | 0:ab4e012489ef | 588 | /// The RSSI (Received Signal Strength Indicator) is measured and latched after the message sync bytes are received. |
davidr99 | 0:ab4e012489ef | 589 | /// The latched RSSI is available from the lastRssi() member functionafter the complete message is received. |
davidr99 | 0:ab4e012489ef | 590 | /// Although lastRssi() |
davidr99 | 0:ab4e012489ef | 591 | /// supposedly returns a signed integer, in the case of this radio it actually returns an unsigned 8 bit integer (uint8_t) |
davidr99 | 0:ab4e012489ef | 592 | /// and you will have to cast the return value to use it: |
davidr99 | 0:ab4e012489ef | 593 | /// \code |
davidr99 | 0:ab4e012489ef | 594 | /// uint8_t lastRssi = (uint8_t)rf24.lastRssi(); |
davidr99 | 0:ab4e012489ef | 595 | /// \endcode |
davidr99 | 0:ab4e012489ef | 596 | /// The units of RSSI are arbitrary and relative, with larger unsigned numbers indicating a stronger signal. Values up to 255 |
davidr99 | 0:ab4e012489ef | 597 | /// are seen with radios in close proximity to each other. Lower limit of receivable strength is about 70. |
davidr99 | 0:ab4e012489ef | 598 | /// |
davidr99 | 0:ab4e012489ef | 599 | /// \par Transmitter Power |
davidr99 | 0:ab4e012489ef | 600 | /// |
davidr99 | 0:ab4e012489ef | 601 | /// You can control the transmitter power on the RF24/25/26/27 transceiver |
davidr99 | 0:ab4e012489ef | 602 | /// with the RH_RF24::setTxPower() function. The argument can be any of |
davidr99 | 0:ab4e012489ef | 603 | /// 0x00 to 0x4f (for RFM24/Si4460) or |
davidr99 | 0:ab4e012489ef | 604 | /// 0x00 to 0x7f (for others) |
davidr99 | 0:ab4e012489ef | 605 | /// 0x00 will yield no measurable power. For other settings there is a non-linear correlation with actual |
davidr99 | 0:ab4e012489ef | 606 | /// RF power output (see below) |
davidr99 | 0:ab4e012489ef | 607 | /// The default is 0x10. Eg: |
davidr99 | 0:ab4e012489ef | 608 | /// \code |
davidr99 | 0:ab4e012489ef | 609 | /// driver.setTxPower(0x10); |
davidr99 | 0:ab4e012489ef | 610 | /// \endcode |
davidr99 | 0:ab4e012489ef | 611 | /// |
davidr99 | 0:ab4e012489ef | 612 | /// We have made some actual power measurements against |
davidr99 | 0:ab4e012489ef | 613 | /// programmed power |
davidr99 | 0:ab4e012489ef | 614 | /// - Anarduino Mini with RFM24-433 and RFM26-433 at Vcc = 3.3V, in CW mode, 434MHz |
davidr99 | 0:ab4e012489ef | 615 | /// - 10cm RG58C/U soldered direct to RFM69 module ANT and GND |
davidr99 | 0:ab4e012489ef | 616 | /// - bnc connecteor |
davidr99 | 0:ab4e012489ef | 617 | /// - 12dB attenuator |
davidr99 | 0:ab4e012489ef | 618 | /// - BNC-SMA adapter |
davidr99 | 0:ab4e012489ef | 619 | /// - MiniKits AD8307 HF/VHF Power Head (calibrated against Rohde&Schwartz 806.2020 test set) |
davidr99 | 0:ab4e012489ef | 620 | /// - Digitech QM-1460 digital multimeter |
davidr99 | 0:ab4e012489ef | 621 | /// \code |
davidr99 | 0:ab4e012489ef | 622 | /// Program power Measured Power dBm |
davidr99 | 0:ab4e012489ef | 623 | /// HEX RFM24 RFM26 |
davidr99 | 0:ab4e012489ef | 624 | /// 0x00 not measurable not measurable |
davidr99 | 0:ab4e012489ef | 625 | /// 0x01 -20.4 -20.6 |
davidr99 | 0:ab4e012489ef | 626 | /// 0x0f 2.4 4.8 |
davidr99 | 0:ab4e012489ef | 627 | /// 0x1f 9.4 11.0 |
davidr99 | 0:ab4e012489ef | 628 | /// 0x2f 11.2 14.2 |
davidr99 | 0:ab4e012489ef | 629 | /// 0x3f 11.6 16.4 |
davidr99 | 0:ab4e012489ef | 630 | /// 0x4f 11.6 18.0 |
davidr99 | 0:ab4e012489ef | 631 | /// 0x5f 18.6 |
davidr99 | 0:ab4e012489ef | 632 | /// 0x6f 19.0 |
davidr99 | 0:ab4e012489ef | 633 | /// 0x7f 19.2 |
davidr99 | 0:ab4e012489ef | 634 | /// \endcode |
davidr99 | 0:ab4e012489ef | 635 | /// Caution: the actual radiated power output will depend heavily on the power supply voltage and the antenna. |
davidr99 | 0:ab4e012489ef | 636 | |
davidr99 | 0:ab4e012489ef | 637 | class RH_RF24 : public RHSPIDriver |
davidr99 | 0:ab4e012489ef | 638 | { |
davidr99 | 0:ab4e012489ef | 639 | public: |
davidr99 | 0:ab4e012489ef | 640 | /// \brief Defines property values for a set of modem configuration registers |
davidr99 | 0:ab4e012489ef | 641 | /// |
davidr99 | 0:ab4e012489ef | 642 | /// Defines property values for a set of modem configuration registers |
davidr99 | 0:ab4e012489ef | 643 | /// that can be passed to setModemRegisters() if none of the choices in |
davidr99 | 0:ab4e012489ef | 644 | /// ModemConfigChoice suit your need setModemRegisters() writes the |
davidr99 | 0:ab4e012489ef | 645 | /// property values from this structure to the appropriate RF24 properties |
davidr99 | 0:ab4e012489ef | 646 | /// to set the desired modulation type, data rate and deviation/bandwidth. |
davidr99 | 0:ab4e012489ef | 647 | typedef struct |
davidr99 | 0:ab4e012489ef | 648 | { |
davidr99 | 0:ab4e012489ef | 649 | uint8_t prop_2000; ///< Value for property RH_RF24_PROPERTY_MODEM_MOD_TYPE |
davidr99 | 0:ab4e012489ef | 650 | uint8_t prop_2003; ///< Value for property RH_RF24_PROPERTY_MODEM_DATA_RATE_2 |
davidr99 | 0:ab4e012489ef | 651 | uint8_t prop_2004; ///< Value for property RH_RF24_PROPERTY_MODEM_DATA_RATE_1 |
davidr99 | 0:ab4e012489ef | 652 | uint8_t prop_2005; ///< Value for property RH_RF24_PROPERTY_MODEM_DATA_RATE_0 |
davidr99 | 0:ab4e012489ef | 653 | uint8_t prop_2006; ///< Value for property RH_RF24_PROPERTY_MODEM_TX_NCO_MODE_3 |
davidr99 | 0:ab4e012489ef | 654 | uint8_t prop_200a; ///< Value for property RH_RF24_PROPERTY_MODEM_FREQ_DEV_2 |
davidr99 | 0:ab4e012489ef | 655 | uint8_t prop_200b; ///< Value for property RH_RF24_PROPERTY_MODEM_FREQ_DEV_1 |
davidr99 | 0:ab4e012489ef | 656 | uint8_t prop_200c; ///< Value for property RH_RF24_PROPERTY_MODEM_FREQ_DEV_0 |
davidr99 | 0:ab4e012489ef | 657 | uint8_t prop_2018; ///< Value for property RH_RF24_PROPERTY_MODEM_TX_RAMP_DELAY |
davidr99 | 0:ab4e012489ef | 658 | uint8_t prop_201e; ///< Value for property RH_RF24_PROPERTY_MODEM_DECIMATION_CFG1 |
davidr99 | 0:ab4e012489ef | 659 | uint8_t prop_201f; ///< Value for property RH_RF24_PROPERTY_MODEM_DECIMATION_CFG0 |
davidr99 | 0:ab4e012489ef | 660 | uint8_t prop_2022; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_OSR_1 |
davidr99 | 0:ab4e012489ef | 661 | uint8_t prop_2023; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_OSR_0 |
davidr99 | 0:ab4e012489ef | 662 | uint8_t prop_2024; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_2 |
davidr99 | 0:ab4e012489ef | 663 | uint8_t prop_2025; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_1 |
davidr99 | 0:ab4e012489ef | 664 | uint8_t prop_2026; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_NCO_OFFSET_0 |
davidr99 | 0:ab4e012489ef | 665 | uint8_t prop_2027; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_GAIN_1 |
davidr99 | 0:ab4e012489ef | 666 | uint8_t prop_2028; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_GAIN_0 |
davidr99 | 0:ab4e012489ef | 667 | uint8_t prop_2029; ///< Value for property RH_RF24_PROPERTY_MODEM_BCR_GEAR |
davidr99 | 0:ab4e012489ef | 668 | uint8_t prop_202d; ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_WAIT |
davidr99 | 0:ab4e012489ef | 669 | uint8_t prop_202e; ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_GAIN_1 |
davidr99 | 0:ab4e012489ef | 670 | uint8_t prop_202f; ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_GAIN_0 |
davidr99 | 0:ab4e012489ef | 671 | uint8_t prop_2030; ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_LIMITER_1 |
davidr99 | 0:ab4e012489ef | 672 | uint8_t prop_2031; ///< Value for property RH_RF24_PROPERTY_MODEM_AFC_LIMITER_0 |
davidr99 | 0:ab4e012489ef | 673 | uint8_t prop_2035; ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_CONTROL |
davidr99 | 0:ab4e012489ef | 674 | uint8_t prop_2038; ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_WINDOW_SIZE |
davidr99 | 0:ab4e012489ef | 675 | uint8_t prop_2039; ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_RFPD_DECAY |
davidr99 | 0:ab4e012489ef | 676 | uint8_t prop_203a; ///< Value for property RH_RF24_PROPERTY_MODEM_AGC_IFPD_DECAY |
davidr99 | 0:ab4e012489ef | 677 | uint8_t prop_203b; ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_GAIN1 |
davidr99 | 0:ab4e012489ef | 678 | uint8_t prop_203c; ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_GAIN0 |
davidr99 | 0:ab4e012489ef | 679 | uint8_t prop_203d; ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_TH1 |
davidr99 | 0:ab4e012489ef | 680 | uint8_t prop_203e; ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_TH0 |
davidr99 | 0:ab4e012489ef | 681 | uint8_t prop_203f; ///< Value for property RH_RF24_PROPERTY_MODEM_FSK4_MAP |
davidr99 | 0:ab4e012489ef | 682 | uint8_t prop_2040; ///< Value for property RH_RF24_PROPERTY_MODEM_OOK_PDTC |
davidr99 | 0:ab4e012489ef | 683 | uint8_t prop_2043; ///< Value for property RH_RF24_PROPERTY_MODEM_OOK_MISC |
davidr99 | 0:ab4e012489ef | 684 | uint8_t prop_2045; ///< Value for property RH_RF24_PROPERTY_MODEM_RAW_CONTROL |
davidr99 | 0:ab4e012489ef | 685 | uint8_t prop_2046; ///< Value for property RH_RF24_PROPERTY_MODEM_RAW_EYE_1 |
davidr99 | 0:ab4e012489ef | 686 | uint8_t prop_2047; ///< Value for property RH_RF24_PROPERTY_MODEM_RAW_EYE_0 |
davidr99 | 0:ab4e012489ef | 687 | uint8_t prop_204e; ///< Value for property RH_RF24_PROPERTY_MODEM_RSSI_COMP |
davidr99 | 0:ab4e012489ef | 688 | uint8_t prop_2100; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE13_7_0 |
davidr99 | 0:ab4e012489ef | 689 | uint8_t prop_2101; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE12_7_0 |
davidr99 | 0:ab4e012489ef | 690 | uint8_t prop_2102; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE11_7_0 |
davidr99 | 0:ab4e012489ef | 691 | uint8_t prop_2103; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE10_7_0 |
davidr99 | 0:ab4e012489ef | 692 | uint8_t prop_2104; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE9_7_0 |
davidr99 | 0:ab4e012489ef | 693 | uint8_t prop_2105; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE8_7_0 |
davidr99 | 0:ab4e012489ef | 694 | uint8_t prop_2106; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE7_7_0 |
davidr99 | 0:ab4e012489ef | 695 | uint8_t prop_2107; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE6_7_0 |
davidr99 | 0:ab4e012489ef | 696 | uint8_t prop_2108; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE5_7_0 |
davidr99 | 0:ab4e012489ef | 697 | uint8_t prop_2109; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE4_7_0 |
davidr99 | 0:ab4e012489ef | 698 | uint8_t prop_210a; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE3_7_0 |
davidr99 | 0:ab4e012489ef | 699 | uint8_t prop_210b; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE2_7_0 |
davidr99 | 0:ab4e012489ef | 700 | uint8_t prop_210c; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE1_7_0 |
davidr99 | 0:ab4e012489ef | 701 | uint8_t prop_210d; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COE0_7_0 |
davidr99 | 0:ab4e012489ef | 702 | uint8_t prop_210e; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM0 |
davidr99 | 0:ab4e012489ef | 703 | uint8_t prop_210f; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM1 |
davidr99 | 0:ab4e012489ef | 704 | uint8_t prop_2110; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM2 |
davidr99 | 0:ab4e012489ef | 705 | uint8_t prop_2111; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX1_CHFLT_COEM3 |
davidr99 | 0:ab4e012489ef | 706 | uint8_t prop_2112; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE13_7_0 |
davidr99 | 0:ab4e012489ef | 707 | uint8_t prop_2113; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE12_7_0 |
davidr99 | 0:ab4e012489ef | 708 | uint8_t prop_2114; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE11_7_0 |
davidr99 | 0:ab4e012489ef | 709 | uint8_t prop_2115; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE10_7_0 |
davidr99 | 0:ab4e012489ef | 710 | uint8_t prop_2116; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE9_7_0 |
davidr99 | 0:ab4e012489ef | 711 | uint8_t prop_2117; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE8_7_0 |
davidr99 | 0:ab4e012489ef | 712 | uint8_t prop_2118; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE7_7_0 |
davidr99 | 0:ab4e012489ef | 713 | uint8_t prop_2119; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE6_7_0 |
davidr99 | 0:ab4e012489ef | 714 | uint8_t prop_211a; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE5_7_0 |
davidr99 | 0:ab4e012489ef | 715 | uint8_t prop_211b; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE4_7_0 |
davidr99 | 0:ab4e012489ef | 716 | uint8_t prop_211c; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE3_7_0 |
davidr99 | 0:ab4e012489ef | 717 | uint8_t prop_211d; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE2_7_0 |
davidr99 | 0:ab4e012489ef | 718 | uint8_t prop_211e; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE1_7_0 |
davidr99 | 0:ab4e012489ef | 719 | uint8_t prop_211f; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COE0_7_0 |
davidr99 | 0:ab4e012489ef | 720 | uint8_t prop_2120; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM0 |
davidr99 | 0:ab4e012489ef | 721 | uint8_t prop_2121; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM1 |
davidr99 | 0:ab4e012489ef | 722 | uint8_t prop_2122; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM2 |
davidr99 | 0:ab4e012489ef | 723 | uint8_t prop_2123; ///< Value for property RH_RF24_PROPERTY_MODEM_CHFLT_RX2_CHFLT_COEM3 |
davidr99 | 0:ab4e012489ef | 724 | uint8_t prop_2203; ///< Value for property RH_RF24_PROPERTY_PA_TC |
davidr99 | 0:ab4e012489ef | 725 | uint8_t prop_2300; ///< Value for property RH_RF24_PROPERTY_SYNTH_PFDCP_CPFF |
davidr99 | 0:ab4e012489ef | 726 | uint8_t prop_2301; ///< Value for property RH_RF24_PROPERTY_SYNTH_PFDCP_CPINT |
davidr99 | 0:ab4e012489ef | 727 | uint8_t prop_2303; ///< Value for property RH_RF24_PROPERTY_SYNTH_LPFILT3 |
davidr99 | 0:ab4e012489ef | 728 | uint8_t prop_2304; ///< Value for property RH_RF24_PROPERTY_SYNTH_LPFILT2 |
davidr99 | 0:ab4e012489ef | 729 | uint8_t prop_2305; ///< Value for property RH_RF24_PROPERTY_SYNTH_LPFILT1 |
davidr99 | 0:ab4e012489ef | 730 | } ModemConfig; |
davidr99 | 0:ab4e012489ef | 731 | |
davidr99 | 0:ab4e012489ef | 732 | /// Choices for setModemConfig() for a selected subset of common |
davidr99 | 0:ab4e012489ef | 733 | /// modulation types, and data rates. If you need another configuration, |
davidr99 | 0:ab4e012489ef | 734 | /// use the register calculator. and call setModemRegisters() with your |
davidr99 | 0:ab4e012489ef | 735 | /// desired settings. |
davidr99 | 0:ab4e012489ef | 736 | /// These are indexes into MODEM_CONFIG_TABLE. We strongly recommend you use these symbolic |
davidr99 | 0:ab4e012489ef | 737 | /// definitions and not their integer equivalents: its possible that values will be |
davidr99 | 0:ab4e012489ef | 738 | /// changed in later versions (though we will try to avoid it). |
davidr99 | 0:ab4e012489ef | 739 | /// Contributions of new complete and tested ModemConfigs ready to add to this list will be readily accepted. |
davidr99 | 0:ab4e012489ef | 740 | typedef enum |
davidr99 | 0:ab4e012489ef | 741 | { |
davidr99 | 0:ab4e012489ef | 742 | FSK_Rb0_5Fd1 = 0, ///< FSK Rb = 0.5kbs, Fd = 1kHz |
davidr99 | 0:ab4e012489ef | 743 | FSK_Rb5Fd10, ///< FSK Rb = 5kbs, Fd = 10kHz |
davidr99 | 0:ab4e012489ef | 744 | FSK_Rb50Fd100, ///< FSK Rb = 50kbs, Fd = 100kHz |
davidr99 | 0:ab4e012489ef | 745 | FSK_Rb150Fd300, ///< FSK Rb = 50kbs, Fd = 100kHz |
davidr99 | 0:ab4e012489ef | 746 | |
davidr99 | 0:ab4e012489ef | 747 | GFSK_Rb0_5Fd1, ///< GFSK Rb = 0.5kbs, Fd = 1kHz |
davidr99 | 0:ab4e012489ef | 748 | GFSK_Rb5Fd10, ///< GFSK Rb = 5kbs, Fd = 10kHz |
davidr99 | 0:ab4e012489ef | 749 | GFSK_Rb50Fd100, ///< GFSK Rb = 50kbs, Fd = 100kHz |
davidr99 | 0:ab4e012489ef | 750 | GFSK_Rb150Fd300, ///< GFSK Rb = 150kbs, Fd = 300kHz |
davidr99 | 0:ab4e012489ef | 751 | |
davidr99 | 0:ab4e012489ef | 752 | // We were unable to get any other OOKs to work |
davidr99 | 0:ab4e012489ef | 753 | OOK_Rb5Bw30, ///< OOK Rb = 5kbs, Bw = 30kHz |
davidr99 | 0:ab4e012489ef | 754 | OOK_Rb10Bw40, ///< OOK Rb = 10kbs, Bw = 40kHz |
davidr99 | 0:ab4e012489ef | 755 | |
davidr99 | 0:ab4e012489ef | 756 | // We were unable to get any 4FSK or 4GFSK schemes to work |
davidr99 | 0:ab4e012489ef | 757 | |
davidr99 | 0:ab4e012489ef | 758 | } ModemConfigChoice; |
davidr99 | 0:ab4e012489ef | 759 | |
davidr99 | 0:ab4e012489ef | 760 | /// \brief Defines the available choices for CRC |
davidr99 | 0:ab4e012489ef | 761 | /// Types of permitted CRC polynomials, to be passed to setCRCPolynomial() |
davidr99 | 0:ab4e012489ef | 762 | /// They deliberately have the same numeric values as the CRC_POLYNOMIAL field of PKT_CRC_CONFIG |
davidr99 | 0:ab4e012489ef | 763 | typedef enum |
davidr99 | 0:ab4e012489ef | 764 | { |
davidr99 | 0:ab4e012489ef | 765 | CRC_NONE = 0, |
davidr99 | 0:ab4e012489ef | 766 | CRC_ITU_T, |
davidr99 | 0:ab4e012489ef | 767 | CRC_IEC_16, |
davidr99 | 0:ab4e012489ef | 768 | CRC_Biacheva, |
davidr99 | 0:ab4e012489ef | 769 | CRC_16_IBM, |
davidr99 | 0:ab4e012489ef | 770 | CRC_CCITT, |
davidr99 | 0:ab4e012489ef | 771 | CRC_Koopman, |
davidr99 | 0:ab4e012489ef | 772 | CRC_IEEE_802_3, |
davidr99 | 0:ab4e012489ef | 773 | CRC_Castagnoli, |
davidr99 | 0:ab4e012489ef | 774 | } CRCPolynomial; |
davidr99 | 0:ab4e012489ef | 775 | |
davidr99 | 0:ab4e012489ef | 776 | /// \brief Defines the commands we can interrogate in printRegisters |
davidr99 | 0:ab4e012489ef | 777 | typedef struct |
davidr99 | 0:ab4e012489ef | 778 | { |
davidr99 | 0:ab4e012489ef | 779 | uint8_t cmd; ///< The command number |
davidr99 | 0:ab4e012489ef | 780 | uint8_t replyLen; ///< Number of bytes in the reply stream (after the CTS) |
davidr99 | 0:ab4e012489ef | 781 | } CommandInfo; |
davidr99 | 0:ab4e012489ef | 782 | |
davidr99 | 0:ab4e012489ef | 783 | /// Constructor. You can have multiple instances, but each instance must have its own |
davidr99 | 0:ab4e012489ef | 784 | /// interrupt and slave select pin. After constructing, you must call init() to initialise the interface |
davidr99 | 0:ab4e012489ef | 785 | /// and the radio module. A maximum of 3 instances can co-exist on one processor, provided there are sufficient |
davidr99 | 0:ab4e012489ef | 786 | /// distinct interrupt lines, one for each instance. |
davidr99 | 0:ab4e012489ef | 787 | /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RF24 before |
davidr99 | 0:ab4e012489ef | 788 | /// accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega, D10 for Maple) |
davidr99 | 0:ab4e012489ef | 789 | /// \param[in] interruptPin The interrupt Pin number that is connected to the RF24 DIO0 interrupt line. |
davidr99 | 0:ab4e012489ef | 790 | /// Defaults to pin 2. |
davidr99 | 0:ab4e012489ef | 791 | /// Caution: You must specify an interrupt capable pin. |
davidr99 | 0:ab4e012489ef | 792 | /// On many Arduino boards, there are limitations as to which pins may be used as interrupts. |
davidr99 | 0:ab4e012489ef | 793 | /// On Leonardo pins 0, 1, 2 or 3. On Mega2560 pins 2, 3, 18, 19, 20, 21. On Due and Teensy, any digital pin. |
davidr99 | 0:ab4e012489ef | 794 | /// On other Arduinos pins 2 or 3. |
davidr99 | 0:ab4e012489ef | 795 | /// See http://arduino.cc/en/Reference/attachInterrupt for more details. |
davidr99 | 0:ab4e012489ef | 796 | /// On Chipkit Uno32, pins 38, 2, 7, 8, 35. |
davidr99 | 0:ab4e012489ef | 797 | /// On other boards, any digital pin may be used. |
davidr99 | 0:ab4e012489ef | 798 | /// \param [in] sdnPin The pin number connected to SDN on the radio. Defaults to pin 9. |
davidr99 | 0:ab4e012489ef | 799 | /// Connecting SDN directly to ground does not aloways provide reliable radio startup. |
davidr99 | 0:ab4e012489ef | 800 | /// \param[in] spi Pointer to the SPI interface object to use. |
davidr99 | 0:ab4e012489ef | 801 | /// Defaults to the standard Arduino hardware SPI interface |
davidr99 | 0:ab4e012489ef | 802 | RH_RF24(PINS slaveSelectPin, PINS interruptPin, PINS sdnPin, RHGenericSPI& spi = hardware_spi); |
davidr99 | 0:ab4e012489ef | 803 | |
davidr99 | 0:ab4e012489ef | 804 | /// Initialises this instance and the radio module connected to it. |
davidr99 | 0:ab4e012489ef | 805 | /// The following steps are taken: |
davidr99 | 0:ab4e012489ef | 806 | /// - Initialise the slave select and shutdown pins and the SPI interface library |
davidr99 | 0:ab4e012489ef | 807 | /// - Checks the connected RF24 module can be communicated |
davidr99 | 0:ab4e012489ef | 808 | /// - Attaches an interrupt handler |
davidr99 | 0:ab4e012489ef | 809 | /// - Configures the RF24 module |
davidr99 | 0:ab4e012489ef | 810 | /// - Sets the frequency to 434.0 MHz |
davidr99 | 0:ab4e012489ef | 811 | /// - Sets the modem data rate to GFSK_Rb5Fd10 |
davidr99 | 0:ab4e012489ef | 812 | /// - Sets the tranmitter power level to 16 (about 2.4dBm on RFM4) |
davidr99 | 0:ab4e012489ef | 813 | /// \return true if everything was successful |
davidr99 | 0:ab4e012489ef | 814 | bool init(); |
davidr99 | 0:ab4e012489ef | 815 | |
davidr99 | 0:ab4e012489ef | 816 | /// Sets the chip mode that will be used when the RH_RF24 driver is idle (ie not transmitting or receiving) |
davidr99 | 0:ab4e012489ef | 817 | /// You can use this to control the power level consumed while idle, at the cost of slower |
davidr99 | 0:ab4e012489ef | 818 | /// transition to tranmit or receive states |
davidr99 | 0:ab4e012489ef | 819 | /// \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 |
davidr99 | 0:ab4e012489ef | 820 | void setIdleMode(uint8_t idleMode); |
davidr99 | 0:ab4e012489ef | 821 | |
davidr99 | 0:ab4e012489ef | 822 | /// Sets the transmitter and receiver |
davidr99 | 0:ab4e012489ef | 823 | /// centre frequency. |
davidr99 | 0:ab4e012489ef | 824 | /// Valid frequency ranges for RFM24/Si4460, Si4461, RFM25/Si4463 are: |
davidr99 | 0:ab4e012489ef | 825 | /// 142MHz to 175Mhz, 284MHz to 350MHz, 425MHz to 525MHz, 850MHz to 1050MHz. |
davidr99 | 0:ab4e012489ef | 826 | /// Valid frequency ranges for RFM26/Si4464 are: |
davidr99 | 0:ab4e012489ef | 827 | /// 119MHz to 960MHz. |
davidr99 | 0:ab4e012489ef | 828 | /// Caution: RFM modules are designed with antenna coupling components to suit a limited band |
davidr99 | 0:ab4e012489ef | 829 | /// of frequencies (marked underneath the module). It is possible to set frequencies in other bands, |
davidr99 | 0:ab4e012489ef | 830 | /// but you may only get little or no power radiated. |
davidr99 | 0:ab4e012489ef | 831 | /// \param[in] centre Frequency in MHz. |
davidr99 | 0:ab4e012489ef | 832 | /// \param[in] afcPullInRange Not used |
davidr99 | 0:ab4e012489ef | 833 | /// \return true if the selected frequency is within a valid range for the connected radio and if |
davidr99 | 0:ab4e012489ef | 834 | /// setting the new frequency succeeded. |
davidr99 | 0:ab4e012489ef | 835 | bool setFrequency(float centre, float afcPullInRange = 0.05); |
davidr99 | 0:ab4e012489ef | 836 | |
davidr99 | 0:ab4e012489ef | 837 | /// Sets all the properties required to configure the data modem in the RF24, including the data rate, |
davidr99 | 0:ab4e012489ef | 838 | /// bandwidths etc. You can use this to configure the modem with custom configurations if none of the |
davidr99 | 0:ab4e012489ef | 839 | /// canned configurations in ModemConfigChoice suit you. |
davidr99 | 0:ab4e012489ef | 840 | /// \param[in] config A ModemConfig structure containing values for the modem configuration registers. |
davidr99 | 0:ab4e012489ef | 841 | void setModemRegisters(const ModemConfig* config); |
davidr99 | 0:ab4e012489ef | 842 | |
davidr99 | 0:ab4e012489ef | 843 | /// Select one of the predefined modem configurations. If you need a modem configuration not provided |
davidr99 | 0:ab4e012489ef | 844 | /// here, use setModemRegisters() with your own ModemConfig. The default after init() is RH_RF24::GFSK_Rb5Fd10. |
davidr99 | 0:ab4e012489ef | 845 | /// \param[in] index The configuration choice. |
davidr99 | 0:ab4e012489ef | 846 | /// \return true if index is a valid choice. |
davidr99 | 0:ab4e012489ef | 847 | bool setModemConfig(ModemConfigChoice index); |
davidr99 | 0:ab4e012489ef | 848 | |
davidr99 | 0:ab4e012489ef | 849 | /// Starts the receiver and checks whether a received message is available. |
davidr99 | 0:ab4e012489ef | 850 | /// This can be called multiple times in a timeout loop |
davidr99 | 0:ab4e012489ef | 851 | /// \return true if a complete, valid message has been received and is able to be retrieved by |
davidr99 | 0:ab4e012489ef | 852 | /// recv() |
davidr99 | 0:ab4e012489ef | 853 | bool available(); |
davidr99 | 0:ab4e012489ef | 854 | |
davidr99 | 0:ab4e012489ef | 855 | /// Turns the receiver on if it not already on. |
davidr99 | 0:ab4e012489ef | 856 | /// If there is a valid message available, copy it to buf and return true |
davidr99 | 0:ab4e012489ef | 857 | /// else return false. |
davidr99 | 0:ab4e012489ef | 858 | /// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted). |
davidr99 | 0:ab4e012489ef | 859 | /// You should be sure to call this function frequently enough to not miss any messages |
davidr99 | 0:ab4e012489ef | 860 | /// It is recommended that you call it in your main loop. |
davidr99 | 0:ab4e012489ef | 861 | /// \param[in] buf Location to copy the received message |
davidr99 | 0:ab4e012489ef | 862 | /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied. |
davidr99 | 0:ab4e012489ef | 863 | /// \return true if a valid message was copied to buf |
davidr99 | 0:ab4e012489ef | 864 | bool recv(uint8_t* buf, uint8_t* len); |
davidr99 | 0:ab4e012489ef | 865 | |
davidr99 | 0:ab4e012489ef | 866 | /// Waits until any previous transmit packet is finished being transmitted with waitPacketSent(). |
davidr99 | 0:ab4e012489ef | 867 | /// Then loads a message into the transmitter and starts the transmitter. Note that a message length |
davidr99 | 0:ab4e012489ef | 868 | /// of 0 is NOT permitted. |
davidr99 | 0:ab4e012489ef | 869 | /// \param[in] data Array of data to be sent |
davidr99 | 0:ab4e012489ef | 870 | /// \param[in] len Number of bytes of data to send (> 0) |
davidr99 | 0:ab4e012489ef | 871 | /// \return true if the message length was valid and it was correctly queued for transmit |
davidr99 | 0:ab4e012489ef | 872 | bool send(const uint8_t* data, uint8_t len); |
davidr99 | 0:ab4e012489ef | 873 | |
davidr99 | 0:ab4e012489ef | 874 | /// The maximum message length supported by this driver |
davidr99 | 0:ab4e012489ef | 875 | /// \return The maximum message length supported by this driver |
davidr99 | 0:ab4e012489ef | 876 | uint8_t maxMessageLength(); |
davidr99 | 0:ab4e012489ef | 877 | |
davidr99 | 0:ab4e012489ef | 878 | /// Sets the length of the preamble |
davidr99 | 0:ab4e012489ef | 879 | /// in bytes. |
davidr99 | 0:ab4e012489ef | 880 | /// Caution: this should be set to the same |
davidr99 | 0:ab4e012489ef | 881 | /// value on all nodes in your network. Default is 4. |
davidr99 | 0:ab4e012489ef | 882 | /// \param[in] bytes Preamble length in bytes. |
davidr99 | 0:ab4e012489ef | 883 | void setPreambleLength(uint16_t bytes); |
davidr99 | 0:ab4e012489ef | 884 | |
davidr99 | 0:ab4e012489ef | 885 | /// Sets the sync words for transmit and receive |
davidr99 | 0:ab4e012489ef | 886 | /// Caution: SyncWords should be set to the same |
davidr99 | 0:ab4e012489ef | 887 | /// value on all nodes in your network. Nodes with different SyncWords set will never receive |
davidr99 | 0:ab4e012489ef | 888 | /// each others messages, so different SyncWords can be used to isolate different |
davidr99 | 0:ab4e012489ef | 889 | /// networks from each other. Default is { 0x2d, 0xd4 }. |
davidr99 | 0:ab4e012489ef | 890 | /// \param[in] syncWords Array of sync words, 1 to 4 octets long. NULL if no sync words to be used. |
davidr99 | 0:ab4e012489ef | 891 | /// \param[in] len Number of sync words to set, 1 to 4. 0 if no sync words to be used. |
davidr99 | 0:ab4e012489ef | 892 | void setSyncWords(const uint8_t* syncWords = NULL, uint8_t len = 0); |
davidr99 | 0:ab4e012489ef | 893 | |
davidr99 | 0:ab4e012489ef | 894 | /// Sets the CRC polynomial to be used to generate the CRC for both receive and transmit |
davidr99 | 0:ab4e012489ef | 895 | /// otherwise the default of CRC_16_IBM will be used. |
davidr99 | 0:ab4e012489ef | 896 | /// \param[in] polynomial One of RH_RF24::CRCPolynomial choices CRC_* |
davidr99 | 0:ab4e012489ef | 897 | /// \return true if polynomial is a valid option for this radio. |
davidr99 | 0:ab4e012489ef | 898 | bool setCRCPolynomial(CRCPolynomial polynomial); |
davidr99 | 0:ab4e012489ef | 899 | |
davidr99 | 0:ab4e012489ef | 900 | /// If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running, |
davidr99 | 0:ab4e012489ef | 901 | /// disables them. |
davidr99 | 0:ab4e012489ef | 902 | void setModeIdle(); |
davidr99 | 0:ab4e012489ef | 903 | |
davidr99 | 0:ab4e012489ef | 904 | /// If current mode is Tx or Idle, changes it to Rx. |
davidr99 | 0:ab4e012489ef | 905 | /// Starts the receiver in the RF24. |
davidr99 | 0:ab4e012489ef | 906 | void setModeRx(); |
davidr99 | 0:ab4e012489ef | 907 | |
davidr99 | 0:ab4e012489ef | 908 | /// If current mode is Rx or Idle, changes it to Rx. F |
davidr99 | 0:ab4e012489ef | 909 | /// Starts the transmitter in the RF24. |
davidr99 | 0:ab4e012489ef | 910 | void setModeTx(); |
davidr99 | 0:ab4e012489ef | 911 | |
davidr99 | 0:ab4e012489ef | 912 | /// Sets the transmitter power output level register PA_PWR_LVL |
davidr99 | 0:ab4e012489ef | 913 | /// The power argument to this function has a non-linear correlation with the actual RF power output. |
davidr99 | 0:ab4e012489ef | 914 | /// See the transmitter power table above for some examples. |
davidr99 | 0:ab4e012489ef | 915 | /// Also the Si446x Data Sheet section 5.4.2 may be helpful. |
davidr99 | 0:ab4e012489ef | 916 | /// Be a good neighbour and set the lowest power level you need. |
davidr99 | 0:ab4e012489ef | 917 | /// Caution: legal power limits may apply in certain countries. |
davidr99 | 0:ab4e012489ef | 918 | /// After init(), the power will be set to 0x10. |
davidr99 | 0:ab4e012489ef | 919 | /// \param[in] power Transmitter power level. For RFM24/Si4460, valid values are 0x00 to 0x4f. For others, 0x00 to 0x7f |
davidr99 | 0:ab4e012489ef | 920 | void setTxPower(uint8_t power); |
davidr99 | 0:ab4e012489ef | 921 | |
davidr99 | 0:ab4e012489ef | 922 | /// Dump the values of available command replies and properties |
davidr99 | 0:ab4e012489ef | 923 | /// to the Serial device if RH_HAVE_SERIAL is defined for the current platform |
davidr99 | 0:ab4e012489ef | 924 | /// Not all commands have valid replies, therefore they are not all printed. |
davidr99 | 0:ab4e012489ef | 925 | /// Caution: the list is very long |
davidr99 | 0:ab4e012489ef | 926 | bool printRegisters(); |
davidr99 | 0:ab4e012489ef | 927 | |
davidr99 | 0:ab4e012489ef | 928 | /// Send a string of command bytes to the chip and get a string of reply bytes |
davidr99 | 0:ab4e012489ef | 929 | /// Different RFM24 commands take different numbers of command bytes and send back different numbers |
davidr99 | 0:ab4e012489ef | 930 | /// of reply bytes. See the Si446x documentaiton for more details. |
davidr99 | 0:ab4e012489ef | 931 | /// Both command bytes and reply bytes are optional |
davidr99 | 0:ab4e012489ef | 932 | /// \param[in] cmd The command number. One of RH_RF24_CMD_* |
davidr99 | 0:ab4e012489ef | 933 | /// \param[in] write_buf Pointer to write_len bytes of command input bytes to send. If there are none, set to NULL. |
davidr99 | 0:ab4e012489ef | 934 | /// \param[in] write_len The number of bytes to send from write_buf. If there are none, set to 0 |
davidr99 | 0:ab4e012489ef | 935 | /// \param[out] read_buf Pointer to read_len bytes of storage where the reply stream from the comand will be written. |
davidr99 | 0:ab4e012489ef | 936 | /// If none are required, set to NULL |
davidr99 | 0:ab4e012489ef | 937 | /// \param[in] read_len The number of bytes to read from the reply stream. If none required, set to 0. |
davidr99 | 0:ab4e012489ef | 938 | /// \return true if the command succeeeded. |
davidr99 | 0:ab4e012489ef | 939 | 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); |
davidr99 | 0:ab4e012489ef | 940 | |
davidr99 | 0:ab4e012489ef | 941 | /// Set one or more chip properties using the RH_RF24_CMD_SET_PROPERTY |
davidr99 | 0:ab4e012489ef | 942 | /// command. See the Si446x API Description AN625 for details on what properties are available. |
davidr99 | 0:ab4e012489ef | 943 | /// param[in] firstProperty The property number of the first property to set. The first value in the values array |
davidr99 | 0:ab4e012489ef | 944 | /// will be used to set this property, and any subsequent values will be used to set the following properties. |
davidr99 | 0:ab4e012489ef | 945 | /// One of RH_RF24_PROPERTY_* |
davidr99 | 0:ab4e012489ef | 946 | /// param[in] values Array of 0 or more values to write the firstProperty and subsequent proerties |
davidr99 | 0:ab4e012489ef | 947 | /// param[in] count The number of values in the values array |
davidr99 | 0:ab4e012489ef | 948 | /// \return true if the command succeeeded. |
davidr99 | 0:ab4e012489ef | 949 | bool set_properties(uint16_t firstProperty, const uint8_t* values, uint8_t count); |
davidr99 | 0:ab4e012489ef | 950 | |
davidr99 | 0:ab4e012489ef | 951 | /// Get one or more chip properties using the RH_RF24_CMD_GET_PROPERTY |
davidr99 | 0:ab4e012489ef | 952 | /// command. See the Si446x API Description AN625 for details on what properties are available. |
davidr99 | 0:ab4e012489ef | 953 | /// param[in] firstProperty The property number of the first property to get. The first value in the values array |
davidr99 | 0:ab4e012489ef | 954 | /// will be set with this property, and any subsequent values will be set from the following properties. |
davidr99 | 0:ab4e012489ef | 955 | /// One of RH_RF24_PROPERTY_* |
davidr99 | 0:ab4e012489ef | 956 | /// param[out] values Array of 0 or more values to receive the firstProperty and subsequent proerties |
davidr99 | 0:ab4e012489ef | 957 | /// param[in] count The number of values in the values array |
davidr99 | 0:ab4e012489ef | 958 | /// \return true if the command succeeeded. |
davidr99 | 0:ab4e012489ef | 959 | bool get_properties(uint16_t firstProperty, uint8_t* values, uint8_t count); |
davidr99 | 0:ab4e012489ef | 960 | |
davidr99 | 0:ab4e012489ef | 961 | /// Measures and returns the current |
davidr99 | 0:ab4e012489ef | 962 | /// Chip temperature. |
davidr99 | 0:ab4e012489ef | 963 | /// \return The current chip temperature in degrees Centigrade |
davidr99 | 0:ab4e012489ef | 964 | float get_temperature(); |
davidr99 | 0:ab4e012489ef | 965 | |
davidr99 | 0:ab4e012489ef | 966 | /// Measures and returns the current |
davidr99 | 0:ab4e012489ef | 967 | /// Chip Vcc supply voltage. |
davidr99 | 0:ab4e012489ef | 968 | /// \return The current chip Vcc supply voltage in Volts. |
davidr99 | 0:ab4e012489ef | 969 | float get_battery_voltage(); |
davidr99 | 0:ab4e012489ef | 970 | |
davidr99 | 0:ab4e012489ef | 971 | /// Measures and returns the current |
davidr99 | 0:ab4e012489ef | 972 | /// voltage applied to a GPIO pin (which has previously been configured as a voltage input) |
davidr99 | 0:ab4e012489ef | 973 | /// \param[in] gpio The GPIO pin to read. 0 to 3. |
davidr99 | 0:ab4e012489ef | 974 | /// \return The current pin voltage in Volts. |
davidr99 | 0:ab4e012489ef | 975 | float get_gpio_voltage(uint8_t gpio); |
davidr99 | 0:ab4e012489ef | 976 | |
davidr99 | 0:ab4e012489ef | 977 | /// Read one of the Fast Read Response registers. |
davidr99 | 0:ab4e012489ef | 978 | /// The Fast Read Response register must be previously configured with the matching |
davidr99 | 0:ab4e012489ef | 979 | /// RH_RF24_PROPERTY_FRR_CTL_?_MODE property to select what chip property will be available in that register. |
davidr99 | 0:ab4e012489ef | 980 | /// \param[in] reg The index of the FRR register to read. 0 means FRR A, 1 means B etc. |
davidr99 | 0:ab4e012489ef | 981 | /// \return the value read from the specified Fast Read Response register. |
davidr99 | 0:ab4e012489ef | 982 | uint8_t frr_read(uint8_t reg); |
davidr99 | 0:ab4e012489ef | 983 | |
davidr99 | 0:ab4e012489ef | 984 | /// Sets the radio into low-power sleep mode. |
davidr99 | 0:ab4e012489ef | 985 | /// If successful, the transport will stay in sleep mode until woken by |
davidr99 | 0:ab4e012489ef | 986 | /// changing mode it idle, transmit or receive (eg by calling send(), recv(), available() etc) |
davidr99 | 0:ab4e012489ef | 987 | /// Caution: there is a time penalty as the radio takes a finte time to wake from sleep mode. |
davidr99 | 0:ab4e012489ef | 988 | /// \return true if sleep mode was successfully entered. |
davidr99 | 0:ab4e012489ef | 989 | virtual bool sleep(); |
davidr99 | 0:ab4e012489ef | 990 | |
davidr99 | 0:ab4e012489ef | 991 | protected: |
davidr99 | 0:ab4e012489ef | 992 | /// This is a low level function to handle the interrupts for one instance of RF24. |
davidr99 | 0:ab4e012489ef | 993 | /// Called automatically by isr*() |
davidr99 | 0:ab4e012489ef | 994 | /// Should not need to be called by user code. |
davidr99 | 0:ab4e012489ef | 995 | void handleInterrupt(); |
davidr99 | 0:ab4e012489ef | 996 | |
davidr99 | 0:ab4e012489ef | 997 | /// Clears the chips RX FIFO |
davidr99 | 0:ab4e012489ef | 998 | /// \return true if successful |
davidr99 | 0:ab4e012489ef | 999 | bool clearRxFifo(); |
davidr99 | 0:ab4e012489ef | 1000 | |
davidr99 | 0:ab4e012489ef | 1001 | /// Clears RH_RF24's internal TX and RX buffers and counters |
davidr99 | 0:ab4e012489ef | 1002 | void clearBuffer(); |
davidr99 | 0:ab4e012489ef | 1003 | |
davidr99 | 0:ab4e012489ef | 1004 | /// Loads the next part of the currently transmitting message |
davidr99 | 0:ab4e012489ef | 1005 | /// into the chips TX buffer |
davidr99 | 0:ab4e012489ef | 1006 | void sendNextFragment(); |
davidr99 | 0:ab4e012489ef | 1007 | |
davidr99 | 0:ab4e012489ef | 1008 | /// Copies the next part of the currenrtly received message from the chips RX FIFO to the |
davidr99 | 0:ab4e012489ef | 1009 | /// receive buffer |
davidr99 | 0:ab4e012489ef | 1010 | void readNextFragment(); |
davidr99 | 0:ab4e012489ef | 1011 | |
davidr99 | 0:ab4e012489ef | 1012 | /// Loads data into the chips TX FIFO |
davidr99 | 0:ab4e012489ef | 1013 | /// \param[in] data Array of data bytes to be loaded |
davidr99 | 0:ab4e012489ef | 1014 | /// \param[in] len Number of bytes in data to be loaded |
davidr99 | 0:ab4e012489ef | 1015 | /// \return true if successful |
davidr99 | 0:ab4e012489ef | 1016 | bool writeTxFifo(uint8_t *data, uint8_t len); |
davidr99 | 0:ab4e012489ef | 1017 | |
davidr99 | 0:ab4e012489ef | 1018 | /// Checks the contents of the RX buffer. |
davidr99 | 0:ab4e012489ef | 1019 | /// If it contans a valid message adressed to this node |
davidr99 | 0:ab4e012489ef | 1020 | /// sets _rxBufValid. |
davidr99 | 0:ab4e012489ef | 1021 | void validateRxBuf(); |
davidr99 | 0:ab4e012489ef | 1022 | |
davidr99 | 0:ab4e012489ef | 1023 | /// Cycles the Shutdown pin to force the cradio chip to reset |
davidr99 | 0:ab4e012489ef | 1024 | void power_on_reset(); |
davidr99 | 0:ab4e012489ef | 1025 | |
davidr99 | 0:ab4e012489ef | 1026 | /// Sets registers, commands and properties |
davidr99 | 0:ab4e012489ef | 1027 | /// in the ratio according to the data in the commands array |
davidr99 | 0:ab4e012489ef | 1028 | /// \param[in] commands Array of data containing radio commands in the format provided by radio_config_Si4460.h |
davidr99 | 0:ab4e012489ef | 1029 | /// \return true if successful |
davidr99 | 0:ab4e012489ef | 1030 | bool configure(const uint8_t* commands); |
davidr99 | 0:ab4e012489ef | 1031 | |
davidr99 | 0:ab4e012489ef | 1032 | /// Clears all pending interrutps in the radio chip. |
davidr99 | 0:ab4e012489ef | 1033 | bool cmd_clear_all_interrupts(); |
davidr99 | 0:ab4e012489ef | 1034 | |
davidr99 | 0:ab4e012489ef | 1035 | private: |
davidr99 | 0:ab4e012489ef | 1036 | |
davidr99 | 0:ab4e012489ef | 1037 | /// Low level interrupt service routine for RF24 connected to interrupt 0 |
davidr99 | 0:ab4e012489ef | 1038 | static void isr0(); |
davidr99 | 0:ab4e012489ef | 1039 | |
davidr99 | 0:ab4e012489ef | 1040 | /// Low level interrupt service routine for RF24 connected to interrupt 1 |
davidr99 | 0:ab4e012489ef | 1041 | static void isr1(); |
davidr99 | 0:ab4e012489ef | 1042 | |
davidr99 | 0:ab4e012489ef | 1043 | /// Low level interrupt service routine for RF24 connected to interrupt 1 |
davidr99 | 0:ab4e012489ef | 1044 | static void isr2(); |
davidr99 | 0:ab4e012489ef | 1045 | |
davidr99 | 0:ab4e012489ef | 1046 | /// Array of instances connected to interrupts 0 and 1 |
davidr99 | 0:ab4e012489ef | 1047 | static RH_RF24* _deviceForInterrupt[]; |
davidr99 | 0:ab4e012489ef | 1048 | |
davidr99 | 0:ab4e012489ef | 1049 | /// Index of next interrupt number to use in _deviceForInterrupt |
davidr99 | 0:ab4e012489ef | 1050 | static uint8_t _interruptCount; |
davidr99 | 0:ab4e012489ef | 1051 | |
davidr99 | 0:ab4e012489ef | 1052 | #if (RH_PLATFORM == RH_PLATFORM_MBED) |
davidr99 | 0:ab4e012489ef | 1053 | /// The configured interrupt pin connected to this instance |
davidr99 | 0:ab4e012489ef | 1054 | InterruptIn _interruptPin; |
davidr99 | 0:ab4e012489ef | 1055 | #else |
davidr99 | 0:ab4e012489ef | 1056 | /// The configured interrupt pin connected to this instance |
davidr99 | 0:ab4e012489ef | 1057 | uint8_t _interruptPin; |
davidr99 | 0:ab4e012489ef | 1058 | #endif |
davidr99 | 0:ab4e012489ef | 1059 | |
davidr99 | 0:ab4e012489ef | 1060 | /// The index into _deviceForInterrupt[] for this device (if an interrupt is already allocated) |
davidr99 | 0:ab4e012489ef | 1061 | /// else 0xff |
davidr99 | 0:ab4e012489ef | 1062 | uint8_t _myInterruptIndex; |
davidr99 | 0:ab4e012489ef | 1063 | |
davidr99 | 0:ab4e012489ef | 1064 | #if (RH_PLATFORM == RH_PLATFORM_MBED) |
davidr99 | 0:ab4e012489ef | 1065 | /// The configured pin connected to the SDN pin of the radio |
davidr99 | 0:ab4e012489ef | 1066 | DigitalOut _sdnPin; |
davidr99 | 0:ab4e012489ef | 1067 | #else |
davidr99 | 0:ab4e012489ef | 1068 | /// The configured pin connected to the SDN pin of the radio |
davidr99 | 0:ab4e012489ef | 1069 | uint8_t _sdnPin; |
davidr99 | 0:ab4e012489ef | 1070 | #endif |
davidr99 | 0:ab4e012489ef | 1071 | |
davidr99 | 0:ab4e012489ef | 1072 | /// The radio OP mode to use when mode is RHModeIdle |
davidr99 | 0:ab4e012489ef | 1073 | uint8_t _idleMode; |
davidr99 | 0:ab4e012489ef | 1074 | |
davidr99 | 0:ab4e012489ef | 1075 | /// The reported PART device type |
davidr99 | 0:ab4e012489ef | 1076 | uint16_t _deviceType; |
davidr99 | 0:ab4e012489ef | 1077 | |
davidr99 | 0:ab4e012489ef | 1078 | /// The selected output power in dBm |
davidr99 | 0:ab4e012489ef | 1079 | int8_t _power; |
davidr99 | 0:ab4e012489ef | 1080 | |
davidr99 | 0:ab4e012489ef | 1081 | /// The message length in _buf |
davidr99 | 0:ab4e012489ef | 1082 | volatile uint8_t _bufLen; |
davidr99 | 0:ab4e012489ef | 1083 | |
davidr99 | 0:ab4e012489ef | 1084 | /// Array of octets of the last received message or the next to transmit message |
davidr99 | 0:ab4e012489ef | 1085 | uint8_t _buf[RH_RF24_MAX_PAYLOAD_LEN]; |
davidr99 | 0:ab4e012489ef | 1086 | |
davidr99 | 0:ab4e012489ef | 1087 | /// True when there is a valid message in the Rx buffer |
davidr99 | 0:ab4e012489ef | 1088 | volatile bool _rxBufValid; |
davidr99 | 0:ab4e012489ef | 1089 | |
davidr99 | 0:ab4e012489ef | 1090 | /// Index into TX buffer of the next to send chunk |
davidr99 | 0:ab4e012489ef | 1091 | volatile uint8_t _txBufSentIndex; |
davidr99 | 0:ab4e012489ef | 1092 | |
davidr99 | 0:ab4e012489ef | 1093 | /// Time in millis since the last preamble was received (and the last time the RSSI was measured) |
davidr99 | 0:ab4e012489ef | 1094 | uint32_t _lastPreambleTime; |
davidr99 | 0:ab4e012489ef | 1095 | |
davidr99 | 0:ab4e012489ef | 1096 | }; |
davidr99 | 0:ab4e012489ef | 1097 | |
davidr99 | 0:ab4e012489ef | 1098 | /// @example rf24_client.pde |
davidr99 | 0:ab4e012489ef | 1099 | /// @example rf24_server.pde |
davidr99 | 0:ab4e012489ef | 1100 | /// @example rf24_reliable_datagram_client.pde |
davidr99 | 0:ab4e012489ef | 1101 | /// @example rf24_reliable_datagram_server.pde |
davidr99 | 0:ab4e012489ef | 1102 | |
davidr99 | 0:ab4e012489ef | 1103 | #endif |