Specifications

Designer Reference Manual USB08 Evaluation Board
110 Source Code Files MOTOROLA
Source Code Files
// handle IN Packet Transmit complete over EP1
//
void handleIN1() {
uchar n;
uchar *dest;
UCR1 &= ~BM_TX1E; // Deactivate EP1 Transmitter
UIR2 = BM_TXD1FR; // Reset EP1 Transmit complete Flag
// refill EP1 Tx Data Buffer
n = 0;
dest = &UE1D0;
while((TxBuf_RdIdx != TxBuf_WrIdx) && n<8) {
*dest = TxBuffer[TxBuf_RdIdx];
TxBuf_RdIdx = (TxBuf_RdIdx+1) & (MAX_TXBUF_SIZE-1);
dest++;
n++;
}
// Activate EP1 Transmitter to send n Bytes
UCR1 = ((UCR1^BM_T1SEQ) & BM_T1SEQ) + BM_TX1E + n;
}
//----------------------------------------------------------------------------
// handle OUT Packet received over EP2
//
void handleOUT2() {
uchar n;
uchar newIdx;
uchar *src;
UCR2 &= ~BM_RX2E; // Deactivate EP2 Receiver
UIR2 = BM_RXD2FR; // Reset EP2 Receive Flag
// ### Senders DATA Toggle should be checked!
// read out EP2 Rx Data Buffer
src = &UE2D0;
n = USR1 & BM_RP2SIZ; // Check Transfer Size
while(n) {
newIdx = (RxBuf_WrIdx+1) & (MAX_RXBUF_SIZE-1);
while(newIdx == RxBuf_RdIdx)
; // wait if TxBuffer is full
RxBuffer[RxBuf_WrIdx] = *src;
RxBuf_WrIdx = newIdx;
src++;
n--;
}
UCR2 = BM_RX2E; // Activate EP2 Receiver
}
//----------------------------------------------------------------------------
Frees
cale Semiconductor,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...