📄 nrf905_reference_firmware.lst
字号:
178 3 MOSI=0;
179 3 }
180 2 else
181 2 {
182 3 MOSI=1;
183 3 }
184 2 SCK=1;
185 2 j>>=1;
186 2 SCK=0;
187 2 }
188 1 }
189 /**********************************************************************************/
190
191 /***********************************************************************************
192 * function: read_spi_one_byte()
193 * use:
194 * input parameter:
195 * output parameter:
196 ***********************************************************************************/
197
198 unsigned char read_spi_one_byte(void)
199 {
200 1 unsigned char j;
201 1 unsigned char data_buf;
202 1
203 1 j=0x80;
204 1 while(j>0)
205 1 {
206 2 data_buf<<=1;
207 2 if(MISO==0)
208 2 {
209 3 data_buf&=0xfe;
210 3 }
211 2 else
212 2 {
213 3 data_buf|=0x01;
214 3 }
215 2 SCK=1;
216 2 j>>=1;
217 2 SCK=0;
218 2 }
219 1 return data_buf;
220 1 }
221 /**********************************************************************************/
222
223 /***********************************************************************************
224 * function: write_config()
225 * use:
226 * input parameter:
227 * output parameter:
228 ***********************************************************************************/
229
230 void write_config()
231 {
232 1 unsigned char i;
233 1 CSN=0;
234 1 write_spi_one_byte(0x00);
235 1 i=0;
236 1 for(i=0;i<10;i++)
237 1 {
238 2 write_spi_one_byte(config_reg_buf[i]);
239 2 }
C51 COMPILER V8.02 NRF905_REFERENCE_FIRMWARE 05/12/2006 12:50:33 PAGE 5
240 1 CSN=1;
241 1 }
242 /**********************************************************************************/
243
244 /***********************************************************************************
245 * function: read_config()
246 * use:
247 * input parameter:
248 * output parameter:
249 ***********************************************************************************/
250 /*
251 void read_config()
252 {
253 unsigned char i;
254 CSN=0;
255 write_spi_one_byte(0x20);//0b00010000
256 i=0;
257 for(i=0;i<10;i++)
258 {
259 xxx[i]=read_spi_one_byte();
260 }
261 CSN=1;
262 }
263 /**********************************************************************************/
264
265 /***********************************************************************************
266 * function: write_tx_payload()
267 * use:
268 * input parameter:
269 * output parameter:
270 ***********************************************************************************/
271
272 void write_tx_payload(unsigned char tx_payload_bytes_num)
273 {
274 1 CSN=0;
275 1 write_spi_one_byte(0x20);//0b00100000
276 1 while(tx_payload_bytes_num--)
277 1 {
278 2 write_spi_one_byte(tx_data_buf[0]);
279 2 }
280 1 write_spi_one_byte(tx_data_buf[1]);
281 1 write_spi_one_byte(tx_data_buf[2]);
282 1 CSN=1;
283 1 }
284 /**********************************************************************************/
285
286 /***********************************************************************************
287 * function: read_tx_payload()
288 * use:
289 * input parameter:
290 * output parameter:
291 ***********************************************************************************/
292 /*
293 void read_tx_payload(unsigned char tx_payload_bytes_num)
294 {
295 unsigned char i;
296 CSN=0;
297 write_spi_one_byte(0x21);0b00100001
298 i=0;
299 while(tx_payload_bytes_num--)
300 {
301 tx_data_buf[i]=read_spi_one_byte();
C51 COMPILER V8.02 NRF905_REFERENCE_FIRMWARE 05/12/2006 12:50:33 PAGE 6
302 i++;
303 }
304 CSN=1;
305 }
306 /**********************************************************************************/
307
308 /***********************************************************************************
309 * function: write_tx_address()
310 * use:
311 * input parameter:
312 * output parameter:
313 ***********************************************************************************/
314
315 void write_tx_address(unsigned char tx_address_bytes_num)
316 {
317 1 unsigned char i;
318 1 CSN=0;
319 1 write_spi_one_byte(0x22);//0b00100010
320 1 i=0;
321 1 while(tx_address_bytes_num--)
322 1 {
323 2 write_spi_one_byte(tx_address_reg_buf[i]);
324 2 i++;
325 2 }
326 1 CSN=1;
327 1 }
328 /**********************************************************************************/
329
330 /***********************************************************************************
331 * function: read_tx_address()
332 * use:
333 * input parameter:
334 * output parameter:
335 ***********************************************************************************/
336 /*
337 void read_tx_address(unsigned char tx_address_bytes_num)
338 {
339 unsigned char i;
340 CSN=0;
341 write_spi_one_byte(0x23);//0b00100011
342 i=0;
343 while(tx_address_bytes_num--)
344 {
345 tx_address_buf[i]=write_spi_one_byte();
346 i++;
347 }
348 CSN=1;
349 }
350 /**********************************************************************************/
351
352 /***********************************************************************************
353 * function: read_rx_payload()
354 * use:
355 * input parameter:
356 * output parameter:
357 ***********************************************************************************/
358
359 void read_rx_payload(unsigned char rx_payload_bytes_num)
360 {
361 1 unsigned char i;
362 1 CSN=0;
363 1 write_spi_one_byte(0x24);//0b00100100
C51 COMPILER V8.02 NRF905_REFERENCE_FIRMWARE 05/12/2006 12:50:33 PAGE 7
364 1 i=0;
365 1 while(rx_payload_bytes_num--)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -