📄 sppisr.lst
字号:
C51 COMPILER V7.08 SPPISR 11/25/2008 21:39:38 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE SPPISR
OBJECT MODULE PLACED IN sppISR.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE sppISR.c OMF2 BROWSE INCDIR(..\..\..\..\Include;..\..\..\..\lib;D:\KEIL\C51
-\BIN\;D:\Keil\C51\LIB\) DEFINE(FREQ433) DEBUG
line level source
1 /*****************************************************************************
2 * *
3 * ********** *
4 * ************ *
5 * *** *** *
6 * *** +++ *** *
7 * *** + + *** *
8 * *** + CHIPCON CC1010 *
9 * *** + + *** CUL - spp *
10 * *** +++ *** *
11 * *** *** *
12 * *********** *
13 * ********* *
14 * *
15 *****************************************************************************
16 * *
17 *****************************************************************************
18 * Author: JOL *
19 *****************************************************************************
20 * Revision history: *
21 * *
22 * $Log: sppISR.c,v $
23 * Revision 1.1 2002/10/14 12:27:33 tos
24 * Initial version in CVS.
25 *
26 * *
27 ****************************************************************************/
28
29 #include <chipcon/sppInternal.h>
30
31 // Internal data variable (struct)
32 SPP_INTERNAL_DATA xdata sppIntData;
33
34
35 pCBF xdata sppRFStateFunc;
36
37
38
39
40 //----------------------------------------------------------------------------
41 // MACRO: FSM_RESET()
42 //
43 // Description:
44 // Disable the RF interrupt, turn off the transceiver, and enter IDLE
45 // mode.
46 //----------------------------------------------------------------------------
47 #define FSM_RESET() \
48 do { \
49 INT_ENABLE (INUM_RF, INT_OFF); \
50 SPP_DISABLE_TIMEOUT(); \
51 sppIntData.mode = SPP_IDLE_MODE; \
52 SPP_FAST_POWER_DOWN(); \
53 } while (0)
54
C51 COMPILER V7.08 SPPISR 11/25/2008 21:39:38 PAGE 2
55
56
57
58 //----------------------------------------------------------------------------
59 // MACRO: FSM_RESTART_RX()
60 //
61 // Description:
62 // Restarts reception by resetting the preamble detection and
63 // average filter. The next state is RX_WAIT.
64 //----------------------------------------------------------------------------
65 #define FSM_RESTART_RX() \
66 do { \
67 MODEM1 &= ~0x10; \
68 PDET &= ~0x80; \
69 PDET |= 0x80; \
70 sppRFStateFunc = RX_WAIT; \
71 sppIntData.pRXI->status = SPP_RX_WAITING; \
72 } while (0)
73
74
75
76
77 //----------------------------------------------------------------------------
78 // MACRO: fsmTryRestartTx()
79 //
80 // Description:
81 // If no valid TX ack is received, this macro will be called from
82 // either the fsm (rf interrupt) or the timeout function (t3 interrupt).
83 //----------------------------------------------------------------------------
84 #define FSM_TRY_RESTART_TX() \
85 do { \
86 if (sppIntData.usedTxAttempts == sppSettings.txAttempts) { \
87 FSM_RESET(); \
88 } else { \
89 sppRFStateFunc = TX_START; \
90 SPP_FAST_POWER_UP_TX(); \
91 } \
92 } while (0)
93
94
95
96
97 //----------------------------------------------------------------------------
98 // TX FUNCTIONS
99 //----------------------------------------------------------------------------
100 void TX_START (void) {
101 1 sppIntData.mode = SPP_TX_MODE;
102 1 sppIntData.pTXI->status = SPP_TX_TRANSMITTING;
103 1 sppIntData.counter = sppSettings.txPreambleByteCount - 1;
104 1 sppIntData.usedTxAttempts++;
105 1 RF_SEND_BYTE (RF_PREAMBLE_BYTE);
106 1 sppRFStateFunc = TX_PREAMBLE;
107 1 }
108
109 void TX_PREAMBLE (void) {
110 1 RF_SEND_BYTE (RF_PREAMBLE_BYTE);
111 1 if (!--sppIntData.counter) {
112 2 sppRFStateFunc = TX_SYNC;
113 2 }
114 1 }
115
116 void TX_SYNC (void) {
C51 COMPILER V7.08 SPPISR 11/25/2008 21:39:38 PAGE 3
117 1 RF_SEND_BYTE (RF_SUITABLE_SYNC_BYTE);
118 1 sppRFStateFunc = TX_DAB;
119 1 }
120
121 void TX_DAB (void) {
122 1 RF_SEND_BYTE (sppIntData.pTXI->destination);
123 1 FAST_CRC8_INIT(sppIntData.crc8);
124 1 FAST_CRC8(sppIntData.pTXI->destination, sppIntData.crc8);
125 1 sppRFStateFunc = TX_SAB;
126 1 }
127
128 void TX_SAB (void) {
129 1 RF_SEND_BYTE (sppSettings.myAddress);
130 1 FAST_CRC8(sppSettings.myAddress, sppIntData.crc8);
131 1 sppRFStateFunc = TX_DATA_LEN;
132 1 }
133
134 void TX_DATA_LEN (void) {
135 1 RF_SEND_BYTE (sppIntData.pTXI->dataLen);
136 1 FAST_CRC8(sppIntData.pTXI->dataLen, sppIntData.crc8);
137 1 sppRFStateFunc = TX_FLAG;
138 1 }
139
140 void TX_FLAG (void) {
141 1 RF_SEND_BYTE (sppIntData.pTXI->flags);
142 1 FAST_CRC8(sppIntData.pTXI->flags, sppIntData.crc8);
143 1 sppRFStateFunc = TX_CRC8;
144 1 }
145
146 void TX_CRC8 (void) {
147 1 RF_SEND_BYTE (sppIntData.crc8);
148 1 if (!sppIntData.pTXI->dataLen) {
149 2 sppRFStateFunc = TX_ZEROPAD_START;
150 2 } else {
151 2 sppRFStateFunc = TX_DBX_START;
152 2 }
153 1 }
154
155 void TX_DBX_START (void) {
156 1 sppIntData.counter = 0;
157 1 sppRFStateFunc = TX_DBX;
158 1 RF_SEND_BYTE (sppIntData.pTXI->pDataBuffer[sppIntData.counter]);
159 1 FAST_CRC16_INIT(sppIntData.crc16);
160 1 FAST_CRC16(sppIntData.pTXI->pDataBuffer[sppIntData.counter], sppIntData.crc16);
161 1 if (++sppIntData.counter == sppIntData.pTXI->dataLen) {
162 2 sppRFStateFunc = TX_CRC16_DATA_H;
163 2 }
164 1 }
165
166 void TX_DBX (void) {
167 1 RF_SEND_BYTE (sppIntData.pTXI->pDataBuffer[sppIntData.counter]);
168 1 FAST_CRC16(sppIntData.pTXI->pDataBuffer[sppIntData.counter], sppIntData.crc16);
169 1 if (++sppIntData.counter == sppIntData.pTXI->dataLen) {
170 2 sppRFStateFunc = TX_CRC16_DATA_H;
171 2 }
172 1 }
173
174 void TX_CRC16_DATA_H (void) {
175 1 RF_SEND_BYTE (sppIntData.crc16 >> 8);
176 1 sppRFStateFunc = TX_CRC16_DATA_L;
177 1 }
178
C51 COMPILER V7.08 SPPISR 11/25/2008 21:39:38 PAGE 4
179 void TX_CRC16_DATA_L (void) {
180 1 RF_SEND_BYTE (sppIntData.crc16 & 0xFF);
181 1 sppRFStateFunc = TX_ZEROPAD_START;
182 1 }
183
184 void TX_ZEROPAD_START (void) {
185 1 sppIntData.counter = SPP_ZEROPAD_COUNT - 1;
186 1 RF_SEND_BYTE (0);
187 1 sppRFStateFunc = TX_ZEROPAD;
188 1 }
189
190 void TX_ZEROPAD (void) {
191 1 RF_SEND_BYTE (0);
192 1 if (!--sppIntData.counter) {
193 2 if (sppIntData.pTXI->flags & SPP_ACK_REQ) {
194 3 sppRFStateFunc = TXACK_START;
195 3 } else {
196 3 sppIntData.pTXI->flags ^= SPP_SEQUENCE_BIT; // Toggle the packet sequence number bit
197 3 sppIntData.pTXI->status = SPP_TX_FINISHED;
198 3 FSM_RESET();
199 3 }
200 2 }
201 1 }
202
203
204
205
206 //----------------------------------------------------------------------------
207 // TXACK FUNCTIONS
208 //----------------------------------------------------------------------------
209 void TXACK_START (void) {
210 1 sppIntData.mode = SPP_TXACK_MODE;
211 1 SPP_ENABLE_TIMEOUT(sppSettings.txAckTimeout);
212 1 SPP_FAST_POWER_UP_RX();
213 1 sppIntData.pTXI->status = SPP_TX_WAITING_FOR_ACK;
214 1 sppRFStateFunc = TXACK_WAIT;
215 1 }
216
217 void TXACK_WAIT (void) {
218 1 // Drop the sync byte
219 1 RF_LOCK_AVERAGE_FILTER(TRUE);
220 1 SPP_DISABLE_TIMEOUT();
221 1 sppRFStateFunc = TXACK_DAB;
222 1 }
223
224 void TXACK_DAB (void) {
225 1 if (RF_RECEIVE_BYTE() == sppSettings.myAddress) {
226 2 FAST_CRC8_INIT(sppIntData.crc8);
227 2 FAST_CRC8(RF_RECEIVE_BYTE(), sppIntData.crc8);
228 2 sppRFStateFunc = TXACK_SAB;
229 2 } else {
230 2 sppIntData.pTXI->status = SPP_TX_ACK_INVALID;
231 2 FSM_TRY_RESTART_TX();
232 2 }
233 1 }
234
235 void TXACK_SAB (void) {
236 1 if (RF_RECEIVE_BYTE() == sppIntData.pTXI->destination) {
237 2 FAST_CRC8(RF_RECEIVE_BYTE(), sppIntData.crc8);
238 2 sppRFStateFunc = TXACK_DATA_LEN;
239 2 } else {
240 2 sppIntData.pTXI->status = SPP_TX_ACK_INVALID;
C51 COMPILER V7.08 SPPISR 11/25/2008 21:39:38 PAGE 5
241 2 FSM_TRY_RESTART_TX();
242 2 }
243 1 }
244
245 void TXACK_DATA_LEN (void) {
246 1 FAST_CRC8(RF_RECEIVE_BYTE(), sppIntData.crc8);
247 1 sppRFStateFunc = TXACK_FLAG;
248 1 }
249
250 void TXACK_FLAG (void) {
251 1 if (RF_RECEIVE_BYTE() & SPP_ACK) {
252 2 FAST_CRC8(RF_RECEIVE_BYTE(), sppIntData.crc8);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -