8 # error This is a userspace-only header, not allowed by the current build.
11 #include <sifteo/abi.h>
52 return _SYS_usb_isConnected();
68 operator _SYSUsbPacket* () {
return &sys; }
69 operator const _SYSUsbPacket* ()
const {
return &sys; }
73 return _SYS_USB_PACKET_BYTES;
102 const uint8_t *
bytes()
const {
113 ASSERT(type <= 0xfffffff);
138 template <
unsigned tCapacity >
142 _SYSIoQueueHeader header;
145 _SYSUsbPacket packets[tCapacity + 1];
149 operator _SYSUsbQueue* () {
return reinterpret_cast<_SYSUsbQueue*
>(&sys); }
150 operator const _SYSUsbQueue* ()
const {
return reinterpret_cast<const _SYSUsbQueue*
>(&sys); }
152 unsigned capacity()
const {
159 unsigned lastIndex = tCapacity;
165 sys.header32 = lastIndex << 16;
167 ASSERT(sys.header.head == 0);
168 ASSERT(sys.header.tail == 0);
169 ASSERT(sys.header.last == lastIndex);
174 unsigned size = tCapacity + 1;
175 return (sys.header.tail + 1) % size == sys.header.head;
180 return sys.header.tail == sys.header.head;
213 unsigned head = sys.header.head;
214 ASSERT(head <= tCapacity);
215 return *
reinterpret_cast<const UsbPacket *
>(&sys.packets[head]);
227 unsigned head = sys.header.head + 1;
228 if (head > tCapacity)
230 sys.header.head = head;
264 unsigned tail = sys.header.tail;
265 ASSERT(tail <= tCapacity);
266 return *
reinterpret_cast<UsbPacket *
>(&sys.packets[tail]);
278 unsigned tail = sys.header.tail + 1;
279 if (tail > tCapacity)
281 sys.header.tail = tail;
294 _SYS_usb_queueWriteHint();
327 template <
unsigned tSendCapacity = 4,
unsigned tReceiveCapacity = 4 >
367 _SYS_usb_setPipe(0, 0);
430 _SYSUsbCounters current;
431 _SYSUsbCounters base;
440 _SYS_usb_counters(&base,
sizeof base);
447 _SYS_usb_counters(¤t,
sizeof current);
452 return current.rxPackets - base.rxPackets;
457 return current.txPackets - base.txPackets;
462 return current.rxBytes - base.rxBytes;
467 return current.txBytes - base.txBytes;
478 return current.rxUserDropped - base.rxUserDropped;