A memory buffer for bidirectional USB communications. More...
#include <sifteo/usb.h>
Public Member Functions | |
void | attach () |
Attach this pipe to the system. More... | |
void | detach () |
Detach all pipes from the system. More... | |
bool | read (UsbPacket &buffer) |
If a packet is available in the queue, read it. More... | |
bool | readAvailable () const |
Does this queue have at least one packet to read? | |
bool | write (const UsbPacket &buffer) |
Write one packet to the send queue, if space is available. More... | |
bool | writeAvailable () const |
Does this queue have room to write at least one packet? | |
Public Attributes | |
UsbQueue< tReceiveCapacity > | receiveQueue |
Queue for packets that have been received but not yet processed. | |
UsbQueue< tSendCapacity > | sendQueue |
Queue for packets we're waiting to send. | |
A memory buffer for bidirectional USB communications.
This is a pair of FIFO buffers which can be used for bidirectional communication over USB. When the pipe is "attached", this Base becomes available to send and receive application-specific packets over USB.
When the pipe is not attached or no pipe has been allocated, the Sifteo USB API will throw an error if application-specific packets are sent. However the USB API provides generic functionality which can be used even without a UsbPipe.
If the UsbPipe's receiveQueue is full, the Sifteo USB API will not be allowed to transmit more packets until our receiveQueue has room. Packets will not be dropped if the buffer fills up.
Some applications may desire lower-level access to the data queues we use. Those applications may access 'sendQueue' and 'receiveQueue' directly, and use the methods on those UsbQueue objects.
Applications that do not need this level of control can use the read() and write() methods on this object directly.
tSendCapacity | Capacity of the send queue in this pipe. |
tReceiveCapacity | Capacity of the receive queue in this pipe. |
|
inline |
Attach this pipe to the system.
When a pipe is "attached", the system will write incoming packets to our receiveQueue and it will be looking for transmittable packets in our sendQueue.
This buffer must stay allocated as long as it's attached to the system. If you plan on recycling or freeing this memory, make sure to detach() it first.
If there was already a different pipe attached, this one replaces it. The previous pipe is automatically detached.
This method clears the send and receive queues. Both queues will be empty when they're first attached to the system.
|
inline |
Detach all pipes from the system.
After this call, the Sifteo USB API will throw an error if application-specific packets are sent to us. The UsbPipe may be recycled or freed.
|
inline |
If a packet is available in the queue, read it.
If a packet is available, copies it to 'buffer' and returns 'true'. If no packets are waiting, returns 'false'.
|
inline |
Write one packet to the send queue, if space is available.
This copies the provided packet into our send queue and returns 'true' if space is available. If the queue is full, returns 'false'.
For more detailed control over the queue, see the methods on our 'sendQueue' member.
Sifteo SDK v1.1.0 (see all versions)
Last updated Tue Dec 23 2014, by Doxygen