LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CDCClassHost.h
Go to the documentation of this file.
1 /*
2  * @brief Host 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 
46 #ifndef __CDC_CLASS_HOST_H__
47 #define __CDC_CLASS_HOST_H__
48 
49  /* Includes: */
50  #include "../../USB.h"
51  #include "../Common/CDCClassCommon.h"
52 
53  #include <stdio.h>
54 
55  /* Enable C linkage for C++ Compilers: */
56  #if defined(__cplusplus)
57  extern "C" {
58  #endif
59 
60  /* Preprocessor Checks: */
61  #if !defined(__INCLUDE_FROM_CDC_DRIVER)
62  #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.
63  #endif
64 
65  /* Public Interface - May be used in end-application: */
66  /* Type Defines: */
73  typedef struct
74  {
75  const struct
76  {
77  uint8_t DataINPipeNumber;
86  uint8_t PortNumber;
88  } Config;
91  struct
92  {
93  bool IsActive;
99  uint16_t DataINPipeSize;
100  uint16_t DataOUTPipeSize;
103  struct
104  {
105  uint8_t HostToDevice;
109  uint8_t DeviceToHost;
112  } ControlLineStates;
114  CDC_LineEncoding_t LineEncoding;
120  } State;
125 
126  /* Enums: */
129  {
134  };
135 
136  /* Function Prototypes: */
143  void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
144 
157  uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
158  uint16_t ConfigDescriptorSize,
159  void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
160 
168  uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
169 
179  uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
180 
189  uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
190  const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);
191 
206  uint8_t CDC_Host_SendData(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
207  const uint8_t* const Buffer,
208  const uint16_t Length);
209 
223  uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
224  const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
225 
239  uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
240  const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
241 
254  uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
255 
267  int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
268 
278  uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
279 
280  #if (!defined(__IAR_SYSTEMS_ICC__) || (_DLIB_FILE_DESCRIPTOR == 1))
281 
300  void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
301  FILE* const Stream);
302 
312  void CDC_Host_CreateBlockingStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
313  FILE* const Stream);
314  #endif /* IAR DLAB checking */
315 
326 
327  /* Private Interface - For use in library only: */
328  #if !defined(__DOXYGEN__)
329  /* Function Prototypes: */
330  #if defined(__INCLUDE_FROM_CDC_HOST_C)
331  #if defined(FDEV_SETUP_STREAM)
332  static int CDC_Host_putchar(char c,
333  FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
334  static int CDC_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
335  static int CDC_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
336  #endif
337 
338  void CDC_Host_Event_Stub(void) ATTR_CONST;
339 
341  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Host_Event_Stub);
342 
343  static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor)
344  ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
345  static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor)
346  ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
347  static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor)
348  ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
349  #endif
350  #endif
351 
352  /* Disable C linkage for C++ Compilers: */
353  #if defined(__cplusplus)
354  }
355  #endif
356 
357 #endif
358