00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00051 #ifndef _CC1000_H_
00052 #define _CC1000_H_
00053
00054 #include "mos.h"
00055
00056 #include "stdarg.h"
00057 #include "com.h"
00058
00059 #ifndef PLATFORM_LINUX
00060
00061
00062 #define CC1000_MAIN 0x00
00063 #define CC1000_FREQ_2A 0x01
00064 #define CC1000_FREQ_1A 0x02
00065 #define CC1000_FREQ_0A 0x03
00066 #define CC1000_FREQ_2B 0x04
00067 #define CC1000_FREQ_1B 0x05
00068 #define CC1000_FREQ_0B 0x06
00069 #define CC1000_FSEP1 0x07
00070 #define CC1000_FSEP0 0x08
00071 #define CC1000_CURRENT 0x09
00072 #define CC1000_FRONT_END 0x0A
00073 #define CC1000_PA_POW 0x0B
00074 #define CC1000_PLL 0x0C
00075 #define CC1000_LOCK 0x0D
00076 #define CC1000_CAL 0x0E
00077 #define CC1000_MODEM2 0x0F
00078 #define CC1000_MODEM1 0x10
00079 #define CC1000_MODEM0 0x11
00080 #define CC1000_MATCH 0x12
00081 #define CC1000_FSCTRL 0x13
00082 #define CC1000_FSHAPE7 0x14
00083 #define CC1000_FSHAPE6 0x15
00084 #define CC1000_FSHAPE5 0x16
00085 #define CC1000_FSHAPE4 0x17
00086 #define CC1000_FSHAPE3 0x18
00087 #define CC1000_FSHAPE2 0x19
00088 #define CC1000_FSHAPE1 0x1A
00089 #define CC1000_FSDELAY 0x1B
00090 #define CC1000_PRESCALER 0x1C
00091 #define CC1000_TEST6 0x40
00092 #define CC1000_TEST5 0x41
00093 #define CC1000_TEST4 0x42
00094 #define CC1000_TEST3 0x43
00095 #define CC1000_TEST2 0x44
00096 #define CC1000_TEST1 0x45
00097 #define CC1000_TEST0 0x46
00098
00099
00100
00101
00102 #define CC1000_RXTX 7
00103 #define CC1000_F_REG 6
00104 #define CC1000_RX_PD 5
00105 #define CC1000_TX_PD 4
00106 #define CC1000_FS_PD 3
00107 #define CC1000_CORE_PD 2
00108 #define CC1000_BIAS_PD 1
00109 #define CC1000_RESET_N 0
00110
00111
00112
00113
00114 #define CC1000_VCO_CURRENT 4
00115
00116 #define CC1000_LO_DRIVE 2
00117
00118 #define CC1000_PA_DRIVE 0
00119
00120
00121 #define CC1000_BUF_CURRENT 5
00122 #define CC1000_LNA_CURRENT 3
00123 #define CC1000_IF_RSSI 1
00124 #define CC1000_XOSC_BYPASS 0
00125
00126
00127 #define CC1000_PA_HIGHPOWER 4
00128 #define CC1000_PA_LOWPOWER 0
00129
00130
00131 #define CC1000_EXT_FILTER 7
00132 #define CC1000_REFDIV 3
00133 #define CC1000_ALARM_DISABLE 2
00134 #define CC1000_ALARM_H 1
00135 #define CC1000_ALARM_L 0
00136
00137
00138 #define CC1000_LOCK_SELECT 4
00139 #define CC1000_PLL_LOCK_ACCURACY 3
00140 #define CC1000_PLL_LOCK_LENGTH 2
00141 #define CC1000_LOCK_INSTANT 1
00142 #define CC1000_LOCK_CONTINUOUS 0
00143
00144
00145 #define CC1000_CAL_START 7
00146 #define CC1000_CAL_DUAL 6
00147 #define CC1000_CAL_WAIT 5
00148 #define CC1000_CAL_CURRENT 4
00149 #define CC1000_CAL_COMPLETE 3
00150 #define CC1000_CAL_ITERATE 0 //3 bits
00151
00152
00153 #define CC1000_PEAKDETECT 7
00154 #define CC1000_PEAK_LEVEL_OFFSET 0 //7 bits
00155
00156
00157 #define CC1000_MLIMIT 5
00158 #define CC1000_LOCK_AVG_IN 4
00159 #define CC1000_LOCK_AVG_MODE 3
00160 #define CC1000_SETTLING 1
00161 #define CC1000_MODEM_RESET_N 0
00162
00163
00164 #define CC1000_BAUDRATE 4
00165 #define CC1000_DATA_FORMAT 2
00166 #define CC1000_XOSC_FREQ 0
00167
00168
00169 #define CC1000_RX_MATCH 4
00170 #define CC1000_TX_MATCH 0
00171
00172
00173 #define CC1000_DITHER1 3
00174 #define CC1000_DITHER0 2
00175 #define CC1000_SHAPE 1
00176 #define CC1000_FS_RESET_N 0
00177
00178
00179 #define CC1000_PRE_SWING 6
00180 #define CC1000_PRE_CURRENT 4
00181 #define CC1000_IF_INPUT 3
00182 #define CC1000_IF_FRONT 2
00183
00184
00185 #define CC1000_LOOPFILTER_TP1 7
00186 #define CC1000_LOOPFILTER_TP2 6
00187 #define CC1000_CHP_OVERRIDE 5
00188 #define CC1000_CHP_CO 0
00189
00190
00191 #define CC1000_CHP_DISALBE 5
00192 #define CC1000_VCO_OVERRIDE 4
00193 #define CC1000_VCO_AO 0
00194
00195
00196 #define CC1000_BREAK_LOOP 4
00197 #define CC1000_CAL_DAC_OPEN 0
00198
00199
00200 #define CC1000_CHP_CURRENT 0
00201
00202
00203 #define CC1000_CAL_DAC 0
00204
00205
00206 #define CC1000_VCO_ARRAY 0
00207
00208
00209 #define FREQS_NUM 0x1e
00210
00211
00212 #define PARAM_NUM 38
00213 #define SETTING_NUM 6
00214
00215
00216 #define MAIN_INDEX 0x00
00217 #define FREQ2A_INDEX 0x01
00218 #define FREQ1A_INDEX 0x02
00219 #define FREQ0A_INDEX 0x03
00220 #define FREQ2B_INDEX 0x04
00221 #define FREQ1B_INDEX 0x05
00222 #define FREQ0B_INDEX 0x06
00223 #define FSEP1_INDEX 0x07
00224 #define FSEP0_INDEX 0x08
00225 #define RXCURRENT_INDEX 0x09
00226 #define FRONTEND_INDEX 0x0a
00227 #define PAPOW_INDEX 0x0b
00228 #define RXPLL_INDEX 0x0c
00229 #define LOCK_INDEX 0x0d
00230 #define CAL_INDEX 0x0e
00231 #define MODEM2_INDEX 0x0f
00232 #define MODEM1_INDEX 0x10
00233 #define MODEM0_INDEX 0x11
00234 #define MATCH_INDEX 0x12
00235 #define FSCTRL_INDEX 0x13
00236 #define FSHAPE7_INDEX 0x14
00237 #define FSHAPE6_INDEX 0x15
00238 #define FSHAPE5_INDEX 0x16
00239 #define FSHAPE4_INDEX 0x17
00240 #define FSHAPE3_INDEX 0x18
00241 #define FSHAPE2_INDEX 0x19
00242 #define FSHAPE1_INDEX 0x1a
00243 #define FSDELAY_INDEX 0x1b
00244 #define PRESCALER_INDEX 0x1c
00245 #define TEST6_INDEX 0x1d
00246 #define TEST5_INDEX 0x1e
00247 #define TEST4_INDEX 0x1f
00248 #define TEST3_INDEX 0x20
00249 #define TEST2_INDEX 0x21
00250 #define TEST1_INDEX 0x22
00251 #define TEST0_INDEX 0x23
00252 #define TXCURRENT_INDEX 0x24
00253 #define TXPLL_INDEX 0x25
00254
00255
00256 #define FREQ_902_265_MHZ 0x00
00257 #define FREQ_902_791_MHZ 0x01
00258 #define FREQ_903_318_MHZ 0x02
00259 #define FREQ_903_845_MHZ 0x03
00260 #define FREQ_904_371_MHZ 0x04
00261 #define FREQ_904_898_MHZ 0x05
00262 #define FREQ_905_425_MHZ 0x06
00263 #define FREQ_905_951_MHZ 0x07
00264 #define FREQ_906_478_MHZ 0x08
00265 #define FREQ_907_004_MHZ 0x09
00266 #define FREQ_907_531_MHZ 0x0a
00267 #define FREQ_908_058_MHZ 0x0b
00268 #define FREQ_908_584_MHZ 0x0c
00269 #define FREQ_909_111_MHZ 0x0d
00270 #define FREQ_909_638_MHZ 0x0e
00271 #define FREQ_910_164_MHZ 0x0f
00272 #define FREQ_910_691_MHZ 0x10
00273 #define FREQ_911_217_MHZ 0x11
00274 #define FREQ_911_744_MHZ 0x12
00275 #define FREQ_912_271_MHZ 0x13
00276 #define FREQ_912_797_MHZ 0x14
00277 #define FREQ_913_324_MHZ 0x15
00278 #define FREQ_913_851_MHZ 0x16
00279 #define FREQ_914_377_MHZ 0x17
00280 #define FREQ_914_907_MHZ 0x18
00281 #define FREQ_915_430_MHZ 0x19
00282 #define FREQ_915_957_MHZ 0x1a
00283 #define FREQ_916_484_MHZ 0x1b
00284 #define FREQ_917_010_MHZ 0x1c
00285 #define FREQ_917_537_MHZ 0x1d
00286
00287
00288
00289 #define BAUD_0_6_K 0x07 //0.6 KBaud
00290 #define BAUD_1_2_K 0x17 //1.2 KBaud
00291 #define BAUD_2_4_K 0x27 //2.4 KBaud
00292 #define BAUD_4_8_K 0x37
00293 #define BAUD_9_6_K 0x47
00294 #define BAUD_19_2_K 0x57
00295 #define BAUD_38_4_K 0x57
00296
00297 #define BAUD_19_2_K_LOWER_TEST4 0x25
00298
00299
00300 #if defined(PLATFORM_NYMPH)
00301 #define CONFIG_PORT PORTC
00302 #define CONFIG_PORT_DIR DDRC
00303 #define CONFIG_PORT_PIN PINC
00304 #define PALE 3
00305 #define PDATA 2
00306 #define PCLK 1
00307 #elif defined(PLATFORM_MICA2)
00308 #define CONFIG_PORT PORTD
00309 #define CONFIG_PORT_DIR DDRD
00310 #define CONFIG_PORT_PIN PIND
00311 #define PALE 4
00312 #define PDATA 7
00313 #define PCLK 6
00314 #elif defined(PLATFORM_MICA2DOT)
00315 #define CONFIG_PORT PORTD
00316 #define CONFIG_PORT_DIR DDRD
00317 #define CONFIG_PORT_PIN PIND
00318 #define PALE 5
00319 #define PDATA 7
00320 #define PCLK 6
00321 #else
00322 #error "Radio port/pins undefined"
00323 #endif
00324
00325
00326 #define CC1000_MODE_RX 0x00
00327 #define CC1000_MODE_TX 0x01
00328 #define CC1000_MODE_PD 0x02
00329 #define CC1000_MODE_SLEEP 0x03
00330
00331
00332
00333 #define CC1000_TX_POWER 0
00334 #define CC1000_RSSI 1
00335 #define CC1000_FREQ 2
00336 #define CC1000_RTS 3
00337 #define CC1000_NO_RTS 4
00338 #define CC1000_GET_TX_POWER 5
00339
00340
00341 #define RADIO_TX_POWER CC1000_TX_POWER
00342
00344 #define MODE_ON 0
00345
00346 #define MODE_OFF 1
00347
00348
00349 #define FREQ 0x03
00350
00352 #define PREAMBLE_THRESH 6
00353
00354 #define PREAMBLE_LEN 16
00355
00356 #define PREAMBLE_BYTE 0xAA
00357
00358 #define FLUSH_BYTE 0xff
00359
00360
00361
00364 void delay_null();
00365
00366
00371 void cc1000_init(uint8_t freq);
00372
00373
00377 void cc1000_set(uint8_t newFreq);
00378
00382 void cc1000_change_freq(uint8_t new_freq);
00383
00388 void cc1000_calibrate();
00389
00394 void cc1000_write(uint8_t addr, uint8_t data);
00395
00400 void cc1000_write_word(short addranddata);
00401
00406 uint8_t cc1000_read(uint8_t addr);
00407
00410 inline uint8_t cc1000_get_mode (void);
00411
00412 void cc1000_set_power(uint8_t powerLevel);
00413
00418 void cc1000_mode(uint8_t mode);
00419
00423 void cc1000_on();
00424 void cc1000_off();
00425
00428 void cc1000_sleep();
00429
00432 void cc1000_wakeup();
00433 void cc1000_reset();
00434
00437 void cc1000_rssi_on();
00438 void cc1000_rssi_off();
00439
00443 uint8_t cc1000_get_channel();
00444
00448 uint8_t cc1000_get_power();
00449
00451 uint8_t cc1000_cmode(uint8_t md);
00452
00454 uint8_t cc1000_ioctl(uint8_t request, va_list ap);
00455
00456 extern uint16_t cc1000_crc_error_count;
00457 extern uint16_t cc1000_mem_error_count;
00458 extern uint16_t cc1000_sync_error_count;
00459 extern uint16_t cc1000_size_error_count;
00460
00462 inline uint16_t cc1000_get_fec_errors();
00463
00464
00466 inline void cc1000_state_machine();
00467
00469 inline void cc1000_start_transmit(comBuf *sendPkt);
00470
00471 void cc1000_fec_on();
00472 void cc1000_fec_off();
00473
00475 void cc1000_default_init();
00476
00480 void cc1000_init_ec();
00481
00482 #endif
00483
00484 #endif