LPCOpen Platform
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  } Config;
110  struct
111  {
112  struct
113  {
114  uint16_t HostToDevice;
117  uint16_t DeviceToHost;
121  } ControlLineStates;
127  } State;
131 
132  /* Function Prototypes: */
133 
143 
152 
161 
172 
185 
194  void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
195  const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);
196 
211  uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
212  const char* const Buffer,
213  const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
214 
228  uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
229  const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
230 
244  uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
245  const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
246 
259  uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
260 
273  int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
274 
284  uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
285 
298  void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
299  #if (!defined(__IAR_SYSTEMS_ICC__) || (_DLIB_FILE_DESCRIPTOR == 1))
300 
320  void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
321  FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
322 
333  void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
334  FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
335  #endif /* IAR DLIB check */
336 
337  /* Private Interface - For use in library only: */
338  #if !defined(__DOXYGEN__)
339  /* Function Prototypes: */
340  #if defined(__INCLUDE_FROM_CDC_DEVICE_C)
341  #if defined(FDEV_SETUP_STREAM)
342  static int CDC_Device_putchar(char c,
343  FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
344  static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
345  static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
346  #endif
347 
348  void CDC_Device_Event_Stub(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_CONST;
349  void CDC_Device_Event_Stub2(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Duration) ATTR_CONST;
350 
353  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);
355  void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
356  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);
358  void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
359  const uint8_t Duration) ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1)
361  #endif
362 
363  #endif
364 
365  /* Disable C linkage for C++ Compilers: */
366  #if defined(__cplusplus)
367  }
368  #endif
369 
370 #endif
371