@@ -0,0 +1,35 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | OBJECTS_DIR = obj | |
|
5 | ||
|
6 | BSP=SamplingBoard | |
|
7 | ||
|
8 | ||
|
9 | UCMODEL=stm32f4 | |
|
10 | ||
|
11 | SOURCES += bsp.c | |
|
12 | ||
|
13 | HEADERS += bsp.h | |
|
14 | ||
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | ||
|
19 | ||
|
20 | ||
|
21 | INCLUDEPATH += $${PWD} | |
|
22 | ||
|
23 | SOURCES += bsp.c | |
|
24 | contains(CONFIG , USB){ | |
|
25 | SOURCES += usbd_usr.c \ | |
|
26 | usbd_desc.c \ | |
|
27 | usbd_cdc_vcp.c \ | |
|
28 | usb_bsp.c | |
|
29 | } | |
|
30 | ||
|
31 | HEADERS += $$libuc2/bsp/includes/$$BSP/bsp.h \ | |
|
32 | usbd_desc.h \ | |
|
33 | usbd_conf.h \ | |
|
34 | usbd_cdc_vcp.h \ | |
|
35 | usb_conf.h |
@@ -0,0 +1,141 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@gmail.com | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <spi.h> | |
|
28 | #include <stdio.h> | |
|
29 | #include <core.h> | |
|
30 | uint32_t OSC0 =8000000; | |
|
31 | uint32_t INTOSC =16000000; | |
|
32 | uint32_t RTCOSC =32768; | |
|
33 | uint32_t currentCpuFreq=0; | |
|
34 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
35 | ||
|
36 | float VREF0 =(float)3.3; | |
|
37 | ||
|
38 | int bsp_init() | |
|
39 | { | |
|
40 | int i=0; | |
|
41 | for(i=0;i<32;i++) | |
|
42 | { | |
|
43 | __opnfiles__[i] = NULL; | |
|
44 | } | |
|
45 | bsp_GPIO_init(); | |
|
46 | bsp_uart_init(); | |
|
47 | bsp_spi_init(); | |
|
48 | printf("\r================================================================\n\r"); | |
|
49 | printf("================================================================\n\r"); | |
|
50 | printf(BSP); | |
|
51 | printf(" initialised\n\r"); | |
|
52 | printf("================================================================\n\r"); | |
|
53 | return 1; | |
|
54 | } | |
|
55 | ||
|
56 | void bsp_GPIO_init() | |
|
57 | { | |
|
58 | // gpio_t GPIOList[]={LED1,LED2,LED3,ADC_MODE0,ADC_MODE1,ADC_FSYNC | |
|
59 | // ,ADC_SYNC,ADC_CLKDIV}; | |
|
60 | // gpio_t GPIOx; | |
|
61 | // for(int i=0;i<8;i++) | |
|
62 | // { | |
|
63 | // GPIOx = gpioopen(GPIOList[i]); | |
|
64 | // gpiosetspeed(&GPIOx,gpiohighspeed); | |
|
65 | // gpiosetdir(&GPIOx,gpiooutdir); | |
|
66 | // gpiosetouttype(&GPIOx,gpiopushpulltype); | |
|
67 | // } | |
|
68 | // gpioset(ADC_CLKDIV); | |
|
69 | // gpioset(ADC_MODE0); | |
|
70 | // gpioset(ADC_MODE1); | |
|
71 | // gpioclr(ADC_SYNC); | |
|
72 | // gpioclr(ADC_FSYNC); | |
|
73 | // delay_100us(10); | |
|
74 | // gpioset(ADC_SYNC); | |
|
75 | ||
|
76 | } | |
|
77 | ||
|
78 | void bsp_uart_init() | |
|
79 | { | |
|
80 | if(__opnfiles__[1]==NULL) | |
|
81 | { | |
|
82 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
83 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
84 | uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,19200,PC6,PC7,-1,-1); | |
|
85 | uartmkstreamdev(uart,fd1); | |
|
86 | __opnfiles__[1] = fd1; | |
|
87 | } | |
|
88 | else | |
|
89 | { | |
|
90 | uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,19200,PC6,PC7,-1,-1); | |
|
91 | } | |
|
92 | } | |
|
93 | ||
|
94 | void bsp_spi_init() | |
|
95 | { | |
|
96 | //spiopenandconfig(spi1,spi8bits | spimaster |spiclkinhlow | spiclkfirstedge | spimsbfirst,1000000,DAC_DIN,ADC_DOUT1,ADC_SCLK,-1); | |
|
97 | } | |
|
98 | ||
|
99 | ||
|
100 | void bsp_iic_init() | |
|
101 | { | |
|
102 | ||
|
103 | } | |
|
104 | ||
|
105 | void bsp_SD_init() | |
|
106 | { | |
|
107 | ||
|
108 | } | |
|
109 | ||
|
110 | void vs10XXclearXCS(){} | |
|
111 | void vs10XXsetXCS(){} | |
|
112 | int vs10XXDREQ() | |
|
113 | { | |
|
114 | return 1; | |
|
115 | } | |
|
116 | ||
|
117 | ||
|
118 | void bsppowersdcard(char onoff) //always ON | |
|
119 | { | |
|
120 | ||
|
121 | } | |
|
122 | ||
|
123 | char bspsdcardpresent() | |
|
124 | { | |
|
125 | return 0; | |
|
126 | } | |
|
127 | ||
|
128 | char bspsdcardwriteprotected() | |
|
129 | { | |
|
130 | return 0; | |
|
131 | } | |
|
132 | ||
|
133 | void bspsdcardselect(char YESNO) | |
|
134 | { | |
|
135 | ||
|
136 | } | |
|
137 | ||
|
138 | ||
|
139 | ||
|
140 | ||
|
141 |
@@ -0,0 +1,92 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@gmail.com | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | ||
|
29 | ||
|
30 | #define __MAX_OPENED_FILES__ 32 | |
|
31 | #define __FS_ROOT_SIZE__ 32 | |
|
32 | ||
|
33 | #define LED1 PD9 | |
|
34 | #define LED2 PD8 | |
|
35 | #define LED3 PB15 | |
|
36 | ||
|
37 | #define DAC_CS PA1 | |
|
38 | #define DAC_DIN PA7 | |
|
39 | ||
|
40 | #define ADC_MODE0 PA2 | |
|
41 | #define ADC_MODE1 PA3 | |
|
42 | #define ADC_FSYNC PA4 | |
|
43 | #define ADC_SCLK PA5 | |
|
44 | #define ADC_DOUT1 PA6 | |
|
45 | ||
|
46 | #define ADC_SYNC PB10 | |
|
47 | #define ADC_CLKDIV PB11 | |
|
48 | ||
|
49 | ||
|
50 | extern float VREF0; | |
|
51 | ||
|
52 | extern uint32_t currentCpuFreq; | |
|
53 | ||
|
54 | extern int bsp_init(); | |
|
55 | ||
|
56 | extern void bsp_GPIO_init(); | |
|
57 | extern void bsp_uart_init(); | |
|
58 | extern void bsp_iic_init(); | |
|
59 | extern void bsp_spi_init(); | |
|
60 | extern void bsp_SD_init(); | |
|
61 | ||
|
62 | /* VS1053 */ | |
|
63 | extern void clearXCS(); | |
|
64 | extern void setXCS(); | |
|
65 | extern int vs10XXDREQ(); | |
|
66 | ||
|
67 | /* SD CARD */ | |
|
68 | void bsppowersdcard(char onoff); | |
|
69 | char bspsdcardpresent(); | |
|
70 | void bspsdcardselect(char YESNO); | |
|
71 | char bspsdcardwriteprotected(); | |
|
72 | ||
|
73 | #endif | |
|
74 | ||
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 |
@@ -0,0 +1,9 | |||
|
1 | CPU=stm32f4xxxG | |
|
2 | DEFINES+=BSP=\\\"SamplingBoard\\\" | |
|
3 | #CONFIG += USB | |
|
4 | USB += cdc | |
|
5 | DEFINES+= USE_USB_OTG_FS | |
|
6 | DEFINES+=stm32f4 | |
|
7 | UCMODEL=stm32f4 | |
|
8 | ||
|
9 |
@@ -0,0 +1,320 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usb_bsp.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief This file is responsible to offer board support package and is | |
|
8 | * configurable by user. | |
|
9 | ****************************************************************************** | |
|
10 | * @attention | |
|
11 | * | |
|
12 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
13 | * | |
|
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
15 | * You may not use this file except in compliance with the License. | |
|
16 | * You may obtain a copy of the License at: | |
|
17 | * | |
|
18 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
19 | * | |
|
20 | * Unless required by applicable law or agreed to in writing, software | |
|
21 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
23 | * See the License for the specific language governing permissions and | |
|
24 | * limitations under the License. | |
|
25 | * | |
|
26 | ****************************************************************************** | |
|
27 | */ | |
|
28 | ||
|
29 | /* Includes ------------------------------------------------------------------*/ | |
|
30 | #include "usb_bsp.h" | |
|
31 | #include "usbd_conf.h" | |
|
32 | ||
|
33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
34 | * @{ | |
|
35 | */ | |
|
36 | ||
|
37 | /** @defgroup USB_BSP | |
|
38 | * @brief This file is responsible to offer board support package | |
|
39 | * @{ | |
|
40 | */ | |
|
41 | ||
|
42 | /** @defgroup USB_BSP_Private_Defines | |
|
43 | * @{ | |
|
44 | */ | |
|
45 | /** | |
|
46 | * @} | |
|
47 | */ | |
|
48 | ||
|
49 | ||
|
50 | /** @defgroup USB_BSP_Private_TypesDefinitions | |
|
51 | * @{ | |
|
52 | */ | |
|
53 | /** | |
|
54 | * @} | |
|
55 | */ | |
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | /** @defgroup USB_BSP_Private_Macros | |
|
62 | * @{ | |
|
63 | */ | |
|
64 | /** | |
|
65 | * @} | |
|
66 | */ | |
|
67 | ||
|
68 | /** @defgroup USBH_BSP_Private_Variables | |
|
69 | * @{ | |
|
70 | */ | |
|
71 | ||
|
72 | /** | |
|
73 | * @} | |
|
74 | */ | |
|
75 | ||
|
76 | /** @defgroup USBH_BSP_Private_FunctionPrototypes | |
|
77 | * @{ | |
|
78 | */ | |
|
79 | /** | |
|
80 | * @} | |
|
81 | */ | |
|
82 | ||
|
83 | /** @defgroup USB_BSP_Private_Functions | |
|
84 | * @{ | |
|
85 | */ | |
|
86 | ||
|
87 | ||
|
88 | /** | |
|
89 | * @brief USB_OTG_BSP_Init | |
|
90 | * Initilizes BSP configurations | |
|
91 | * @param None | |
|
92 | * @retval None | |
|
93 | */ | |
|
94 | ||
|
95 | void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) | |
|
96 | { | |
|
97 | #ifdef USE_STM3210C_EVAL | |
|
98 | ||
|
99 | RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); | |
|
100 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; | |
|
101 | ||
|
102 | #else // USE_STM322xG_EVAL | |
|
103 | GPIO_InitTypeDef GPIO_InitStructure; | |
|
104 | #ifdef USE_USB_OTG_FS | |
|
105 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE); | |
|
106 | ||
|
107 | /* Configure SOF ID DM DP Pins */ | |
|
108 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | | |
|
109 | GPIO_Pin_11 | | |
|
110 | GPIO_Pin_12; | |
|
111 | ||
|
112 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
113 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
114 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
|
115 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
116 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
117 | ||
|
118 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ; | |
|
119 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ; | |
|
120 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ; | |
|
121 | ||
|
122 | /* Configure VBUS Pin */ | |
|
123 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; | |
|
124 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
125 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; | |
|
126 | GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; | |
|
127 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
128 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
129 | ||
|
130 | /* Configure ID pin */ | |
|
131 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; | |
|
132 | GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; | |
|
133 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; | |
|
134 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
135 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
136 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ; | |
|
137 | ||
|
138 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); | |
|
139 | RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ; | |
|
140 | #else // USE_USB_OTG_HS | |
|
141 | ||
|
142 | #ifdef USE_ULPI_PHY // ULPI | |
|
143 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | | |
|
144 | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOH | | |
|
145 | RCC_AHB1Periph_GPIOI, ENABLE); | |
|
146 | ||
|
147 | ||
|
148 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource3, GPIO_AF_OTG2_HS) ; // D0 | |
|
149 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // CLK | |
|
150 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // D1 | |
|
151 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource1, GPIO_AF_OTG2_HS) ; // D2 | |
|
152 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // D7 | |
|
153 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource10,GPIO_AF_OTG2_HS) ; // D3 | |
|
154 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // D4 | |
|
155 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource12,GPIO_AF_OTG2_HS) ; // D5 | |
|
156 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource13,GPIO_AF_OTG2_HS) ; // D6 | |
|
157 | GPIO_PinAFConfig(GPIOH,GPIO_PinSource4, GPIO_AF_OTG2_HS) ; // NXT | |
|
158 | GPIO_PinAFConfig(GPIOI,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // DIR | |
|
159 | GPIO_PinAFConfig(GPIOC,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // STP | |
|
160 | ||
|
161 | // CLK | |
|
162 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; | |
|
163 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
164 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
165 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
166 | ||
|
167 | // D0 | |
|
168 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 ; | |
|
169 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
170 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
171 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
|
172 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
173 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
174 | ||
|
175 | ||
|
176 | ||
|
177 | // D1 D2 D3 D4 D5 D6 D7 | |
|
178 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | | |
|
179 | GPIO_Pin_5 | GPIO_Pin_10 | | |
|
180 | GPIO_Pin_11| GPIO_Pin_12 | | |
|
181 | GPIO_Pin_13 ; | |
|
182 | ||
|
183 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
184 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
185 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
|
186 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
187 | GPIO_Init(GPIOB, &GPIO_InitStructure); | |
|
188 | ||
|
189 | ||
|
190 | // STP | |
|
191 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ; | |
|
192 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
193 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
194 | GPIO_Init(GPIOC, &GPIO_InitStructure); | |
|
195 | ||
|
196 | //NXT | |
|
197 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; | |
|
198 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
199 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
200 | GPIO_Init(GPIOH, &GPIO_InitStructure); | |
|
201 | ||
|
202 | ||
|
203 | //DIR | |
|
204 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ; | |
|
205 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
206 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
207 | GPIO_Init(GPIOI, &GPIO_InitStructure); | |
|
208 | ||
|
209 | ||
|
210 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS | | |
|
211 | RCC_AHB1Periph_OTG_HS_ULPI, ENABLE) ; | |
|
212 | ||
|
213 | #else | |
|
214 | ||
|
215 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB , ENABLE); | |
|
216 | ||
|
217 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | | |
|
218 | GPIO_Pin_14 | | |
|
219 | GPIO_Pin_15; | |
|
220 | ||
|
221 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
222 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
223 | GPIO_Init(GPIOB, &GPIO_InitStructure); | |
|
224 | ||
|
225 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource12, GPIO_AF_OTG2_FS) ; | |
|
226 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS) ; | |
|
227 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS) ; | |
|
228 | ||
|
229 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; | |
|
230 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
231 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; | |
|
232 | GPIO_Init(GPIOB, &GPIO_InitStructure); | |
|
233 | ||
|
234 | ||
|
235 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ; | |
|
236 | ||
|
237 | #endif | |
|
238 | #endif //USB_OTG_HS | |
|
239 | #endif //USE_STM322xG_EVAL | |
|
240 | } | |
|
241 | /** | |
|
242 | * @brief USB_OTG_BSP_EnableInterrupt | |
|
243 | * Enabele USB Global interrupt | |
|
244 | * @param None | |
|
245 | * @retval None | |
|
246 | */ | |
|
247 | void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) | |
|
248 | { | |
|
249 | NVIC_InitTypeDef NVIC_InitStructure; | |
|
250 | ||
|
251 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); | |
|
252 | #ifdef USE_USB_OTG_HS | |
|
253 | NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn; | |
|
254 | #else | |
|
255 | NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; | |
|
256 | #endif | |
|
257 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; | |
|
258 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; | |
|
259 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
260 | NVIC_Init(&NVIC_InitStructure); | |
|
261 | #ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED | |
|
262 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); | |
|
263 | NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_OUT_IRQn; | |
|
264 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; | |
|
265 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; | |
|
266 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
267 | NVIC_Init(&NVIC_InitStructure); | |
|
268 | ||
|
269 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); | |
|
270 | NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_IN_IRQn; | |
|
271 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; | |
|
272 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; | |
|
273 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
274 | NVIC_Init(&NVIC_InitStructure); | |
|
275 | #endif | |
|
276 | } | |
|
277 | /** | |
|
278 | * @brief USB_OTG_BSP_uDelay | |
|
279 | * This function provides delay time in micro sec | |
|
280 | * @param usec : Value of delay required in micro sec | |
|
281 | * @retval None | |
|
282 | */ | |
|
283 | void USB_OTG_BSP_uDelay (const uint32_t usec) | |
|
284 | { | |
|
285 | uint32_t count = 0; | |
|
286 | const uint32_t utime = (120 * usec / 7); | |
|
287 | do | |
|
288 | { | |
|
289 | if ( ++count > utime ) | |
|
290 | { | |
|
291 | return ; | |
|
292 | } | |
|
293 | } | |
|
294 | while (1); | |
|
295 | } | |
|
296 | ||
|
297 | ||
|
298 | /** | |
|
299 | * @brief USB_OTG_BSP_mDelay | |
|
300 | * This function provides delay time in milli sec | |
|
301 | * @param msec : Value of delay required in milli sec | |
|
302 | * @retval None | |
|
303 | */ | |
|
304 | void USB_OTG_BSP_mDelay (const uint32_t msec) | |
|
305 | { | |
|
306 | USB_OTG_BSP_uDelay(msec * 1000); | |
|
307 | } | |
|
308 | /** | |
|
309 | * @} | |
|
310 | */ | |
|
311 | ||
|
312 | /** | |
|
313 | * @} | |
|
314 | */ | |
|
315 | ||
|
316 | /** | |
|
317 | * @} | |
|
318 | */ | |
|
319 | ||
|
320 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,310 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usb_conf.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief General low level driver configuration | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | #ifndef __USB_CONF__H__ | |
|
30 | #define __USB_CONF__H__ | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #if defined (USE_STM322xG_EVAL) | |
|
34 | #include "stm322xg_eval.h" | |
|
35 | #include "stm322xg_eval_lcd.h" | |
|
36 | #include "stm322xg_eval_ioe.h" | |
|
37 | #include "stm322xg_eval_sdio_sd.h" | |
|
38 | #elif defined(USE_STM324xG_EVAL) | |
|
39 | #include "stm32f4xx.h" | |
|
40 | #include "stm324xg_eval.h" | |
|
41 | #include "stm324xg_eval_lcd.h" | |
|
42 | #include "stm324xg_eval_ioe.h" | |
|
43 | #include "stm324xg_eval_sdio_sd.h" | |
|
44 | #elif defined (USE_STM3210C_EVAL) | |
|
45 | #include "stm32f10x.h" | |
|
46 | #include "stm3210c_eval.h" | |
|
47 | #include "stm3210c_eval_lcd.h" | |
|
48 | #include "stm3210c_eval_ioe.h" | |
|
49 | #include "stm3210c_eval_spi_sd.h" | |
|
50 | #elif defined (stm32f4) | |
|
51 | #include "stm32f4xx.h" | |
|
52 | #else | |
|
53 | #error "Missing define: Evaluation board (ie. USE_STM322xG_EVAL)" | |
|
54 | #endif | |
|
55 | ||
|
56 | ||
|
57 | /** @addtogroup USB_OTG_DRIVER | |
|
58 | * @{ | |
|
59 | */ | |
|
60 | ||
|
61 | /** @defgroup USB_CONF | |
|
62 | * @brief USB low level driver configuration file | |
|
63 | * @{ | |
|
64 | */ | |
|
65 | ||
|
66 | /** @defgroup USB_CONF_Exported_Defines | |
|
67 | * @{ | |
|
68 | */ | |
|
69 | ||
|
70 | /* USB Core and PHY interface configuration. | |
|
71 | Tip: To avoid modifying these defines each time you need to change the USB | |
|
72 | configuration, you can declare the needed define in your toolchain | |
|
73 | compiler preprocessor. | |
|
74 | */ | |
|
75 | /****************** USB OTG FS PHY CONFIGURATION ******************************* | |
|
76 | * The USB OTG FS Core supports one on-chip Full Speed PHY. | |
|
77 | * | |
|
78 | * The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor | |
|
79 | * when FS core is used. | |
|
80 | *******************************************************************************/ | |
|
81 | #ifndef USE_USB_OTG_FS | |
|
82 | //#define USE_USB_OTG_FS | |
|
83 | #endif /* USE_USB_OTG_FS */ | |
|
84 | ||
|
85 | #ifdef USE_USB_OTG_FS | |
|
86 | #define USB_OTG_FS_CORE | |
|
87 | #endif | |
|
88 | ||
|
89 | /****************** USB OTG HS PHY CONFIGURATION ******************************* | |
|
90 | * The USB OTG HS Core supports two PHY interfaces: | |
|
91 | * (i) An ULPI interface for the external High Speed PHY: the USB HS Core will | |
|
92 | * operate in High speed mode | |
|
93 | * (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode | |
|
94 | * | |
|
95 | * You can select the PHY to be used using one of these two defines: | |
|
96 | * (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode | |
|
97 | * (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode | |
|
98 | * | |
|
99 | * Notes: | |
|
100 | * - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as | |
|
101 | * default PHY when HS core is used. | |
|
102 | * - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available. | |
|
103 | * Configuration (ii) need a different hardware, for more details refer to your | |
|
104 | * STM32 device datasheet. | |
|
105 | *******************************************************************************/ | |
|
106 | #ifndef USE_USB_OTG_HS | |
|
107 | //#define USE_USB_OTG_HS | |
|
108 | #endif /* USE_USB_OTG_HS */ | |
|
109 | ||
|
110 | #ifndef USE_ULPI_PHY | |
|
111 | //#define USE_ULPI_PHY | |
|
112 | #endif /* USE_ULPI_PHY */ | |
|
113 | ||
|
114 | #ifndef USE_EMBEDDED_PHY | |
|
115 | //#define USE_EMBEDDED_PHY | |
|
116 | #endif /* USE_EMBEDDED_PHY */ | |
|
117 | ||
|
118 | #ifdef USE_USB_OTG_HS | |
|
119 | #define USB_OTG_HS_CORE | |
|
120 | #endif | |
|
121 | ||
|
122 | /******************************************************************************* | |
|
123 | * FIFO Size Configuration in Device mode | |
|
124 | * | |
|
125 | * (i) Receive data FIFO size = RAM for setup packets + | |
|
126 | * OUT endpoint control information + | |
|
127 | * data OUT packets + miscellaneous | |
|
128 | * Space = ONE 32-bits words | |
|
129 | * --> RAM for setup packets = 10 spaces | |
|
130 | * (n is the nbr of CTRL EPs the device core supports) | |
|
131 | * --> OUT EP CTRL info = 1 space | |
|
132 | * (one space for status information written to the FIFO along with each | |
|
133 | * received packet) | |
|
134 | * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces | |
|
135 | * (MINIMUM to receive packets) | |
|
136 | * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces | |
|
137 | * (if high-bandwidth EP is enabled or multiple isochronous EPs) | |
|
138 | * --> miscellaneous = 1 space per OUT EP | |
|
139 | * (one space for transfer complete status information also pushed to the | |
|
140 | * FIFO with each endpoint's last packet) | |
|
141 | * | |
|
142 | * (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for | |
|
143 | * that particular IN EP. More space allocated in the IN EP Tx FIFO results | |
|
144 | * in a better performance on the USB and can hide latencies on the AHB. | |
|
145 | * | |
|
146 | * (iii) TXn min size = 16 words. (n : Transmit FIFO index) | |
|
147 | * (iv) When a TxFIFO is not used, the Configuration should be as follows: | |
|
148 | * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) | |
|
149 | * --> Txm can use the space allocated for Txn. | |
|
150 | * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) | |
|
151 | * --> Txn should be configured with the minimum space of 16 words | |
|
152 | * (v) The FIFO is used optimally when used TxFIFOs are allocated in the top | |
|
153 | * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. | |
|
154 | * (vi) In HS case 12 FIFO locations should be reserved for internal DMA registers | |
|
155 | * so total FIFO size should be 1012 Only instead of 1024 | |
|
156 | *******************************************************************************/ | |
|
157 | ||
|
158 | /****************** USB OTG HS CONFIGURATION **********************************/ | |
|
159 | #ifdef USB_OTG_HS_CORE | |
|
160 | #define RX_FIFO_HS_SIZE 512 | |
|
161 | #define TX0_FIFO_HS_SIZE 64 | |
|
162 | #define TX1_FIFO_HS_SIZE 372 | |
|
163 | #define TX2_FIFO_HS_SIZE 64 | |
|
164 | #define TX3_FIFO_HS_SIZE 0 | |
|
165 | #define TX4_FIFO_HS_SIZE 0 | |
|
166 | #define TX5_FIFO_HS_SIZE 0 | |
|
167 | ||
|
168 | // #define USB_OTG_HS_SOF_OUTPUT_ENABLED | |
|
169 | ||
|
170 | #ifdef USE_ULPI_PHY | |
|
171 | #define USB_OTG_ULPI_PHY_ENABLED | |
|
172 | #endif | |
|
173 | #ifdef USE_EMBEDDED_PHY | |
|
174 | #define USB_OTG_EMBEDDED_PHY_ENABLED | |
|
175 | /* wakeup is working only when HS core is configured in FS mode */ | |
|
176 | #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT | |
|
177 | #endif | |
|
178 | /* #define USB_OTG_HS_INTERNAL_DMA_ENABLED */ /* Be aware that enabling DMA mode will result in data being sent only by | |
|
179 | multiple of 4 packet sizes. This is due to the fact that USB DMA does | |
|
180 | not allow sending data from non word-aligned addresses. | |
|
181 | For this specific application, it is advised to not enable this option | |
|
182 | unless required. */ | |
|
183 | #define USB_OTG_HS_DEDICATED_EP1_ENABLED | |
|
184 | #endif | |
|
185 | ||
|
186 | /****************** USB OTG FS CONFIGURATION **********************************/ | |
|
187 | #ifdef USB_OTG_FS_CORE | |
|
188 | #define RX_FIFO_FS_SIZE 128 | |
|
189 | #define TX0_FIFO_FS_SIZE 32 | |
|
190 | #define TX1_FIFO_FS_SIZE 128 | |
|
191 | #define TX2_FIFO_FS_SIZE 32 | |
|
192 | #define TX3_FIFO_FS_SIZE 0 | |
|
193 | ||
|
194 | // #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT | |
|
195 | // #define USB_OTG_FS_SOF_OUTPUT_ENABLED | |
|
196 | #endif | |
|
197 | ||
|
198 | /****************** USB OTG MISC CONFIGURATION ********************************/ | |
|
199 | #define VBUS_SENSING_ENABLED | |
|
200 | ||
|
201 | /****************** USB OTG MODE CONFIGURATION ********************************/ | |
|
202 | //#define USE_HOST_MODE | |
|
203 | #define USE_DEVICE_MODE | |
|
204 | //#define USE_OTG_MODE | |
|
205 | ||
|
206 | #ifndef USB_OTG_FS_CORE | |
|
207 | #ifndef USB_OTG_HS_CORE | |
|
208 | #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined" | |
|
209 | #endif | |
|
210 | #endif | |
|
211 | ||
|
212 | #ifndef USE_DEVICE_MODE | |
|
213 | #ifndef USE_HOST_MODE | |
|
214 | #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined" | |
|
215 | #endif | |
|
216 | #endif | |
|
217 | ||
|
218 | #ifndef USE_USB_OTG_HS | |
|
219 | #ifndef USE_USB_OTG_FS | |
|
220 | #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined" | |
|
221 | #endif | |
|
222 | #else //USE_USB_OTG_HS | |
|
223 | #ifndef USE_ULPI_PHY | |
|
224 | #ifndef USE_EMBEDDED_PHY | |
|
225 | #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined" | |
|
226 | #endif | |
|
227 | #endif | |
|
228 | #endif | |
|
229 | ||
|
230 | /****************** C Compilers dependant keywords ****************************/ | |
|
231 | /* In HS mode and when the DMA is used, all variables and data structures dealing | |
|
232 | with the DMA during the transaction process should be 4-bytes aligned */ | |
|
233 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
234 | #if defined (__GNUC__) /* GNU Compiler */ | |
|
235 | #define __ALIGN_END __attribute__ ((aligned (4))) | |
|
236 | #define __ALIGN_BEGIN | |
|
237 | #else | |
|
238 | #define __ALIGN_END | |
|
239 | #if defined (__CC_ARM) /* ARM Compiler */ | |
|
240 | #define __ALIGN_BEGIN __align(4) | |
|
241 | #elif defined (__ICCARM__) /* IAR Compiler */ | |
|
242 | #define __ALIGN_BEGIN | |
|
243 | #elif defined (__TASKING__) /* TASKING Compiler */ | |
|
244 | #define __ALIGN_BEGIN __align(4) | |
|
245 | #endif /* __CC_ARM */ | |
|
246 | #endif /* __GNUC__ */ | |
|
247 | #else | |
|
248 | #define __ALIGN_BEGIN | |
|
249 | #define __ALIGN_END | |
|
250 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
251 | ||
|
252 | /* __packed keyword used to decrease the data type alignment to 1-byte */ | |
|
253 | #if defined (__CC_ARM) /* ARM Compiler */ | |
|
254 | #define __packed __packed | |
|
255 | #elif defined (__ICCARM__) /* IAR Compiler */ | |
|
256 | #define __packed __packed | |
|
257 | #elif defined ( __GNUC__ ) /* GNU Compiler */ | |
|
258 | #define __packed __attribute__ ((__packed__)) | |
|
259 | #elif defined (__TASKING__) /* TASKING Compiler */ | |
|
260 | #define __packed __unaligned | |
|
261 | #endif /* __CC_ARM */ | |
|
262 | ||
|
263 | /** | |
|
264 | * @} | |
|
265 | */ | |
|
266 | ||
|
267 | ||
|
268 | /** @defgroup USB_CONF_Exported_Types | |
|
269 | * @{ | |
|
270 | */ | |
|
271 | /** | |
|
272 | * @} | |
|
273 | */ | |
|
274 | ||
|
275 | ||
|
276 | /** @defgroup USB_CONF_Exported_Macros | |
|
277 | * @{ | |
|
278 | */ | |
|
279 | /** | |
|
280 | * @} | |
|
281 | */ | |
|
282 | ||
|
283 | /** @defgroup USB_CONF_Exported_Variables | |
|
284 | * @{ | |
|
285 | */ | |
|
286 | /** | |
|
287 | * @} | |
|
288 | */ | |
|
289 | ||
|
290 | /** @defgroup USB_CONF_Exported_FunctionsPrototype | |
|
291 | * @{ | |
|
292 | */ | |
|
293 | /** | |
|
294 | * @} | |
|
295 | */ | |
|
296 | ||
|
297 | ||
|
298 | #endif //__USB_CONF__H__ | |
|
299 | ||
|
300 | ||
|
301 | /** | |
|
302 | * @} | |
|
303 | */ | |
|
304 | ||
|
305 | /** | |
|
306 | * @} | |
|
307 | */ | |
|
308 | ||
|
309 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
|
310 |
@@ -0,0 +1,381 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_cdc_vcp.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief Generic media access Layer. | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
29 | #pragma data_alignment = 4 | |
|
30 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #include "usbd_cdc_vcp.h" | |
|
34 | #include "usb_conf.h" | |
|
35 | ||
|
36 | /* Private typedef -----------------------------------------------------------*/ | |
|
37 | /* Private define ------------------------------------------------------------*/ | |
|
38 | /* Private macro -------------------------------------------------------------*/ | |
|
39 | /* Private variables ---------------------------------------------------------*/ | |
|
40 | LINE_CODING linecoding = | |
|
41 | { | |
|
42 | 115200, /* baud rate*/ | |
|
43 | 0x00, /* stop bits-1*/ | |
|
44 | 0x00, /* parity - none*/ | |
|
45 | 0x08 /* nb. of bits 8*/ | |
|
46 | }; | |
|
47 | ||
|
48 | ||
|
49 | USART_InitTypeDef USART_InitStructure; | |
|
50 | ||
|
51 | /* These are external variables imported from CDC core to be used for IN | |
|
52 | transfer management. */ | |
|
53 | extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer. | |
|
54 | These data will be sent over USB IN endpoint | |
|
55 | in the CDC core functions. */ | |
|
56 | extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to | |
|
57 | start address when writing received data | |
|
58 | in the buffer APP_Rx_Buffer. */ | |
|
59 | ||
|
60 | /* Private function prototypes -----------------------------------------------*/ | |
|
61 | static uint16_t VCP_Init (void); | |
|
62 | static uint16_t VCP_DeInit (void); | |
|
63 | static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len); | |
|
64 | static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len); | |
|
65 | static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len); | |
|
66 | ||
|
67 | static uint16_t VCP_COMConfig(uint8_t Conf); | |
|
68 | ||
|
69 | CDC_IF_Prop_TypeDef VCP_fops = | |
|
70 | { | |
|
71 | VCP_Init, | |
|
72 | VCP_DeInit, | |
|
73 | VCP_Ctrl, | |
|
74 | VCP_DataTx, | |
|
75 | VCP_DataRx | |
|
76 | }; | |
|
77 | ||
|
78 | /* Private functions ---------------------------------------------------------*/ | |
|
79 | /** | |
|
80 | * @brief VCP_Init | |
|
81 | * Initializes the Media on the STM32 | |
|
82 | * @param None | |
|
83 | * @retval Result of the opeartion (USBD_OK in all cases) | |
|
84 | */ | |
|
85 | static uint16_t VCP_Init(void) | |
|
86 | { | |
|
87 | NVIC_InitTypeDef NVIC_InitStructure; | |
|
88 | ||
|
89 | /* EVAL_COM1 default configuration */ | |
|
90 | /* EVAL_COM1 configured as follow: | |
|
91 | - BaudRate = 115200 baud | |
|
92 | - Word Length = 8 Bits | |
|
93 | - One Stop Bit | |
|
94 | - Parity Odd | |
|
95 | - Hardware flow control disabled | |
|
96 | - Receive and transmit enabled | |
|
97 | */ | |
|
98 | USART_InitStructure.USART_BaudRate = 115200; | |
|
99 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
100 | USART_InitStructure.USART_StopBits = USART_StopBits_1; | |
|
101 | USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
|
102 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
|
103 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
|
104 | ||
|
105 | /* Configure and enable the USART */ | |
|
106 | STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
|
107 | ||
|
108 | /* Enable the USART Receive interrupt */ | |
|
109 | USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); | |
|
110 | ||
|
111 | /* Enable USART Interrupt */ | |
|
112 | NVIC_InitStructure.NVIC_IRQChannel = EVAL_COM1_IRQn; | |
|
113 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; | |
|
114 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; | |
|
115 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
116 | NVIC_Init(&NVIC_InitStructure); | |
|
117 | ||
|
118 | return USBD_OK; | |
|
119 | } | |
|
120 | ||
|
121 | /** | |
|
122 | * @brief VCP_DeInit | |
|
123 | * DeInitializes the Media on the STM32 | |
|
124 | * @param None | |
|
125 | * @retval Result of the opeartion (USBD_OK in all cases) | |
|
126 | */ | |
|
127 | static uint16_t VCP_DeInit(void) | |
|
128 | { | |
|
129 | ||
|
130 | return USBD_OK; | |
|
131 | } | |
|
132 | ||
|
133 | ||
|
134 | /** | |
|
135 | * @brief VCP_Ctrl | |
|
136 | * Manage the CDC class requests | |
|
137 | * @param Cmd: Command code | |
|
138 | * @param Buf: Buffer containing command data (request parameters) | |
|
139 | * @param Len: Number of data to be sent (in bytes) | |
|
140 | * @retval Result of the opeartion (USBD_OK in all cases) | |
|
141 | */ | |
|
142 | static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) | |
|
143 | { | |
|
144 | switch (Cmd) | |
|
145 | { | |
|
146 | case SEND_ENCAPSULATED_COMMAND: | |
|
147 | /* Not needed for this driver */ | |
|
148 | break; | |
|
149 | ||
|
150 | case GET_ENCAPSULATED_RESPONSE: | |
|
151 | /* Not needed for this driver */ | |
|
152 | break; | |
|
153 | ||
|
154 | case SET_COMM_FEATURE: | |
|
155 | /* Not needed for this driver */ | |
|
156 | break; | |
|
157 | ||
|
158 | case GET_COMM_FEATURE: | |
|
159 | /* Not needed for this driver */ | |
|
160 | break; | |
|
161 | ||
|
162 | case CLEAR_COMM_FEATURE: | |
|
163 | /* Not needed for this driver */ | |
|
164 | break; | |
|
165 | ||
|
166 | case SET_LINE_CODING: | |
|
167 | linecoding.bitrate = (uint32_t)(Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24)); | |
|
168 | linecoding.format = Buf[4]; | |
|
169 | linecoding.paritytype = Buf[5]; | |
|
170 | linecoding.datatype = Buf[6]; | |
|
171 | /* Set the new configuration */ | |
|
172 | VCP_COMConfig(OTHER_CONFIG); | |
|
173 | break; | |
|
174 | ||
|
175 | case GET_LINE_CODING: | |
|
176 | Buf[0] = (uint8_t)(linecoding.bitrate); | |
|
177 | Buf[1] = (uint8_t)(linecoding.bitrate >> 8); | |
|
178 | Buf[2] = (uint8_t)(linecoding.bitrate >> 16); | |
|
179 | Buf[3] = (uint8_t)(linecoding.bitrate >> 24); | |
|
180 | Buf[4] = linecoding.format; | |
|
181 | Buf[5] = linecoding.paritytype; | |
|
182 | Buf[6] = linecoding.datatype; | |
|
183 | break; | |
|
184 | ||
|
185 | case SET_CONTROL_LINE_STATE: | |
|
186 | /* Not needed for this driver */ | |
|
187 | break; | |
|
188 | ||
|
189 | case SEND_BREAK: | |
|
190 | /* Not needed for this driver */ | |
|
191 | break; | |
|
192 | ||
|
193 | default: | |
|
194 | break; | |
|
195 | } | |
|
196 | ||
|
197 | return USBD_OK; | |
|
198 | } | |
|
199 | ||
|
200 | /** | |
|
201 | * @brief VCP_DataTx | |
|
202 | * CDC received data to be send over USB IN endpoint are managed in | |
|
203 | * this function. | |
|
204 | * @param Buf: Buffer of data to be sent | |
|
205 | * @param Len: Number of data to be sent (in bytes) | |
|
206 | * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL | |
|
207 | */ | |
|
208 | static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len) | |
|
209 | { | |
|
210 | if (linecoding.datatype == 7) | |
|
211 | { | |
|
212 | APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1) & 0x7F; | |
|
213 | } | |
|
214 | else if (linecoding.datatype == 8) | |
|
215 | { | |
|
216 | APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1); | |
|
217 | } | |
|
218 | ||
|
219 | APP_Rx_ptr_in++; | |
|
220 | ||
|
221 | /* To avoid buffer overflow */ | |
|
222 | if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) | |
|
223 | { | |
|
224 | APP_Rx_ptr_in = 0; | |
|
225 | } | |
|
226 | ||
|
227 | return USBD_OK; | |
|
228 | } | |
|
229 | ||
|
230 | /** | |
|
231 | * @brief VCP_DataRx | |
|
232 | * Data received over USB OUT endpoint are sent over CDC interface | |
|
233 | * through this function. | |
|
234 | * | |
|
235 | * @note | |
|
236 | * This function will block any OUT packet reception on USB endpoint | |
|
237 | * untill exiting this function. If you exit this function before transfer | |
|
238 | * is complete on CDC interface (ie. using DMA controller) it will result | |
|
239 | * in receiving more data while previous ones are still not sent. | |
|
240 | * | |
|
241 | * @param Buf: Buffer of data to be received | |
|
242 | * @param Len: Number of data received (in bytes) | |
|
243 | * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL | |
|
244 | */ | |
|
245 | static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len) | |
|
246 | { | |
|
247 | uint32_t i; | |
|
248 | ||
|
249 | for (i = 0; i < Len; i++) | |
|
250 | { | |
|
251 | USART_SendData(EVAL_COM1, *(Buf + i) ); | |
|
252 | while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TXE) == RESET); | |
|
253 | } | |
|
254 | ||
|
255 | return USBD_OK; | |
|
256 | } | |
|
257 | ||
|
258 | /** | |
|
259 | * @brief VCP_COMConfig | |
|
260 | * Configure the COM Port with default values or values received from host. | |
|
261 | * @param Conf: can be DEFAULT_CONFIG to set the default configuration or OTHER_CONFIG | |
|
262 | * to set a configuration received from the host. | |
|
263 | * @retval None. | |
|
264 | */ | |
|
265 | static uint16_t VCP_COMConfig(uint8_t Conf) | |
|
266 | { | |
|
267 | if (Conf == DEFAULT_CONFIG) | |
|
268 | { | |
|
269 | /* EVAL_COM1 default configuration */ | |
|
270 | /* EVAL_COM1 configured as follow: | |
|
271 | - BaudRate = 115200 baud | |
|
272 | - Word Length = 8 Bits | |
|
273 | - One Stop Bit | |
|
274 | - Parity Odd | |
|
275 | - Hardware flow control disabled | |
|
276 | - Receive and transmit enabled | |
|
277 | */ | |
|
278 | USART_InitStructure.USART_BaudRate = 115200; | |
|
279 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
280 | USART_InitStructure.USART_StopBits = USART_StopBits_1; | |
|
281 | USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
|
282 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
|
283 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
|
284 | ||
|
285 | /* Configure and enable the USART */ | |
|
286 | STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
|
287 | ||
|
288 | /* Enable the USART Receive interrupt */ | |
|
289 | USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); | |
|
290 | } | |
|
291 | else | |
|
292 | { | |
|
293 | /* set the Stop bit*/ | |
|
294 | switch (linecoding.format) | |
|
295 | { | |
|
296 | case 0: | |
|
297 | USART_InitStructure.USART_StopBits = USART_StopBits_1; | |
|
298 | break; | |
|
299 | case 1: | |
|
300 | USART_InitStructure.USART_StopBits = USART_StopBits_1_5; | |
|
301 | break; | |
|
302 | case 2: | |
|
303 | USART_InitStructure.USART_StopBits = USART_StopBits_2; | |
|
304 | break; | |
|
305 | default : | |
|
306 | VCP_COMConfig(DEFAULT_CONFIG); | |
|
307 | return (USBD_FAIL); | |
|
308 | } | |
|
309 | ||
|
310 | /* set the parity bit*/ | |
|
311 | switch (linecoding.paritytype) | |
|
312 | { | |
|
313 | case 0: | |
|
314 | USART_InitStructure.USART_Parity = USART_Parity_No; | |
|
315 | break; | |
|
316 | case 1: | |
|
317 | USART_InitStructure.USART_Parity = USART_Parity_Even; | |
|
318 | break; | |
|
319 | case 2: | |
|
320 | USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
|
321 | break; | |
|
322 | default : | |
|
323 | VCP_COMConfig(DEFAULT_CONFIG); | |
|
324 | return (USBD_FAIL); | |
|
325 | } | |
|
326 | ||
|
327 | /*set the data type : only 8bits and 9bits is supported */ | |
|
328 | switch (linecoding.datatype) | |
|
329 | { | |
|
330 | case 0x07: | |
|
331 | /* With this configuration a parity (Even or Odd) should be set */ | |
|
332 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
333 | break; | |
|
334 | case 0x08: | |
|
335 | if (USART_InitStructure.USART_Parity == USART_Parity_No) | |
|
336 | { | |
|
337 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
338 | } | |
|
339 | else | |
|
340 | { | |
|
341 | USART_InitStructure.USART_WordLength = USART_WordLength_9b; | |
|
342 | } | |
|
343 | ||
|
344 | break; | |
|
345 | default : | |
|
346 | VCP_COMConfig(DEFAULT_CONFIG); | |
|
347 | return (USBD_FAIL); | |
|
348 | } | |
|
349 | ||
|
350 | USART_InitStructure.USART_BaudRate = linecoding.bitrate; | |
|
351 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
|
352 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
|
353 | ||
|
354 | /* Configure and enable the USART */ | |
|
355 | STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
|
356 | } | |
|
357 | return USBD_OK; | |
|
358 | } | |
|
359 | ||
|
360 | /** | |
|
361 | * @brief EVAL_COM_IRQHandler | |
|
362 | * | |
|
363 | * @param None. | |
|
364 | * @retval None. | |
|
365 | */ | |
|
366 | void EVAL_COM_IRQHandler(void) | |
|
367 | { | |
|
368 | if (USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET) | |
|
369 | { | |
|
370 | /* Send the received data to the PC Host*/ | |
|
371 | VCP_DataTx (0,0); | |
|
372 | } | |
|
373 | ||
|
374 | /* If overrun condition occurs, clear the ORE flag and recover communication */ | |
|
375 | if (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_ORE) != RESET) | |
|
376 | { | |
|
377 | (void)USART_ReceiveData(EVAL_COM1); | |
|
378 | } | |
|
379 | } | |
|
380 | ||
|
381 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,74 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_cdc_vcp.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief Header for usbd_cdc_vcp.c file. | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | #ifndef __USBD_CDC_VCP_H | |
|
30 | #define __USBD_CDC_VCP_H | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #ifdef STM32F2XX | |
|
34 | #include "stm32f2xx.h" | |
|
35 | #elif defined(STM32F10X_CL) | |
|
36 | #include "stm32f10x.h" | |
|
37 | #endif /* STM32F2XX */ | |
|
38 | ||
|
39 | #include "usbd_cdc_core.h" | |
|
40 | #include "usbd_conf.h" | |
|
41 | ||
|
42 | ||
|
43 | /* Exported typef ------------------------------------------------------------*/ | |
|
44 | /* The following structures groups all needed parameters to be configured for the | |
|
45 | ComPort. These parameters can modified on the fly by the host through CDC class | |
|
46 | command class requests. */ | |
|
47 | typedef struct | |
|
48 | { | |
|
49 | uint32_t bitrate; | |
|
50 | uint8_t format; | |
|
51 | uint8_t paritytype; | |
|
52 | uint8_t datatype; | |
|
53 | }LINE_CODING; | |
|
54 | ||
|
55 | /* Exported constants --------------------------------------------------------*/ | |
|
56 | /* The following define is used to route the USART IRQ handler to be used. | |
|
57 | The IRQ handler function is implemented in the usbd_cdc_vcp.c file. */ | |
|
58 | ||
|
59 | #ifdef USE_STM3210C_EVAL | |
|
60 | #define EVAL_COM_IRQHandler USART2_IRQHandler | |
|
61 | #else | |
|
62 | #define EVAL_COM_IRQHandler USART3_IRQHandler | |
|
63 | #endif /* USE_STM322xG_EVAL */ | |
|
64 | ||
|
65 | ||
|
66 | #define DEFAULT_CONFIG 0 | |
|
67 | #define OTHER_CONFIG 1 | |
|
68 | ||
|
69 | /* Exported macro ------------------------------------------------------------*/ | |
|
70 | /* Exported functions ------------------------------------------------------- */ | |
|
71 | ||
|
72 | #endif /* __USBD_CDC_VCP_H */ | |
|
73 | ||
|
74 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,107 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_conf.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief USB Device configuration file | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | #ifndef __USBD_CONF__H__ | |
|
30 | #define __USBD_CONF__H__ | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #include "usb_conf.h" | |
|
34 | ||
|
35 | /** @defgroup USB_CONF_Exported_Defines | |
|
36 | * @{ | |
|
37 | */ | |
|
38 | #define USBD_CFG_MAX_NUM 1 | |
|
39 | #define USBD_ITF_MAX_NUM 1 | |
|
40 | ||
|
41 | #define USBD_SELF_POWERED | |
|
42 | ||
|
43 | #define USB_MAX_STR_DESC_SIZ 255 | |
|
44 | ||
|
45 | /** @defgroup USB_VCP_Class_Layer_Parameter | |
|
46 | * @{ | |
|
47 | */ | |
|
48 | #define CDC_IN_EP 0x81 /* EP1 for data IN */ | |
|
49 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ | |
|
50 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ | |
|
51 | ||
|
52 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ | |
|
53 | #ifdef USE_USB_OTG_HS | |
|
54 | #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ | |
|
55 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ | |
|
56 | ||
|
57 | #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */ | |
|
58 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: | |
|
59 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */ | |
|
60 | #else | |
|
61 | #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ | |
|
62 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ | |
|
63 | ||
|
64 | #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */ | |
|
65 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: | |
|
66 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */ | |
|
67 | #endif /* USE_USB_OTG_HS */ | |
|
68 | ||
|
69 | #define APP_FOPS VCP_fops | |
|
70 | /** | |
|
71 | * @} | |
|
72 | */ | |
|
73 | ||
|
74 | /** @defgroup USB_CONF_Exported_Types | |
|
75 | * @{ | |
|
76 | */ | |
|
77 | /** | |
|
78 | * @} | |
|
79 | */ | |
|
80 | ||
|
81 | ||
|
82 | /** @defgroup USB_CONF_Exported_Macros | |
|
83 | * @{ | |
|
84 | */ | |
|
85 | /** | |
|
86 | * @} | |
|
87 | */ | |
|
88 | ||
|
89 | /** @defgroup USB_CONF_Exported_Variables | |
|
90 | * @{ | |
|
91 | */ | |
|
92 | /** | |
|
93 | * @} | |
|
94 | */ | |
|
95 | ||
|
96 | /** @defgroup USB_CONF_Exported_FunctionsPrototype | |
|
97 | * @{ | |
|
98 | */ | |
|
99 | /** | |
|
100 | * @} | |
|
101 | */ | |
|
102 | ||
|
103 | ||
|
104 | #endif //__USBD_CONF__H__ | |
|
105 | ||
|
106 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
|
107 |
@@ -0,0 +1,322 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_desc.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief This file provides the USBD descriptors and string formating method. | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Includes ------------------------------------------------------------------*/ | |
|
29 | #include "usbd_core.h" | |
|
30 | #include "usbd_desc.h" | |
|
31 | #include "usbd_req.h" | |
|
32 | #include "usbd_conf.h" | |
|
33 | #include "usb_regs.h" | |
|
34 | ||
|
35 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
36 | * @{ | |
|
37 | */ | |
|
38 | ||
|
39 | ||
|
40 | /** @defgroup USBD_DESC | |
|
41 | * @brief USBD descriptors module | |
|
42 | * @{ | |
|
43 | */ | |
|
44 | ||
|
45 | /** @defgroup USBD_DESC_Private_TypesDefinitions | |
|
46 | * @{ | |
|
47 | */ | |
|
48 | /** | |
|
49 | * @} | |
|
50 | */ | |
|
51 | ||
|
52 | ||
|
53 | /** @defgroup USBD_DESC_Private_Defines | |
|
54 | * @{ | |
|
55 | */ | |
|
56 | #define USBD_VID 0x0483 | |
|
57 | ||
|
58 | #define USBD_PID 0x5740 | |
|
59 | ||
|
60 | /** @defgroup USB_String_Descriptors | |
|
61 | * @{ | |
|
62 | */ | |
|
63 | #define USBD_LANGID_STRING 0x409 | |
|
64 | #define USBD_MANUFACTURER_STRING "STMicroelectronics" | |
|
65 | ||
|
66 | #define USBD_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS mode" | |
|
67 | #define USBD_SERIALNUMBER_HS_STRING "00000000050B" | |
|
68 | ||
|
69 | #define USBD_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode" | |
|
70 | #define USBD_SERIALNUMBER_FS_STRING "00000000050C" | |
|
71 | ||
|
72 | #define USBD_CONFIGURATION_HS_STRING "VCP Config" | |
|
73 | #define USBD_INTERFACE_HS_STRING "VCP Interface" | |
|
74 | ||
|
75 | #define USBD_CONFIGURATION_FS_STRING "VCP Config" | |
|
76 | #define USBD_INTERFACE_FS_STRING "VCP Interface" | |
|
77 | /** | |
|
78 | * @} | |
|
79 | */ | |
|
80 | ||
|
81 | ||
|
82 | /** @defgroup USBD_DESC_Private_Macros | |
|
83 | * @{ | |
|
84 | */ | |
|
85 | /** | |
|
86 | * @} | |
|
87 | */ | |
|
88 | ||
|
89 | ||
|
90 | /** @defgroup USBD_DESC_Private_Variables | |
|
91 | * @{ | |
|
92 | */ | |
|
93 | ||
|
94 | USBD_DEVICE USR_desc = | |
|
95 | { | |
|
96 | USBD_USR_DeviceDescriptor, | |
|
97 | USBD_USR_LangIDStrDescriptor, | |
|
98 | USBD_USR_ManufacturerStrDescriptor, | |
|
99 | USBD_USR_ProductStrDescriptor, | |
|
100 | USBD_USR_SerialStrDescriptor, | |
|
101 | USBD_USR_ConfigStrDescriptor, | |
|
102 | USBD_USR_InterfaceStrDescriptor, | |
|
103 | ||
|
104 | }; | |
|
105 | ||
|
106 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
107 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | |
|
108 | #pragma data_alignment=4 | |
|
109 | #endif | |
|
110 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
111 | /* USB Standard Device Descriptor */ | |
|
112 | __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = | |
|
113 | { | |
|
114 | 0x12, /*bLength */ | |
|
115 | USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ | |
|
116 | 0x00, /*bcdUSB */ | |
|
117 | 0x02, | |
|
118 | 0x00, /*bDeviceClass*/ | |
|
119 | 0x00, /*bDeviceSubClass*/ | |
|
120 | 0x00, /*bDeviceProtocol*/ | |
|
121 | USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ | |
|
122 | LOBYTE(USBD_VID), /*idVendor*/ | |
|
123 | HIBYTE(USBD_VID), /*idVendor*/ | |
|
124 | LOBYTE(USBD_PID), /*idVendor*/ | |
|
125 | HIBYTE(USBD_PID), /*idVendor*/ | |
|
126 | 0x00, /*bcdDevice rel. 2.00*/ | |
|
127 | 0x02, | |
|
128 | USBD_IDX_MFC_STR, /*Index of manufacturer string*/ | |
|
129 | USBD_IDX_PRODUCT_STR, /*Index of product string*/ | |
|
130 | USBD_IDX_SERIAL_STR, /*Index of serial number string*/ | |
|
131 | USBD_CFG_MAX_NUM /*bNumConfigurations*/ | |
|
132 | } ; /* USB_DeviceDescriptor */ | |
|
133 | ||
|
134 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
135 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | |
|
136 | #pragma data_alignment=4 | |
|
137 | #endif | |
|
138 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
139 | /* USB Standard Device Descriptor */ | |
|
140 | __ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = | |
|
141 | { | |
|
142 | USB_LEN_DEV_QUALIFIER_DESC, | |
|
143 | USB_DESC_TYPE_DEVICE_QUALIFIER, | |
|
144 | 0x00, | |
|
145 | 0x02, | |
|
146 | 0x00, | |
|
147 | 0x00, | |
|
148 | 0x00, | |
|
149 | 0x40, | |
|
150 | 0x01, | |
|
151 | 0x00, | |
|
152 | }; | |
|
153 | ||
|
154 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
155 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | |
|
156 | #pragma data_alignment=4 | |
|
157 | #endif | |
|
158 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
159 | /* USB Standard Device Descriptor */ | |
|
160 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END = | |
|
161 | { | |
|
162 | USB_SIZ_STRING_LANGID, | |
|
163 | USB_DESC_TYPE_STRING, | |
|
164 | LOBYTE(USBD_LANGID_STRING), | |
|
165 | HIBYTE(USBD_LANGID_STRING), | |
|
166 | }; | |
|
167 | /** | |
|
168 | * @} | |
|
169 | */ | |
|
170 | ||
|
171 | ||
|
172 | /** @defgroup USBD_DESC_Private_FunctionPrototypes | |
|
173 | * @{ | |
|
174 | */ | |
|
175 | /** | |
|
176 | * @} | |
|
177 | */ | |
|
178 | ||
|
179 | ||
|
180 | /** @defgroup USBD_DESC_Private_Functions | |
|
181 | * @{ | |
|
182 | */ | |
|
183 | ||
|
184 | /** | |
|
185 | * @brief USBD_USR_DeviceDescriptor | |
|
186 | * return the device descriptor | |
|
187 | * @param speed : current device speed | |
|
188 | * @param length : pointer to data length variable | |
|
189 | * @retval pointer to descriptor buffer | |
|
190 | */ | |
|
191 | uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) | |
|
192 | { | |
|
193 | *length = sizeof(USBD_DeviceDesc); | |
|
194 | return USBD_DeviceDesc; | |
|
195 | } | |
|
196 | ||
|
197 | /** | |
|
198 | * @brief USBD_USR_LangIDStrDescriptor | |
|
199 | * return the LangID string descriptor | |
|
200 | * @param speed : current device speed | |
|
201 | * @param length : pointer to data length variable | |
|
202 | * @retval pointer to descriptor buffer | |
|
203 | */ | |
|
204 | uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) | |
|
205 | { | |
|
206 | *length = sizeof(USBD_LangIDDesc); | |
|
207 | return USBD_LangIDDesc; | |
|
208 | } | |
|
209 | ||
|
210 | ||
|
211 | /** | |
|
212 | * @brief USBD_USR_ProductStrDescriptor | |
|
213 | * return the product string descriptor | |
|
214 | * @param speed : current device speed | |
|
215 | * @param length : pointer to data length variable | |
|
216 | * @retval pointer to descriptor buffer | |
|
217 | */ | |
|
218 | uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length) | |
|
219 | { | |
|
220 | ||
|
221 | ||
|
222 | if(speed == 0) | |
|
223 | { | |
|
224 | USBD_GetString (USBD_PRODUCT_HS_STRING, USBD_StrDesc, length); | |
|
225 | } | |
|
226 | else | |
|
227 | { | |
|
228 | USBD_GetString (USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); | |
|
229 | } | |
|
230 | return USBD_StrDesc; | |
|
231 | } | |
|
232 | ||
|
233 | /** | |
|
234 | * @brief USBD_USR_ManufacturerStrDescriptor | |
|
235 | * return the manufacturer string descriptor | |
|
236 | * @param speed : current device speed | |
|
237 | * @param length : pointer to data length variable | |
|
238 | * @retval pointer to descriptor buffer | |
|
239 | */ | |
|
240 | uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length) | |
|
241 | { | |
|
242 | USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | |
|
243 | return USBD_StrDesc; | |
|
244 | } | |
|
245 | ||
|
246 | /** | |
|
247 | * @brief USBD_USR_SerialStrDescriptor | |
|
248 | * return the serial number string descriptor | |
|
249 | * @param speed : current device speed | |
|
250 | * @param length : pointer to data length variable | |
|
251 | * @retval pointer to descriptor buffer | |
|
252 | */ | |
|
253 | uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length) | |
|
254 | { | |
|
255 | if(speed == USB_OTG_SPEED_HIGH) | |
|
256 | { | |
|
257 | USBD_GetString (USBD_SERIALNUMBER_HS_STRING, USBD_StrDesc, length); | |
|
258 | } | |
|
259 | else | |
|
260 | { | |
|
261 | USBD_GetString (USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length); | |
|
262 | } | |
|
263 | return USBD_StrDesc; | |
|
264 | } | |
|
265 | ||
|
266 | /** | |
|
267 | * @brief USBD_USR_ConfigStrDescriptor | |
|
268 | * return the configuration string descriptor | |
|
269 | * @param speed : current device speed | |
|
270 | * @param length : pointer to data length variable | |
|
271 | * @retval pointer to descriptor buffer | |
|
272 | */ | |
|
273 | uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) | |
|
274 | { | |
|
275 | if(speed == USB_OTG_SPEED_HIGH) | |
|
276 | { | |
|
277 | USBD_GetString (USBD_CONFIGURATION_HS_STRING, USBD_StrDesc, length); | |
|
278 | } | |
|
279 | else | |
|
280 | { | |
|
281 | USBD_GetString (USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); | |
|
282 | } | |
|
283 | return USBD_StrDesc; | |
|
284 | } | |
|
285 | ||
|
286 | ||
|
287 | /** | |
|
288 | * @brief USBD_USR_InterfaceStrDescriptor | |
|
289 | * return the interface string descriptor | |
|
290 | * @param speed : current device speed | |
|
291 | * @param length : pointer to data length variable | |
|
292 | * @retval pointer to descriptor buffer | |
|
293 | */ | |
|
294 | uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length) | |
|
295 | { | |
|
296 | if(speed == 0) | |
|
297 | { | |
|
298 | USBD_GetString (USBD_INTERFACE_HS_STRING, USBD_StrDesc, length); | |
|
299 | } | |
|
300 | else | |
|
301 | { | |
|
302 | USBD_GetString (USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); | |
|
303 | } | |
|
304 | return USBD_StrDesc; | |
|
305 | } | |
|
306 | ||
|
307 | /** | |
|
308 | * @} | |
|
309 | */ | |
|
310 | ||
|
311 | ||
|
312 | /** | |
|
313 | * @} | |
|
314 | */ | |
|
315 | ||
|
316 | ||
|
317 | /** | |
|
318 | * @} | |
|
319 | */ | |
|
320 | ||
|
321 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
|
322 |
@@ -0,0 +1,120 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_desc.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief header file for the usbd_desc.c file | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | ||
|
30 | #ifndef __USB_DESC_H | |
|
31 | #define __USB_DESC_H | |
|
32 | ||
|
33 | /* Includes ------------------------------------------------------------------*/ | |
|
34 | #include "usbd_def.h" | |
|
35 | ||
|
36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
37 | * @{ | |
|
38 | */ | |
|
39 | ||
|
40 | /** @defgroup USB_DESC | |
|
41 | * @brief general defines for the usb device library file | |
|
42 | * @{ | |
|
43 | */ | |
|
44 | ||
|
45 | /** @defgroup USB_DESC_Exported_Defines | |
|
46 | * @{ | |
|
47 | */ | |
|
48 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 | |
|
49 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 | |
|
50 | #define USB_STRING_DESCRIPTOR_TYPE 0x03 | |
|
51 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 | |
|
52 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 | |
|
53 | #define USB_SIZ_DEVICE_DESC 18 | |
|
54 | #define USB_SIZ_STRING_LANGID 4 | |
|
55 | ||
|
56 | /** | |
|
57 | * @} | |
|
58 | */ | |
|
59 | ||
|
60 | ||
|
61 | /** @defgroup USBD_DESC_Exported_TypesDefinitions | |
|
62 | * @{ | |
|
63 | */ | |
|
64 | /** | |
|
65 | * @} | |
|
66 | */ | |
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | /** @defgroup USBD_DESC_Exported_Macros | |
|
71 | * @{ | |
|
72 | */ | |
|
73 | /** | |
|
74 | * @} | |
|
75 | */ | |
|
76 | ||
|
77 | /** @defgroup USBD_DESC_Exported_Variables | |
|
78 | * @{ | |
|
79 | */ | |
|
80 | extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; | |
|
81 | extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]; | |
|
82 | extern uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC]; | |
|
83 | extern uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; | |
|
84 | extern uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]; | |
|
85 | extern USBD_DEVICE USR_desc; | |
|
86 | /** | |
|
87 | * @} | |
|
88 | */ | |
|
89 | ||
|
90 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype | |
|
91 | * @{ | |
|
92 | */ | |
|
93 | ||
|
94 | ||
|
95 | uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length); | |
|
96 | uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length); | |
|
97 | uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length); | |
|
98 | uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length); | |
|
99 | uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length); | |
|
100 | uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length); | |
|
101 | uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length); | |
|
102 | ||
|
103 | #ifdef USB_SUPPORT_USER_STRING_DESC | |
|
104 | uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length); | |
|
105 | #endif /* USB_SUPPORT_USER_STRING_DESC */ | |
|
106 | ||
|
107 | /** | |
|
108 | * @} | |
|
109 | */ | |
|
110 | ||
|
111 | #endif /* __USBD_DESC_H */ | |
|
112 | ||
|
113 | /** | |
|
114 | * @} | |
|
115 | */ | |
|
116 | ||
|
117 | /** | |
|
118 | * @} | |
|
119 | */ | |
|
120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,203 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_usr.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief This file includes the user application layer | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Includes ------------------------------------------------------------------*/ | |
|
29 | #include "usbd_usr.h" | |
|
30 | #include "usbd_ioreq.h" | |
|
31 | //#include "lcd_log.h" | |
|
32 | ||
|
33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
34 | * @{ | |
|
35 | */ | |
|
36 | ||
|
37 | /** @defgroup USBD_USR | |
|
38 | * @brief This file includes the user application layer | |
|
39 | * @{ | |
|
40 | */ | |
|
41 | ||
|
42 | /** @defgroup USBD_USR_Private_TypesDefinitions | |
|
43 | * @{ | |
|
44 | */ | |
|
45 | /** | |
|
46 | * @} | |
|
47 | */ | |
|
48 | ||
|
49 | ||
|
50 | /** @defgroup USBD_USR_Private_Defines | |
|
51 | * @{ | |
|
52 | */ | |
|
53 | /** | |
|
54 | * @} | |
|
55 | */ | |
|
56 | ||
|
57 | ||
|
58 | /** @defgroup USBD_USR_Private_Macros | |
|
59 | * @{ | |
|
60 | */ | |
|
61 | /** | |
|
62 | * @} | |
|
63 | */ | |
|
64 | ||
|
65 | ||
|
66 | /** @defgroup USBD_USR_Private_Variables | |
|
67 | * @{ | |
|
68 | */ | |
|
69 | ||
|
70 | USBD_Usr_cb_TypeDef USR_cb = | |
|
71 | { | |
|
72 | USBD_USR_Init, | |
|
73 | USBD_USR_DeviceReset, | |
|
74 | USBD_USR_DeviceConfigured, | |
|
75 | USBD_USR_DeviceSuspended, | |
|
76 | USBD_USR_DeviceResumed, | |
|
77 | ||
|
78 | ||
|
79 | USBD_USR_DeviceConnected, | |
|
80 | USBD_USR_DeviceDisconnected, | |
|
81 | }; | |
|
82 | ||
|
83 | /** | |
|
84 | * @} | |
|
85 | */ | |
|
86 | ||
|
87 | /** @defgroup USBD_USR_Private_Constants | |
|
88 | * @{ | |
|
89 | */ | |
|
90 | ||
|
91 | /** | |
|
92 | * @} | |
|
93 | */ | |
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | /** @defgroup USBD_USR_Private_FunctionPrototypes | |
|
98 | * @{ | |
|
99 | */ | |
|
100 | /** | |
|
101 | * @} | |
|
102 | */ | |
|
103 | ||
|
104 | ||
|
105 | /** @defgroup USBD_USR_Private_Functions | |
|
106 | * @{ | |
|
107 | */ | |
|
108 | ||
|
109 | /** | |
|
110 | * @brief USBD_USR_Init | |
|
111 | * Displays the message on LCD for host lib initialization | |
|
112 | * @param None | |
|
113 | * @retval None | |
|
114 | */ | |
|
115 | void USBD_USR_Init(void) | |
|
116 | { | |
|
117 | /* Initialize LEDs */ | |
|
118 | //STM_EVAL_LEDInit(LED1); | |
|
119 | //STM_EVAL_LEDInit(LED2); | |
|
120 | //STM_EVAL_LEDInit(LED3); | |
|
121 | //STM_EVAL_LEDInit(LED4); | |
|
122 | ||
|
123 | } | |
|
124 | ||
|
125 | /** | |
|
126 | * @brief USBD_USR_DeviceReset | |
|
127 | * Displays the message on LCD on device Reset Event | |
|
128 | * @param speed : device speed | |
|
129 | * @retval None | |
|
130 | */ | |
|
131 | void USBD_USR_DeviceReset(uint8_t speed ) | |
|
132 | { | |
|
133 | ||
|
134 | } | |
|
135 | ||
|
136 | ||
|
137 | /** | |
|
138 | * @brief USBD_USR_DeviceConfigured | |
|
139 | * Displays the message on LCD on device configuration Event | |
|
140 | * @param None | |
|
141 | * @retval Staus | |
|
142 | */ | |
|
143 | void USBD_USR_DeviceConfigured (void) | |
|
144 | { | |
|
145 | } | |
|
146 | ||
|
147 | /** | |
|
148 | * @brief USBD_USR_DeviceSuspended | |
|
149 | * Displays the message on LCD on device suspend Event | |
|
150 | * @param None | |
|
151 | * @retval None | |
|
152 | */ | |
|
153 | void USBD_USR_DeviceSuspended(void) | |
|
154 | { | |
|
155 | ||
|
156 | /* Users can do their application actions here for the USB-Reset */ | |
|
157 | } | |
|
158 | ||
|
159 | ||
|
160 | /** | |
|
161 | * @brief USBD_USR_DeviceResumed | |
|
162 | * Displays the message on LCD on device resume Event | |
|
163 | * @param None | |
|
164 | * @retval None | |
|
165 | */ | |
|
166 | void USBD_USR_DeviceResumed(void) | |
|
167 | { | |
|
168 | ||
|
169 | /* Users can do their application actions here for the USB-Reset */ | |
|
170 | } | |
|
171 | ||
|
172 | ||
|
173 | /** | |
|
174 | * @brief USBD_USR_DeviceConnected | |
|
175 | * Displays the message on LCD on device connection Event | |
|
176 | * @param None | |
|
177 | * @retval Staus | |
|
178 | */ | |
|
179 | void USBD_USR_DeviceConnected (void) | |
|
180 | { | |
|
181 | ||
|
182 | } | |
|
183 | ||
|
184 | ||
|
185 | /** | |
|
186 | * @brief USBD_USR_DeviceDisonnected | |
|
187 | * Displays the message on LCD on device disconnection Event | |
|
188 | * @param None | |
|
189 | * @retval Staus | |
|
190 | */ | |
|
191 | void USBD_USR_DeviceDisconnected (void) | |
|
192 | { | |
|
193 | ||
|
194 | } | |
|
195 | /** | |
|
196 | * @} | |
|
197 | */ | |
|
198 | ||
|
199 | /** | |
|
200 | * @} | |
|
201 | */ | |
|
202 | ||
|
203 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
General Comments 0
You need to be logged in to leave comments.
Login now