📄 ia443x_rf.lst
字号:
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 1
C51 COMPILER V8.00, COMPILATION OF MODULE IA443X_RF
OBJECT MODULE PLACED IN IA443x_rf.OBJ
COMPILER INVOKED BY: C:\Program Files\Keil\C51\BIN\C51.exe IA443x_rf.c DB OE BR
line level source
1 /*
2 ** ============================================================================
3 **
4 ** FILE
5 ** IA443x_rf.c
6 **
7 ** DESCRIPTION
8 ** Contains the RF dependent functions
9 **
10 ** CREATED
11 ** Silicon Laboratories Hungary Ltd
12 **
13 ** COPYRIGHT
14 ** Copyright 2008 Silicon Laboratories, Inc.
15 ** http://www.silabs.com
16 **
17 ** ============================================================================
18 */
19
20 /*------------------------------------------------------------------------*/
21 /* INCLUDE */
22 /*------------------------------------------------------------------------*/
23 #include "IA443x_rf.h"
24 #include "IA443x_rf_callback.h"
25 #include "timers.h"
26 #include "IAI_EBID.h"
27 #include "global_definitions.h"
28
29 /*------------------------------------------------------------------------*/
30 /* GLOBAL variables */
31 /*------------------------------------------------------------------------*/
32 idata RF_STATES RfState;
33 idata uint8 ItStatus1, ItStatus2, Rssi_ant1, Rssi_ant2, ByteTime;
34 bit fPacketReceived;
35 idata uint8 Tmr2SwPrescaler;
36 idata UU16 RfTimer;
37
38 extern xdata ANTENNA_TYPE SelectedAntennaType;
39 extern code uint8 GFSKRfSettings[NMBR_OF_GFSK_SAMPLE_SETTING][NMBR_OF_PARAMETER];
40 extern code uint8 OOKRfSettings[NMBR_OF_OOK_SAMPLE_SETTING][NMBR_OF_PARAMETER];
41 extern code uint8 AribRfSettings[NMBR_OF_ARIB_SAMPLE_SETTING][NMBR_OF_PARAMETER];
42
43 /*------------------------------------------------------------------------*/
44 /* LOCAL function prototypes */
45 /*------------------------------------------------------------------------*/
46 void RFStateMachine(RF_ENUM ItSource);
47 void GotoPreambleSearchState(void);
48
49 /*------------------------------------------------------------------------*/
50 /* LOCAL definitions */
51 /*------------------------------------------------------------------------*/
52 //#define RF_LED_DEBUG
53
54 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55 +
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 2
56 + FUNCTION NAME: void RfInitHw(void)
57 +
58 + DESCRIPTION: initializes the used I/O pins, SPI and timer peripherals,
59 + IT routines needed for the RF stack
60 +
61 + RETURN: None
62 +
63 + NOTES: 1.) has to be called in the power-on routine
64 + 2.) it doesn't initialize the RF chip registers
65 +
66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
67 RF_ENUM RfInitHw(void)
68 {
69 1 //initialize I/O port directions
70 1 RF_NSEL_PIN = 1;
71 1 EE_NSEL_PIN = 1;
72 1
73 1 //TMR2 is used for the RF stack
74 1 DisableTmr2It();
75 1
76 1 //set MAC EXT IT - INT0 is used for this purpose (falling edge)
77 1 SetExt0ItFallingEdge();
78 1 DisableExt0It();
79 1
80 1 //setup RF stack state machine
81 1 RfState = sRFPOR;
82 1 //release all IT flag to set IRQ high
83 1 ItStatus1 = SpiRfReadRegister(InterruptStatus1);
84 1 ItStatus2 = SpiRfReadRegister(InterruptStatus2);
85 1
86 1 //SW reset -> wait for POR interrupt
87 1 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl1), 0x80);
88 1 //timeout for POR interrupt
89 1 RfTimer.U16 = RESET_TIMEOUT;
90 1 StartTmr2(RESET_TIMEOUT_DIV,RfTimer,FALSE);
91 1 do{
92 2 }while( (Tmr2Expired() == FALSE) );
93 1 //check the status of the POR
94 1 ItStatus1 = SpiRfReadRegister( InterruptStatus1 );
95 1 ItStatus2 = SpiRfReadRegister( InterruptStatus2 );
96 1 if( (ItStatus2 & 0x03) == 0x03 )
97 1 {//POR performed correctly
98 2 //disable XTAL
99 2 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl1), 0x00);
100 2 //set RF stack state
101 2 RfState = sRFStandBy;
102 2 DisableTmr2It();
103 2 }
104 1 else
105 1 {//POR error
106 2 DisableTmr2It();
107 2 return RF_ERROR_TIMING;
108 2 }
109 1
110 1 //disable all ITs, except 'ichiprdy'
111 1 SpiRfWriteAddressData((REG_WRITE | InterruptEnable1), 0x00);
112 1 SpiRfWriteAddressData((REG_WRITE | InterruptEnable2), 0x02);
113 1 //release all IT flag to set IRQ high
114 1 ItStatus1 = SpiRfReadRegister(InterruptStatus1);
115 1 ItStatus2 = SpiRfReadRegister(InterruptStatus2);
116 1
117 1 //set the special registers (what has to be different than the POR-default)
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 3
118 1 SetSpecialRegisters();
119 1
120 1 //reset digital testbus, disable scan test
121 1 SpiRfWriteAddressData((REG_WRITE | DigitalTestBus), 0x00);
122 1 //select nothing to the Analog Testbus
123 1 SpiRfWriteAddressData((REG_WRITE | AnalogTestBus), 0x0B);
124 1
125 1 return RF_OK;
126 1 }
127
128
129 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
130 +
131 + FUNCTION NAME: RF_ENUM RFWakeUp(void)
132 +
133 + DESCRIPTION: wakes up the RF chip from STANDBY.
134 +
135 + RETURN: RF_OK: the operation was succesfull
136 + RF_ERROR_STATE: the operation is ignored, because the
137 + RF stack was not in STANDBY state.
138 +
139 + NOTES:
140 +
141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
142 RF_ENUM RFWakeUp(void)
143 {
144 1 uint8 temp8;
145 1
146 1 if( RfState != sRFStandBy )
147 1 return RF_ERROR_STATE;
148 1
149 1 //start the crystal oscillator
150 1 temp8 = SpiRfReadRegister( OperatingFunctionControl1 );
151 1 temp8 |= 0x01;
152 1 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl1), temp8);
153 1
154 1 //set RF stack state
155 1 RfState = sRFWakingUp;
156 1
157 1 //set timeout for XTAL startup
158 1 RfTimer.U16 = XTAL_WAKE_UP_PERIOD;
159 1 Tmr2SwPrescaler = XTAL_WAKE_UP_PERIOd_SW_DIV;
160 1 StartTmr2(XTAL_WAKE_UP_PERIOD_DIV,RfTimer,TRUE);
161 1 EnableExt0It();
162 1
163 1 return RF_OK;
164 1 }
165
166
167 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168 +
169 + FUNCTION NAME: RF_ENUM RFSleep(void)
170 +
171 + DESCRIPTION: sets the transceiver into STANDBY state.
172 +
173 + RETURN: RF_OK: the operation was succesfull
174 + RF_ERROR_STATE: the operation is ignored, because the
175 + RF stack was not in IDLE state.
176 +
177 + NOTES:
178 +
179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
C51 COMPILER V8.00 IA443X_RF 11/17/2008 10:50:33 PAGE 4
180 RF_ENUM RFSleep(void)
181 {
182 1 uint8 temp8;
183 1
184 1 if( RfState != sRFIdle )
185 1 return RF_ERROR_STATE;
186 1
187 1 //release all IT flag
188 1 ItStatus1 = SpiRfReadRegister( InterruptStatus1 );
189 1 ItStatus2 = SpiRfReadRegister( InterruptStatus2 );
190 1 //stop the crystal oscillator
191 1 temp8 = SpiRfReadRegister( OperatingFunctionControl1 );
192 1 temp8 &= 0xFE;
193 1 SpiRfWriteAddressData((REG_WRITE | OperatingFunctionControl1), temp8);
194 1 //set next state
195 1 RfState = sRFStandBy;
196 1
197 1 return RF_OK;
198 1 }
199
200 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
201 +
202 + FUNCTION NAME: RF_ENUM RFSetParameter(RF_PARAMETER parameter, uint8 * value, uint8 length)
203 +
204 + DESCRIPTION: sets the appropiate registers
205 +
206 + INPUT: parameter: name of the RF parameter needs to be change
207 + value: value of the parameter (it maybe more bytes)
208 + length: number of bytes of the value
209 +
210 + RETURN: RF_OK: the operation was succesfull
211 + RF_ERROR_STATE: the operation is ignored, because the
212 + RF stack was not in IDLE state.
213 + RF_ERROR_PARAMETER: the input paramter is invalid, operation is ignored
214 +
215 + NOTES:
216 +
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -