Beispiel #1
0
//	Space in send EP
u8 USB_SendSpace(u8 ep)
{
	LockEP lock(ep);
	if (!ReadWriteAllowed())
		return 0;
	return 64 - FifoByteCount();
}
Beispiel #2
0
void 
USB_Flush(uint8_t ep)
{
  SetEP(ep);
  if (FifoByteCount())
    ReleaseTX();
}
Beispiel #3
0
uint8_t 
USB_SendSpace(uint8_t ep)
{
  LockEP lock(ep);
  if (!ReadWriteAllowed()) return (0);
  return (64 - FifoByteCount());
}
Beispiel #4
0
int 
USB_Recv(uint8_t ep, void* d, int len)
{
  if (!_usbConfiguration || len < 0) return (-1);
	
  LockEP lock(ep);
  uint8_t n = FifoByteCount();
  len = min(n,len);
  n = len;
  uint8_t* dst = (uint8_t*)d;
  while (n--)
    *dst++ = Recv8();
  if (len && !FifoByteCount())
    ReleaseRX();
  return (len);
}
Beispiel #5
0
//	Non Blocking receive
//	Return number of bytes read
int USB_Recv(u8 ep, void* d, int len)
{
	if (!_usbConfiguration || len < 0)
		return -1;
	
	LockEP lock(ep);
	u8 n = FifoByteCount();
	len = min(n,len);
	n = len;
	u8* dst = (u8*)d;
	while (n--)
		*dst++ = Recv8();
	if (len && !FifoByteCount())	// release empty buffer
		ReleaseRX();
	
	return len;
}
Beispiel #6
0
//	Space in send EP
u8 USB_SendSpace(u8 ep)
{
	LockEP lock(ep);
	if (!ReadWriteAllowed())
		return 0;
	// subtract 1 from the EP size to never send a full packet,
	// this avoids dealing with ZLP's in USB_Send
	return USB_EP_SIZE - 1 - FifoByteCount();
}
Beispiel #7
0
//	Space in send EP
uint8_t USBD_SendSpace(uint8_t ep)
{
	SetEP(ep);
	if (!ReadWriteAllowed())
  {
		return 0;
  }

	return 64 - FifoByteCount();
}
Beispiel #8
0
//	Number of bytes, assumes a rx endpoint
u8 USB_Available(u8 ep)
{
	LockEP lock(ep);
	return FifoByteCount();
}
Beispiel #9
0
//	Number of bytes, assumes a rx endpoint
uint8_t USBD_Available(uint8_t ep)
{
	SetEP(ep);

	return FifoByteCount();
}
Beispiel #10
0
uint8_t 
USB_Available(uint8_t ep)
{
  LockEP lock(ep);
  return (FifoByteCount());
}