//************************************************************* // // Send a string to the UART. // //************************************************************* void UARTSend(uint32_t ui32Base, const uint8_t *pui8Buffer, uint32_t ui32Count) { // // Loop while there are more characters to send. // while(ui32Count--) { // // Write the next character to the UART. // ROM_UARTCharPutNonBlocking(ui32Base, *pui8Buffer++); while (ROM_UARTBusy(ui32Base)); } }
//***************************************************************************** // // Handles CDC driver notifications related to the receive channel (data from // the USB host). // // \param ui32CBData is the client-supplied callback data value for this channel. // \param ui32Event identifies the event we are being notified about. // \param ui32MsgValue is an event-specific value. // \param pvMsgData is an event-specific pointer. // // This function is called by the CDC driver to notify us of any events // related to operation of the receive data channel (the OUT channel carrying // data from the USB host). // // \return The return value is event-specific. // //***************************************************************************** uint32_t RxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData) { uint32_t ui32Count; // Which event are we being sent? switch(ui32Event) { // A new packet has been received. case USB_EVENT_RX_AVAILABLE: { // Call the user defined RX data handler RxDataHandler(); break; } // We are being asked how much unprocessed data we have still to // process. We return 0 if the UART is currently idle or 1 if it is // in the process of transmitting something. The actual number of // bytes in the UART FIFO is not important here, merely whether or // not everything previously sent to us has been transmitted. case USB_EVENT_DATA_REMAINING: { // Get the number of bytes in the buffer and add 1 if some data // still has to clear the transmitter. ui32Count = ROM_UARTBusy(USB_UART_BASE) ? 1 : 0; return(ui32Count); } // We are being asked to provide a buffer into which the next packet // can be read. We do not support this mode of receiving data so let // the driver know by returning 0. The CDC driver should not be sending // this message but this is included just for illustration and // completeness. case USB_EVENT_REQUEST_BUFFER: { return(0); } // We don't expect to receive any other events. Ignore any that show // up in a release build or hang in a debug build. default: #ifdef DEBUG while(1); #else break; #endif } return(0); }
//***************************************************************************** // // Handles CDC driver notifications related to the receive channel (data from // the USB host). // // \param ulCBData is the client-supplied callback data value for this channel. // \param ulEvent identifies the event we are being notified about. // \param ulMsgValue is an event-specific value. // \param pvMsgData is an event-specific pointer. // // This function is called by the CDC driver to notify us of any events // related to operation of the receive data channel (the OUT channel carrying // data from the USB host). // // \return The return value is event-specific. // //***************************************************************************** unsigned long RxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgValue, void *pvMsgData) { unsigned long ulCount; // // Which event are we being sent? // switch(ulEvent) { // // A new packet has been received. // case USB_EVENT_RX_AVAILABLE: { // // Feed some characters into the UART TX FIFO and enable the // interrupt so we are told when there is more space. // USBUARTPrimeTransmit(USB_UART_BASE); ROM_UARTIntEnable(USB_UART_BASE, UART_INT_TX); break; } // // We are being asked how much unprocessed data we have still to // process. We return 0 if the UART is currently idle or 1 if it is // in the process of transmitting something. The actual number of // bytes in the UART FIFO is not important here, merely whether or // not everything previously sent to us has been transmitted. // case USB_EVENT_DATA_REMAINING: { // // Get the number of bytes in the buffer and add 1 if some data // still has to clear the transmitter. // ulCount = ROM_UARTBusy(USB_UART_BASE) ? 1 : 0; return(ulCount); } // // We are being asked to provide a buffer into which the next packet // can be read. We do not support this mode of receiving data so let // the driver know by returning 0. The CDC driver should not be sending // this message but this is included just for illustration and // completeness. // case USB_EVENT_REQUEST_BUFFER: { return(0); } // // We don't expect to receive any other events. Ignore any that show // up in a release build or hang in a debug build. // default: #ifdef DEBUG while(1); #else break; #endif } return(0); }