-/*----------------------------------------------------------------------------\r
- * Name: vcomdemo.c\r
- * Purpose: USB virtual COM port Demo\r
- * Version: V1.20\r
- *----------------------------------------------------------------------------\r
- * This software is supplied "AS IS" without any warranties, express,\r
- * implied or statutory, including but not limited to the implied\r
- * warranties of fitness for purpose, satisfactory quality and\r
- * noninfringement. Keil extends you a royalty-free right to reproduce\r
- * and distribute executable files created using this software for use\r
- * on NXP Semiconductors LPC microcontroller devices only. Nothing else\r
- * gives you the right to use this software.\r
- *\r
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.\r
- *---------------------------------------------------------------------------*/\r
-\r
-#include "../LPC17xx.h"\r
-#include "lpc_types.h"\r
-\r
-#include "usb.h"\r
-#include "usbcfg.h"\r
-#include "usbhw.h"\r
-#include "usbcore.h"\r
-#include "cdc.h"\r
-#include "cdcuser.h"\r
-#include "serial.h"\r
-#include "vcomdemo.h"\r
-\r
-/* Example group ----------------------------------------------------------- */\r
-/** @defgroup USBDEV_USBCDC USBCDC\r
- * @ingroup USBDEV_Examples\r
- * @{\r
- */\r
-\r
-/*----------------------------------------------------------------------------\r
- Initialises the VCOM port.\r
- Call this function before using VCOM_putchar or VCOM_getchar\r
- *---------------------------------------------------------------------------*/\r
-void VCOM_Init(void) {\r
-#if PORT_NUM\r
- CDC_Init (1);\r
-#else\r
- CDC_Init (0);\r
-#endif\r
-}\r
-\r
-\r
-/*----------------------------------------------------------------------------\r
- Reads character from serial port buffer and writes to USB buffer\r
- *---------------------------------------------------------------------------*/\r
-void VCOM_Serial2Usb(void) {\r
- static char serBuf [USB_CDC_BUFSIZE];\r
- int numBytesRead, numAvailByte;\r
-\r
- ser_AvailChar (&numAvailByte);\r
- if (numAvailByte > 0) {\r
- if (CDC_DepInEmpty) {\r
- numBytesRead = ser_Read (&serBuf[0], &numAvailByte);\r
-\r
- CDC_DepInEmpty = 0;\r
- USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead);\r
- }\r
- }\r
-\r
-}\r
-\r
-/*----------------------------------------------------------------------------\r
- Reads character from USB buffer and writes to serial port buffer\r
- *---------------------------------------------------------------------------*/\r
-void VCOM_Usb2Serial(void) {\r
- static char serBuf [32];\r
- int numBytesToRead, numBytesRead, numAvailByte;\r
-\r
- CDC_OutBufAvailChar (&numAvailByte);\r
- if (numAvailByte > 0) {\r
- numBytesToRead = numAvailByte > 32 ? 32 : numAvailByte;\r
- numBytesRead = CDC_RdOutBuf (&serBuf[0], &numBytesToRead);\r
-#if PORT_NUM\r
- ser_Write (1, &serBuf[0], &numBytesRead);\r
-#else\r
- ser_Write (0, &serBuf[0], &numBytesRead);\r
-#endif\r
- }\r
-\r
-}\r
-\r
-\r
-/*----------------------------------------------------------------------------\r
- checks the serial state and initiates notification\r
- *---------------------------------------------------------------------------*/\r
-void VCOM_CheckSerialState (void) {\r
- unsigned short temp;\r
- static unsigned short serialState;\r
-\r
- temp = CDC_GetSerialState();\r
- if (serialState != temp) {\r
- serialState = temp;\r
- CDC_NotificationIn(); // send SERIAL_STATE notification\r
- }\r
-}\r
-\r
-/*----------------------------------------------------------------------------\r
- Main Program\r
- *---------------------------------------------------------------------------*/\r
-int main (void) {\r
- SystemInit();\r
-\r
- VCOM_Init(); // VCOM Initialization\r
-\r
- USB_Init(); // USB Initialization\r
- USB_Connect(TRUE); // USB Connect\r
-\r
- while (!USB_Configuration) ; // wait until USB is configured\r
-\r
- while (1) { // Loop forever\r
- VCOM_Serial2Usb(); // read serial port and initiate USB event\r
- VCOM_CheckSerialState();\r
- VCOM_Usb2Serial();\r
- } // end while\r
-} // end main ()\r
-\r
-/*\r
- * @}\r
- */\r
+/*----------------------------------------------------------------------------
+ * Name: vcomdemo.c
+ * Purpose: USB virtual COM port Demo
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ * This software is supplied "AS IS" without any warranties, express,
+ * implied or statutory, including but not limited to the implied
+ * warranties of fitness for purpose, satisfactory quality and
+ * noninfringement. Keil extends you a royalty-free right to reproduce
+ * and distribute executable files created using this software for use
+ * on NXP Semiconductors LPC microcontroller devices only. Nothing else
+ * gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *---------------------------------------------------------------------------*/
+
+#include <board.h>
+#include "lpc_types.h"
+
+#include "usb.h"
+#include "cfg.h"
+#include "hw.h"
+#include "core.h"
+#include "cdc.h"
+#include "cdcuser.h"
+#include "serial.h"
+#include "vcom.h"
+
+/* Example group ----------------------------------------------------------- */
+/** @defgroup USBDEV_USBCDC USBCDC
+ * @ingroup USBDEV_Examples
+ * @{
+ */
+
+/*----------------------------------------------------------------------------
+ Initialises the VCOM port.
+ Call this function before using VCOM_putchar or VCOM_getchar
+ *---------------------------------------------------------------------------*/
+void VCOM_Init(void) {
+#if PORT_NUM
+ CDC_Init (1);
+#else
+ CDC_Init (0);
+#endif
+}
+
+
+/*----------------------------------------------------------------------------
+ Reads character from serial port buffer and writes to USB buffer
+ *---------------------------------------------------------------------------*/
+void VCOM_Serial2Usb(void) {
+ static char serBuf [USB_CDC_BUFSIZE];
+ int numBytesRead, numAvailByte;
+
+ ser_AvailChar (&numAvailByte);
+ if (numAvailByte > 0) {
+ if (CDC_DepInEmpty) {
+ numBytesRead = ser_Read (&serBuf[0], &numAvailByte);
+
+ CDC_DepInEmpty = 0;
+ USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead);
+ }
+ }
+
+}
+
+/*----------------------------------------------------------------------------
+ Reads character from USB buffer and writes to serial port buffer
+ *---------------------------------------------------------------------------*/
+void VCOM_Usb2Serial(void) {
+ static char serBuf [32];
+ int numBytesToRead, numBytesRead, numAvailByte;
+
+ CDC_OutBufAvailChar (&numAvailByte);
+ if (numAvailByte > 0) {
+ numBytesToRead = numAvailByte > 32 ? 32 : numAvailByte;
+ numBytesRead = CDC_RdOutBuf (&serBuf[0], &numBytesToRead);
+#if PORT_NUM
+ ser_Write (1, &serBuf[0], &numBytesRead);
+#else
+ ser_Write (0, &serBuf[0], &numBytesRead);
+#endif
+ }
+
+}
+
+
+/*----------------------------------------------------------------------------
+ checks the serial state and initiates notification
+ *---------------------------------------------------------------------------*/
+void VCOM_CheckSerialState (void) {
+ unsigned short temp;
+ static unsigned short serialState;
+
+ temp = CDC_GetSerialState();
+ if (serialState != temp) {
+ serialState = temp;
+ CDC_NotificationIn(); // send SERIAL_STATE notification
+ }
+}
+
+/*
+ * @}
+ */