📄 s8051.lst
字号:
165 +
166 + RETURN: value of the register
167 +
168 + NOTES: it controls the nSEL pin of the radio
169 +
170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
171 uint8 SpiRfReadRegister(uint8 address)
172 {
173 1 uint8 temp8;
174 1
175 1 RF_NSEL_PIN = 0;
176 1 SpiReadWrite( address );
177 1 temp8 = SpiReadWrite( 0x00 );
178 1 RF_NSEL_PIN = 1;
179 1 return temp8;
C51 COMPILER V8.00 S8051 11/17/2008 10:50:41 PAGE 4
180 1 }
181
182 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
183 +
184 + FUNCTION NAME: uint16 SpiReadWriteAddressData(uint8 address, uint8 data1)
185 +
186 + DESCRIPTION: sends and read 16 length data through the SPI port
187 +
188 + INPUT: address - register address
189 + data - data
190 +
191 + RETURN: received word
192 +
193 + NOTES: it controls the nSEL pin
194 +
195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
196 UU16 SpiRfReadWriteAddressData(uint8 address, uint8 d)
197 {
198 1 UU16 temp16;
199 1
200 1 RF_NSEL_PIN = 0;
201 1 temp16.U8[MSB] = SpiReadWrite( address );
202 1 temp16.U8[LSB] = SpiReadWrite( d );
203 1 RF_NSEL_PIN = 1;
204 1
205 1 return temp16;
206 1 }
207
208 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
209 +
210 + FUNCTION NAME: uint8 SpiReadByteFromTestcardEEPROM(uint16 address)
211 +
212 + DESCRIPTION: read on byte from the EEPROM populated to the Testcard
213 +
214 + RETURN: value read out
215 +
216 + INPUT: address of the data in the EEPROM
217 +
218 + NOTES:
219 +
220 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
221 uint8 SpiReadByteFromTestcardEEPROM(uint16 address)
222 {
223 1 xdata uint8 temp8;
224 1
225 1 //select the EEPROM
226 1 EE_NSEL_PIN = 0;
227 1 //send instruction + address MSB
228 1 SpiWrite(0x03);
229 1 //send address upper byte
230 1 SpiWrite((uint8)(address >> 8));
231 1 //send address lower byte
232 1 SpiWrite((uint8)(address & 0x00FF));
233 1 //get data
234 1 temp8 = SpiReadWrite(0x00);
235 1 //release nSEL
236 1 EE_NSEL_PIN = 1;
237 1
238 1 return temp8;
239 1 }
240 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
241 +
C51 COMPILER V8.00 S8051 11/17/2008 10:50:41 PAGE 5
242 + FUNCTION NAME: void SpiWriteByteToTestcardEEPROM(uint16 address, uint8 d)
243 +
244 + DESCRIPTION: write one byte to the EEPROM populated on the Testcard
245 +
246 + RETURN: None
247 +
248 + INPUT: address, data
249 +
250 + NOTES:
251 +
252 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
253 void SpiWriteByteToTestcardEEPROM(uint16 address, uint8 d)
254 {
255 1 UU16 temp;
256 1
257 1 EE_NSEL_PIN = 0;
258 1 SpiWrite(0x06);
259 1 EE_NSEL_PIN = 1;
260 1
261 1 //select the EEPROM
262 1 EE_NSEL_PIN = 0;
263 1 //send instruction + address MSB
264 1 SpiWrite(0x02);
265 1 //send address upper byte
266 1 SpiWrite((uint8)(address >> 8));
267 1 //send address lower byte
268 1 SpiWrite((uint8)(address & 0x00FF));
269 1 //send data
270 1 SpiWrite(d);
271 1 //release nSEL
272 1 EE_NSEL_PIN = 1;
273 1
274 1 temp.U16 = 3334;
275 1 StartTmr3(TMR3_12, temp, FALSE); //wait 5ms after every write circule
276 1 while( Tmr3Expired() == FALSE );
277 1
278 1 EE_NSEL_PIN = 0;
279 1 SpiWrite(0x04);
280 1 EE_NSEL_PIN = 1;
281 1
282 1
283 1
284 1 }
285 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
286 +
287 + FUNCTION NAME: void SpiReadSegmentFromTestcardEEPROM(uint16 star_address, uint8 * data, uint8 length)
288 +
289 + DESCRIPTION: read a segment from the EEPROM populated to the Testcard
290 +
291 + RETURN: data stored in the place where the data pointer defined
292 +
293 + INPUT: start_address - starting address of the segment needs to be read out
294 + length - length of the segment needs to be read out
295 +
296 + NOTES:
297 +
298 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
299 void SpiReadSegmentFromTestcardEEPROM(uint16 start_address, uint8 * d, uint8 length)
300 {
301 1 xdata uint8 temp8;
302 1
303 1 //select the EEPROM
C51 COMPILER V8.00 S8051 11/17/2008 10:50:41 PAGE 6
304 1 EE_NSEL_PIN = 0;
305 1 //send instruction + address MSB
306 1 SpiWrite(0x03);
307 1 //send address upper byte
308 1 SpiWrite((uint8)(start_address >> 8));
309 1 //send address lower byte
310 1 SpiWrite((uint8)(start_address & 0x00FF));
311 1 for(temp8=0;temp8<length;temp8++)
312 1 {
313 2 //get data
314 2 *d++ = SpiReadWrite(0x00);
315 2 }
316 1 //release nSEL
317 1 EE_NSEL_PIN = 1;
318 1 }
319
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 298 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 2
PDATA SIZE = ---- ----
DATA SIZE = ---- 16
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -