| 25 | } |
| 26 | |
| 27 | void packetHandler(int packetID, int readlength) |
| 28 | { |
| 29 | static char data[4096]; |
| 30 | // static int bytesRead = 0; // Not used |
| 31 | |
| 32 | // Wifi_RxRawReadPacket: Allows user code to read a packet from within the WifiPacketHandler function |
| 33 | // long packetID: a non-unique identifier which locates the packet specified in the internal buffer |
| 34 | // long readlength: number of bytes to read (actually reads (number+1)&~1 bytes) |
| 35 | // unsigned short * data: location for the data to be read into |
| 36 | |
| 37 | // bytesRead = Wifi_RxRawReadPacket(packetID, readlength, (unsigned short *)data); // Not used |
| 38 | Wifi_RxRawReadPacket(packetID, readlength, (unsigned short *)data); |
| 39 | |
| 40 | // Check this is the right kind of packet |
| 41 | if (data[32] == 'Y' && data[33] == 'O') { |
| 42 | u8 command = data[34]; |
| 43 | u8 val = data[35]; |
| 44 | int sendid = *((int*)(data+36)); |
| 45 | |
| 46 | if (lastSendid == sendid) { |
| 47 | if (!(ioRam[0x02] & 0x01)) { |
| 48 | nifiSendid--; |
| 49 | sendPacketByte(56, linkSendData); |
| 50 | nifiSendid++; |
| 51 | } |
| 52 | return; |
| 53 | } |
| 54 | lastSendid = sendid; |
| 55 | |
| 56 | if (command == 55 || command == 56) { |
| 57 | //printLog("%d: Received %x\n", ioRam[0x02]&1, val); |
| 58 | linkReceivedData = val; |
| 59 | } |
| 60 | |
| 61 | //linkReceivedData = 0; |
| 62 | switch(command) { |
| 63 | // Command sent from "internal clock" |
| 64 | case 55: |
| 65 | if (ioRam[0x02] & 0x80) { |
| 66 | // Falls through to case 56 |
| 67 | } |
| 68 | else { |
| 69 | printLog("Not ready!\n"); |
| 70 | transferWaiting = true; |
| 71 | timerStart(2, ClockDivider_64, 10000, transferWaitingTimeoutFunc); |
| 72 | break; |
| 73 | } |
| 74 | // Internal clock receives a response from external clock |
| 75 | case 56: |
| 76 | transferReady = true; |
| 77 | cyclesToExecute = -1; |
| 78 | nifiSendid++; |
| 79 | break; |
| 80 | default: |
| 81 | //printLog("Unknown packet\n"); |
| 82 | break; |
| 83 | } |
| 84 | } |
nothing calls this directly
no test coverage detected