LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CDCClassDevice.h
Go to the documentation of this file.
1 /*
2  * @brief Device mode driver for the library USB CDC Class driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * Copyright(C) Dean Camera, 2011, 2012
7  * All rights reserved.
8  *
9  * @par
10  * Software that is described herein is for illustrative purposes only
11  * which provides customers with programming information regarding the
12  * LPC products. This software is supplied "AS IS" without any warranties of
13  * any kind, and NXP Semiconductors and its licensor disclaim any and
14  * all warranties, express or implied, including all implied warranties of
15  * merchantability, fitness for a particular purpose and non-infringement of
16  * intellectual property rights. NXP Semiconductors assumes no responsibility
17  * or liability for the use of the software, conveys no license or rights under any
18  * patent, copyright, mask work right, or any other intellectual property rights in
19  * or to any products. NXP Semiconductors reserves the right to make changes
20  * in the software without notification. NXP Semiconductors also makes no
21  * representation or warranty that such application will be suitable for the
22  * specified use without further testing or modification.
23  *
24  * @par
25  * Permission to use, copy, modify, and distribute this software and its
26  * documentation is hereby granted, under NXP Semiconductors' and its
27  * licensor's relevant copyrights in the software, without fee, provided that it
28  * is used in conjunction with NXP Semiconductors microcontrollers. This
29  * copyright, permission, and disclaimer notice must appear in all copies of
30  * this code.
31  */
32 
63 #ifndef _CDC_CLASS_DEVICE_H_
64 #define _CDC_CLASS_DEVICE_H_
65 
66  /* Includes: */
67  #include "../../USB.h"
68  #include "../Common/CDCClassCommon.h"
69 
70  #include <stdio.h>
71 
72  /* Enable C linkage for C++ Compilers: */
73  #if defined(__cplusplus)
74  extern "C" {
75  #endif
76 
77  /* Preprocessor Checks: */
78  #if !defined(__INCLUDE_FROM_CDC_DRIVER)
79  #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.
80  #endif
81 
82  /* Public Interface - May be used in end-application: */
83  /* Type Defines: */
90  typedef struct
91  {
92  const struct
93  {
97  uint16_t DataINEndpointSize;
107  uint8_t PortNumber;
108  } Config;
111  struct
112  {
113  struct
114  {
115  uint16_t HostToDevice;
118  uint16_t DeviceToHost;
122  } ControlLineStates;
128  } State;
132 
133  /* Function Prototypes: */
134 
144 
153 
162 
173 
186 
195  void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
196  const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);
197 
212  uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
213  const char* const Buffer,
214  const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
215 
229  uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
230  const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
231 
245  uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
246  const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
247 
260  uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
261 
274  int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
275 
285  uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
286 
299  void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
300  #if (!defined(__IAR_SYSTEMS_ICC__) || (_DLIB_FILE_DESCRIPTOR == 1))
301 
321  void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
322  FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
323 
334  void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
335  FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
336  #endif /* IAR DLIB check */
337 
338  /* Private Interface - For use in library only: */
339  #if !defined(__DOXYGEN__)
340  /* Function Prototypes: */
341  #if defined(__INCLUDE_FROM_CDC_DEVICE_C)
342  #if defined(FDEV_SETUP_STREAM)
343  static int CDC_Device_putchar(char c,
344  FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
345  static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
346  static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
347  #endif
348 
349  void CDC_Device_Event_Stub(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_CONST;
350  void CDC_Device_Event_Stub2(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Duration) ATTR_CONST;
351 
354  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);
356  void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
357  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);
359  void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
360  const uint8_t Duration) ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1)
362  #endif
363 
364  #endif
365 
366  /* Disable C linkage for C++ Compilers: */
367  #if defined(__cplusplus)
368  }
369  #endif
370 
371 #endif
372