📄 ia443x_rf.lst
字号:
217 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
218 RF_ENUM RFSetParameter(RF_PARAMETER parameter, uint8 * value, uint8 length)
219 {
220 1 uint8 temp8, i;
221 1
222 1
223 1 if( (RfState != sRFIdle) || (length > 100) )
224 1 return RF_ERROR_STATE;
225 1
226 1 switch(parameter)
227 1 {
228 2 /*
229 2 value[0] - frequency band
230 2 value[1] - Carrier frequency1
231 2 value[2] - Carrier frequency2
232 2 */
233 2 case pRfFrequency:
234 2 //set frequency band
235 2 SpiRfWriteAddressData((REG_WRITE | FrequencyBandSelect), *value++);
236 2 //set frequency
237 2 SpiRfWriteAddressData((REG_WRITE | NominalCarrierFrequency1), *value++);
238 2 SpiRfWriteAddressData((REG_WRITE | NominalCarrierFrequency0), *value);
239 2 break;
240 2
241 2 /*
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 5
242 2 value[0] - GPIO0
243 2 value[1] - GPIO1
244 2 value[2] - GPIO2
245 2 */
246 2 case pRfGpios:
247 2 SpiRfWriteAddressData((REG_WRITE | GPIO0Configuration), *value++);
248 2 SpiRfWriteAddressData((REG_WRITE | GPIO1Configuration), *value++);
249 2 SpiRfWriteAddressData((REG_WRITE | GPIO2Configuration), *value++);
250 2 break;
251 2
252 2 /*
253 2 value[0] - DIGITAL OUT: bit<0> - GPIO0, bit<1> - GPIO1, bit<2> - GPIO2
254 2 */
255 2 case pRfDigitalOut:
256 2 SpiRfWriteAddressData((REG_WRITE | IOPortConfiguration), (*value & 0x07));
257 2 break;
258 2
259 2 /*
260 2 value[0] - DIGITAL INPUT: bit<0> - GPIO0, bit<1> - GPIO1, bit<2> - GPIO2
261 2 value[1] - INTERRUPT INPUT STATE: bit<0> - GPIO0, bit<1> - GPIO1, bit<2> - GPIO2
262 2 */
263 2 case pRfDigitalIn:
264 2 temp8 = SpiRfReadRegister( IOPortConfiguration );
265 2 *value++ = temp8 & 0x07;
266 2 *value = (temp8 >> 4) & 0x07;
267 2 break;
268 2
269 2
270 2 /*
271 2 value[0] - Output power
272 2 */
273 2 case pRfTransmitPower:
274 2 SpiRfWriteAddressData((REG_WRITE | TXPower), *value);
275 2 break;
276 2
277 2 /*
278 2 value[0] - Preamble length in nibbles: bit[8]
279 2 value[1] - Preamble length in nibbles: bit[7..0]
280 2 */
281 2 case pRfPreambleLength:
282 2 //set MSB if needed
283 2 temp8 = SpiRfReadRegister( HeaderControl2 );
284 2 if( *value++ == 0)
285 2 {
286 3 temp8 &= 0xFE;
287 3 }
288 2 else
289 2 {
290 3 temp8 |= 0x01;
291 3 }
292 2 SpiRfWriteAddressData((REG_WRITE | HeaderControl2), (temp8 & 0x07));
293 2 //set lower byte
294 2 SpiRfWriteAddressData((REG_WRITE | PreambleLength), *value);
295 2 break;
296 2
297 2 /*
298 2 value[0] - Number of nibbles needs to be match (0...31)
299 2 */
300 2 case pRfPremableDetection:
301 2 temp8 += ((*value & 0x1F) << 3);
302 2 SpiRfWriteAddressData((REG_WRITE | PreambleDetectionControl), temp8 );
303 2 break;
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 6
304 2
305 2 /*
306 2 value[0] - Length of the synchron word (1...4)
307 2 value[1] - synchron word 3
308 2 value[2] - synchron word 2 -if enabled-
309 2 value[3] - synchron word 1 -if enabled-
310 2 value[4] - synchron word 0 -if enabled-
311 2 */
312 2 case pRfSynchronWord:
313 2 temp8 = ((*value++ - 1) << 1) & 0x06;
314 2 i = SpiRfReadRegister( HeaderControl2 ) & 0xF9;
315 2 i += temp8;
316 2 SpiRfWriteAddressData((REG_WRITE | HeaderControl2), i);
317 2 for(i=0;i<temp8;i++)
318 2 {
319 3 SpiRfWriteAddressData((REG_WRITE | (SyncWord3 + i)), *value++);
320 3 }
321 2 break;
322 2
323 2 /*
324 2 value[0] - new value of the modulation mode ctrl 2 register.
325 2 (Refer to the IA443x_rf.h for available definitions!)
326 2 */
327 2 case pRfModulation:
328 2 temp8 = SpiRfReadRegister( ModulationModeControl1 );
329 2 temp8 &= 0x2C;
330 2 SpiRfWriteAddressData((REG_WRITE | ModulationModeControl1), temp8);
331 2 SpiRfWriteAddressData((REG_WRITE | ModulationModeControl2), *value);
332 2 break;
333 2
334 2 /*
335 2 value[0] - wheather the TX / RX packet handler, CRC is enabled or not .
336 2 (Refer to the IA443x_rf.h for available definitions!)
337 2 */
338 2 case pRfPacketHandler:
339 2 SpiRfWriteAddressData((REG_WRITE | DataAccessControl), *value);
340 2 break;
341 2
342 2 /*
343 2 value[0] - whether it uses antenna diversity algorithm or not
344 2 */
345 2 case pRfAntennaDiversity:
346 2 temp8 = SpiRfReadRegister( OperatingFunctionControl2 );
347 2 temp8 &= 0x1F;
348 2 if( *value == TRUE)
349 2 {//enable antenna diversity algorithm
350 3 temp8 |= 0x80;
351 3 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl2), temp8);
352 3 SpiRfWriteAddressData((REG_WRITE | AFCTimingControl), 0x20);
353 3 }
354 2 else
355 2 {//disable antenna diversity algorithm
356 3 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl2), temp8);
357 3 SpiRfWriteAddressData((REG_WRITE | AFCTimingControl), 0x08);
358 3 }
359 2 break;
360 2
361 2 /*
362 2 value[0] - TRUE: enable the LBD; FALSE: disable the LBD
363 2 value[1] - TRUE: enable IT, FALSE: disable IT
364 2 value[2] - LBD Threshold
365 2 */
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 7
366 2 case pLowBatteryDetector:
367 2 temp8 = SpiRfReadRegister( OperatingFunctionControl1 );
368 2 if(*value++ == TRUE)
369 2 {//enable the Low Battery Detector
370 3 temp8 |= 0x40;
371 3 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl1), temp8);
372 3 temp8 = SpiRfReadRegister( InterruptStatus2 );
373 3 if(*value++ == TRUE)
374 3 {//enable LBD IT
375 4 temp8 |= 0x04;
376 4 }
377 3 else
378 3 {//disable LBD IT
379 4 temp8 &= 0xFB;
380 4 }
381 3 SpiRfWriteAddressData((REG_WRITE | InterruptStatus2), temp8);
382 3 SpiRfWriteAddressData((REG_WRITE | LowBatteryDetectorThreshold), *value);
383 3 }
384 2 else
385 2 {//disable the Low Battery Detector
386 3 temp8 &= 0xBF;
387 3 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl1), temp8);
388 3 }
389 2 break;
390 2
391 2 /*
392 2 value[0] - TRUE: the sent and received data is inverted
393 2 */
394 2 case pRfDataInverted:
395 2 temp8 = SpiRfReadRegister( ModulationModeControl2 ) & 0xF7;
396 2 if( *value == TRUE )
397 2 {
398 3 temp8 |= 0x08;
399 3 }
400 2 SpiRfWriteAddressData((REG_WRITE | ModulationModeControl2), temp8);
401 2 break;
402 2
403 2 default:
404 2 return RF_ERROR_PARAMETER;
405 2 break;
406 2 }
407 1
408 1 return RF_OK;
409 1 }
410
411
412 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
413 +
414 + FUNCTION NAME: RF_ENUM RFSetRfParameters(uint8 modulation_mode, uint8 arib_mode, uint8 data_rate)
415 +
416 + DESCRIPTION: this function configures the RF part of the chip (both TX and RX)
417 + for different (predefined) data rate, deviation and modulation index
418 + requirements.
419 + The available settings can be find in the global_canstans.c file
420 +
421 + RETURN: RF_OK: the operation was succesfull
422 + RF_ERROR_PARAMETER: invalid parameter, the operation is ignored.
423 +
424 + NOTES:
425 +
426 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
427 RF_ENUM RFSetRfParameters(uint8 modulation_mode, uint8 arib_mode, uint8 data_rate)
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 8
428 {
429 1 uint8 ModulationModeCtrl1_reg,temp8;
430 1
431 1 if( modulation_mode == 2 )
432 1 {//OOK modulation
433 2 //check whether the input parameter valid or not
434 2 if( data_rate > (NMBR_OF_OOK_SAMPLE_SETTING - 1))
435 2 {
436 3 return RF_ERROR_PARAMETER;
437 3 }
438 2 //set the registers according the selected RF settings
439 2 SpiRfWriteAddressData((REG_WRITE | IFFilterBandwidth), OOKRfSettings[data_rate][0] );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -