1 // Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
3 // This file is part of SCSI2SD.
5 // SCSI2SD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // SCSI2SD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
18 // Library for sending packet data over a USB HID connection.
19 // Supports reassembly of packets larger than the HID packet,
27 // Maximum packet payload length. Must be large enough to support a SD sector
29 #define HIDPACKET_MAX_LEN 520
34 // The first byte of each HID packet contains the hid chunk number.
35 // High-bit indicates a final chunk.
36 // The second byte of each HID packet contains the payload length.
38 // Call this with HID bytes received. len <= USBHID_LEN
39 void hidPacket_recv(const uint8_t* bytes
, size_t len
);
41 // Returns the received packet contents, or NULL if a complete packet isn't
43 const uint8_t* hidPacket_getPacket(size_t* len
);
45 // Returns the received packet contents, or NULL if a complete packet isn't
47 const uint8_t* hidPacket_peekPacket(size_t* len
);
49 // Call this with packet data to send. len <= USBHID_LEN
50 // Overwrites any packet currently being sent.
51 void hidPacket_send(const uint8_t* bytes
, size_t len
);
53 // Returns USBHID_LEN bytes to send in the next HID packet, or
54 // NULL if there's nothing to send.
55 const uint8_t* hidPacket_getHIDBytes(uint8_t* hidBuffer
);