Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8e29acf

Browse files
committedOct 4, 2020
first working version of usb host + msc
1 parent ac1d03e commit 8e29acf

File tree

10 files changed

+877
-0
lines changed

10 files changed

+877
-0
lines changed
 
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_msc.c"
4+
5+
#endif /* USBHOST */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_msc_bot.c"
4+
5+
#endif /* USBHOST */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_msc_scsi.c"
4+
5+
#endif /* USBHOST */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_core.c"
4+
5+
#endif /* USBHOST */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_ctlreq.c"
4+
5+
#endif /* USBHOST */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_ioreq.c"
4+
5+
#endif /* USBHOST */
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef USBHOST
2+
3+
#include "usbh_pipes.c"
4+
5+
#endif /* USBHOST */

‎cores/arduino/stm32/usb_host/usbh_conf.c‎

Lines changed: 585 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
/* USER CODE BEGIN Header */
2+
/**
3+
******************************************************************************
4+
* @file : Target/usbh_conf.h
5+
* @version : v1.0_Cube
6+
* @brief : Header for usbh_conf.c file.
7+
******************************************************************************
8+
* @attention
9+
*
10+
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
11+
* All rights reserved.</center></h2>
12+
*
13+
* This software component is licensed by ST under Ultimate Liberty license
14+
* SLA0044, the "License"; You may not use this file except in compliance with
15+
* the License. You may obtain a copy of the License at:
16+
* www.st.com/SLA0044
17+
*
18+
******************************************************************************
19+
*/
20+
/* USER CODE END Header */
21+
22+
/* Define to prevent recursive inclusion -------------------------------------*/
23+
#ifndef __USBH_CONF__H__
24+
#define __USBH_CONF__H__
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
// #define USBHOST
30+
31+
#ifdef USBHOST
32+
/* Includes ------------------------------------------------------------------*/
33+
#include "stm32_def.h"
34+
35+
/* Includes ------------------------------------------------------------------*/
36+
37+
#include <stdio.h>
38+
#include <stdlib.h>
39+
#include <string.h>
40+
// #include "main.h"
41+
42+
// #include "stm32f4xx.h"
43+
// #include "stm32f4xx_hal.h"
44+
45+
/* USER CODE BEGIN INCLUDE */
46+
47+
/* USER CODE END INCLUDE */
48+
49+
/** @addtogroup STM32_USB_HOST_LIBRARY
50+
* @{
51+
*/
52+
53+
/** @defgroup USBH_CONF
54+
* @brief usb host low level driver configuration file
55+
* @{
56+
*/
57+
58+
/** @defgroup USBH_CONF_Exported_Variables USBH_CONF_Exported_Variables
59+
* @brief Public variables.
60+
* @{
61+
*/
62+
63+
/**
64+
* @}
65+
*/
66+
67+
/** @defgroup USBH_CONF_Exported_Defines USBH_CONF_Exported_Defines
68+
* @brief Defines for configuration of the Usb host.
69+
* @{
70+
*/
71+
72+
/*---------- -----------*/
73+
#define USBH_MAX_NUM_ENDPOINTS 2U
74+
75+
/*---------- -----------*/
76+
#define USBH_MAX_NUM_INTERFACES 2U
77+
78+
/*---------- -----------*/
79+
#define USBH_MAX_NUM_CONFIGURATION 2U
80+
81+
/*---------- -----------*/
82+
#define USBH_KEEP_CFG_DESCRIPTOR 2U
83+
84+
/*---------- -----------*/
85+
#define USBH_MAX_NUM_SUPPORTED_CLASS 2U
86+
87+
/*---------- -----------*/
88+
#define USBH_MAX_SIZE_CONFIGURATION 256U
89+
90+
/*---------- -----------*/
91+
#define USBH_MAX_DATA_BUFFER 512U
92+
93+
/*---------- -----------*/
94+
#define USBH_DEBUG_LEVEL 0U
95+
96+
/*---------- -----------*/
97+
#define USBH_USE_OS 0U
98+
99+
/****************************************/
100+
/* #define for FS and HS identification */
101+
#define HOST_HS 0
102+
#define HOST_FS 1
103+
104+
/* Interrupt priority */
105+
#ifndef USBH_IRQ_PRIO
106+
#define USBH_IRQ_PRIO 0
107+
#endif /* USBH_IRQ_PRIO */
108+
#ifndef USBH_IRQ_SUBPRIO
109+
#define USBH_IRQ_SUBPRIO 0
110+
#endif /* USBH_IRQ_SUBPRIO */
111+
112+
#if (USBH_USE_OS == 1)
113+
#include "cmsis_os.h"
114+
#define USBH_PROCESS_PRIO osPriorityNormal
115+
#define USBH_PROCESS_STACK_SIZE ((uint16_t)0)
116+
#endif /* (USBH_USE_OS == 1) */
117+
118+
/**
119+
* @}
120+
*/
121+
122+
/** @defgroup USBH_CONF_Exported_Macros USBH_CONF_Exported_Macros
123+
* @brief Aliases.
124+
* @{
125+
*/
126+
127+
/* Memory management macros */
128+
129+
/** Alias for memory allocation. */
130+
#define USBH_malloc malloc
131+
132+
/** Alias for memory release. */
133+
#define USBH_free free
134+
135+
/** Alias for memory set. */
136+
#define USBH_memset memset
137+
138+
/** Alias for memory copy. */
139+
#define USBH_memcpy memcpy
140+
141+
/* DEBUG macros */
142+
143+
extern void spi_debug(const char *msg, ...);
144+
145+
#if (USBH_DEBUG_LEVEL > 0U)
146+
#define USBH_UsrLog(...) do { \
147+
printf(__VA_ARGS__); \
148+
printf("\n"); \
149+
} while (0)
150+
#else
151+
#define USBH_UsrLog(MSG, ...) spi_debug(MSG __VA_OPT__(,) __VA_ARGS__);
152+
//do {} while (0)
153+
#endif
154+
155+
#if (USBH_DEBUG_LEVEL > 1U)
156+
157+
#define USBH_ErrLog(...) do { \
158+
printf("ERROR: ") ; \
159+
printf(__VA_ARGS__); \
160+
printf("\n"); \
161+
} while (0)
162+
#else
163+
#define USBH_ErrLog(MSG, ...) spi_debug(MSG __VA_OPT__(,) __VA_ARGS__);
164+
//do {} while (0)
165+
#endif
166+
167+
#if (USBH_DEBUG_LEVEL > 2U)
168+
#define USBH_DbgLog(...) do { \
169+
printf("DEBUG : ") ; \
170+
printf(__VA_ARGS__); \
171+
printf("\n"); \
172+
} while (0)
173+
#else
174+
#define USBH_DbgLog(MSG, ...) spi_debug(MSG __VA_OPT__(,) __VA_ARGS__);
175+
//do {} while (0)
176+
#endif
177+
178+
/**
179+
* @}
180+
*/
181+
182+
/** @defgroup USBH_CONF_Exported_Types USBH_CONF_Exported_Types
183+
* @brief Types.
184+
* @{
185+
*/
186+
187+
/**
188+
* @}
189+
*/
190+
191+
/** @defgroup USBH_CONF_Exported_FunctionsPrototype USBH_CONF_Exported_FunctionsPrototype
192+
* @brief Declaration of public functions for Usb host.
193+
* @{
194+
*/
195+
196+
/* Exported functions -------------------------------------------------------*/
197+
198+
/**
199+
* @}
200+
*/
201+
202+
/**
203+
* @}
204+
*/
205+
206+
/**
207+
* @}
208+
*/
209+
210+
#endif /* USBHOST */
211+
212+
#ifdef __cplusplus
213+
}
214+
#endif
215+
216+
#endif /* __USBH_CONF__H__ */
217+
218+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

‎tools/platformio-build.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def configure_application_offset(mcu, upload_protocol):
187187
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "OpenAMP"),
188188
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "hid"),
189189
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "cdc"),
190+
join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb_host"),
190191
join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Inc"),
191192
join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Src"),
192193
join(FRAMEWORK_DIR, "system", series),
@@ -208,6 +209,44 @@ def configure_application_offset(mcu, upload_protocol):
208209
"Core",
209210
"Src",
210211
),
212+
join(
213+
FRAMEWORK_DIR,
214+
"system",
215+
"Middlewares",
216+
"ST",
217+
"STM32_USB_Host_Library",
218+
"Core",
219+
"Inc",
220+
),
221+
join(
222+
FRAMEWORK_DIR,
223+
"system",
224+
"Middlewares",
225+
"ST",
226+
"STM32_USB_Host_Library",
227+
"Core",
228+
"Src",
229+
),
230+
join(
231+
FRAMEWORK_DIR,
232+
"system",
233+
"Middlewares",
234+
"ST",
235+
"STM32_USB_Host_Library",
236+
"Class",
237+
"MSC",
238+
"Inc",
239+
),
240+
join(
241+
FRAMEWORK_DIR,
242+
"system",
243+
"Middlewares",
244+
"ST",
245+
"STM32_USB_Host_Library",
246+
"Class",
247+
"MSC",
248+
"Src",
249+
),
211250
join(
212251
FRAMEWORK_DIR,
213252
"system",

0 commit comments

Comments
 (0)
Please sign in to comment.