kann mir jemand diesen code erklären:
1 | /* Send multiple byte */
|
2 | static
|
3 | void xmit_spi_multi (
|
4 | const BYTE *buff, /* Pointer to the data */
|
5 | UINT btx /* Number of bytes to send (512) */
|
6 | )
|
7 | {
|
8 | UINT n = 512;
|
9 | WORD d;
|
10 |
|
11 |
|
12 | SSPxCR0 = 0x000F; /* Select 16-bit mode */
|
13 |
|
14 | for (n = 0; n < 8; n++) { /* Push 8 frames into pipeline */
|
15 | d = *buff++;
|
16 | d = (d << 8) | *buff++;
|
17 | SSPxDR = d;
|
18 | }
|
19 | btx -= 16;
|
20 | do { /* Transmit data block */
|
21 | d = *buff++;
|
22 | d = (d << 8) | *buff++;
|
23 | while (!(SSPxSR & _BV(2))) ;
|
24 | SSPxDR; SSPxDR = d;
|
25 | } while (btx -= 2);
|
26 | for (n = 0; n < 8; n++) {
|
27 | while (!(SSPxSR & _BV(2))) ;
|
28 | SSPxDR;
|
29 | }
|
30 |
|
31 | SSPxCR0 = 0x0007; /* Select 8-bit mode */
|
32 | }
|
unverständlich ist mir:
while (!(SSPxSR & _BV(2))) ;
_BV(2) müsste RNE Receive fifo not empty sein
Warum wird nicht TNF abgefragt?
SSPxDR;
Was bewirkt dieser isolierte Registeraufruf?