Subversion Repositories LedShow

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/**
2
  ******************************************************************************
3
  * @file    usbd_cdc.h
4
  * @author  MCD Application Team
5
  * @brief   header file for the usbd_cdc.c file.
6
  ******************************************************************************
7
  * @attention
8
  *
9 mjames 9
  * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
10
  * All rights reserved.</center></h2>
2 mjames 11
  *
9 mjames 12
  * This software component is licensed by ST under Ultimate Liberty license
13
  * SLA0044, the "License"; You may not use this file except in compliance with
14
  * the License. You may obtain a copy of the License at:
15
  *                      www.st.com/SLA0044
2 mjames 16
  *
17
  ******************************************************************************
9 mjames 18
  */
19
 
2 mjames 20
/* Define to prevent recursive inclusion -------------------------------------*/
21
#ifndef __USB_CDC_H
22
#define __USB_CDC_H
23
 
24
#ifdef __cplusplus
9 mjames 25
extern "C" {
2 mjames 26
#endif
27
 
28
/* Includes ------------------------------------------------------------------*/
29
#include  "usbd_ioreq.h"
30
 
31
/** @addtogroup STM32_USB_DEVICE_LIBRARY
32
  * @{
33
  */
9 mjames 34
 
2 mjames 35
/** @defgroup usbd_cdc
36
  * @brief This file is the Header file for usbd_cdc.c
37
  * @{
9 mjames 38
  */
2 mjames 39
 
40
 
41
/** @defgroup usbd_cdc_Exported_Defines
42
  * @{
9 mjames 43
  */
44
#define CDC_IN_EP                                   0x81U  /* EP1 for data IN */
45
#define CDC_OUT_EP                                  0x01U  /* EP1 for data OUT */
46
#define CDC_CMD_EP                                  0x82U  /* EP2 for CDC commands */
2 mjames 47
 
9 mjames 48
#ifndef CDC_HS_BINTERVAL
49
#define CDC_HS_BINTERVAL                          0x10U
50
#endif /* CDC_HS_BINTERVAL */
51
 
52
#ifndef CDC_FS_BINTERVAL
53
#define CDC_FS_BINTERVAL                          0x10U
54
#endif /* CDC_FS_BINTERVAL */
55
 
2 mjames 56
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
9 mjames 57
#define CDC_DATA_HS_MAX_PACKET_SIZE                 512U  /* Endpoint IN & OUT Packet size */
58
#define CDC_DATA_FS_MAX_PACKET_SIZE                 64U  /* Endpoint IN & OUT Packet size */
59
#define CDC_CMD_PACKET_SIZE                         8U  /* Control Endpoint Packet size */
2 mjames 60
 
9 mjames 61
#define USB_CDC_CONFIG_DESC_SIZ                     67U
2 mjames 62
#define CDC_DATA_HS_IN_PACKET_SIZE                  CDC_DATA_HS_MAX_PACKET_SIZE
63
#define CDC_DATA_HS_OUT_PACKET_SIZE                 CDC_DATA_HS_MAX_PACKET_SIZE
64
 
65
#define CDC_DATA_FS_IN_PACKET_SIZE                  CDC_DATA_FS_MAX_PACKET_SIZE
66
#define CDC_DATA_FS_OUT_PACKET_SIZE                 CDC_DATA_FS_MAX_PACKET_SIZE
67
 
68
/*---------------------------------------------------------------------*/
69
/*  CDC definitions                                                    */
70
/*---------------------------------------------------------------------*/
9 mjames 71
#define CDC_SEND_ENCAPSULATED_COMMAND               0x00U
72
#define CDC_GET_ENCAPSULATED_RESPONSE               0x01U
73
#define CDC_SET_COMM_FEATURE                        0x02U
74
#define CDC_GET_COMM_FEATURE                        0x03U
75
#define CDC_CLEAR_COMM_FEATURE                      0x04U
76
#define CDC_SET_LINE_CODING                         0x20U
77
#define CDC_GET_LINE_CODING                         0x21U
78
#define CDC_SET_CONTROL_LINE_STATE                  0x22U
79
#define CDC_SEND_BREAK                              0x23U
2 mjames 80
 
81
/**
82
  * @}
9 mjames 83
  */
2 mjames 84
 
85
 
86
/** @defgroup USBD_CORE_Exported_TypesDefinitions
87
  * @{
88
  */
89
 
90
/**
91
  * @}
9 mjames 92
  */
2 mjames 93
typedef struct
94
{
95
  uint32_t bitrate;
96
  uint8_t  format;
97
  uint8_t  paritytype;
98
  uint8_t  datatype;
9 mjames 99
} USBD_CDC_LineCodingTypeDef;
2 mjames 100
 
101
typedef struct _USBD_CDC_Itf
102
{
9 mjames 103
  int8_t (* Init)(void);
104
  int8_t (* DeInit)(void);
105
  int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length);
106
  int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
2 mjames 107
 
9 mjames 108
} USBD_CDC_ItfTypeDef;
2 mjames 109
 
110
 
111
typedef struct
112
{
9 mjames 113
  uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U];      /* Force 32bits alignment */
2 mjames 114
  uint8_t  CmdOpCode;
9 mjames 115
  uint8_t  CmdLength;
116
  uint8_t  *RxBuffer;
117
  uint8_t  *TxBuffer;
2 mjames 118
  uint32_t RxLength;
9 mjames 119
  uint32_t TxLength;
120
 
121
  __IO uint32_t TxState;
122
  __IO uint32_t RxState;
2 mjames 123
}
9 mjames 124
USBD_CDC_HandleTypeDef;
2 mjames 125
 
126
 
127
 
128
/** @defgroup USBD_CORE_Exported_Macros
129
  * @{
9 mjames 130
  */
131
 
2 mjames 132
/**
133
  * @}
9 mjames 134
  */
2 mjames 135
 
136
/** @defgroup USBD_CORE_Exported_Variables
137
  * @{
9 mjames 138
  */
2 mjames 139
 
140
extern USBD_ClassTypeDef  USBD_CDC;
141
#define USBD_CDC_CLASS    &USBD_CDC
142
/**
143
  * @}
9 mjames 144
  */
2 mjames 145
 
146
/** @defgroup USB_CORE_Exported_Functions
147
  * @{
148
  */
9 mjames 149
uint8_t  USBD_CDC_RegisterInterface(USBD_HandleTypeDef   *pdev,
150
                                    USBD_CDC_ItfTypeDef *fops);
2 mjames 151
 
9 mjames 152
uint8_t  USBD_CDC_SetTxBuffer(USBD_HandleTypeDef   *pdev,
153
                              uint8_t  *pbuff,
154
                              uint16_t length);
2 mjames 155
 
9 mjames 156
uint8_t  USBD_CDC_SetRxBuffer(USBD_HandleTypeDef   *pdev,
157
                              uint8_t  *pbuff);
2 mjames 158
 
9 mjames 159
uint8_t  USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
160
 
161
uint8_t  USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
2 mjames 162
/**
163
  * @}
9 mjames 164
  */
2 mjames 165
 
166
#ifdef __cplusplus
167
}
168
#endif
169
 
170
#endif  /* __USB_CDC_H */
171
/**
172
  * @}
9 mjames 173
  */
2 mjames 174
 
175
/**
176
  * @}
9 mjames 177
  */
178
 
2 mjames 179
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/