Skip to content

Commit 0b9e38e

Browse files
author
Rudi Horn
committed
added default msc interface
1 parent 1c247ed commit 0b9e38e

File tree

3 files changed

+276
-1
lines changed

3 files changed

+276
-1
lines changed

cores/arduino/stm32/usb/msc/usbd_msc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ EndBSPDependencies */
4040

4141
/* Includes ------------------------------------------------------------------*/
4242
#include "usbd_msc.h"
43+
#include "usbd_msc_storage_if.h"
4344

4445

4546
/** @addtogroup STM32_USB_DEVICE_LIBRARY
@@ -268,7 +269,7 @@ __ALIGN_BEGIN uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]
268269
USBD_MSC_BOT_HandleTypeDef msc_handle_dat;
269270
USBD_MSC_BOT_HandleTypeDef *msc_handle = &msc_handle_dat;
270271

271-
USBD_StorageTypeDef *msc_storage = NULL;
272+
USBD_StorageTypeDef *msc_storage = &USBD_MSC_Template_fops;
272273

273274
/** @defgroup MSC_CORE_Private_Functions
274275
* @{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/**
2+
******************************************************************************
3+
* @file usbd_msc_storage_template.c
4+
* @author MCD Application Team
5+
* @brief Memory management layer
6+
******************************************************************************
7+
* @attention
8+
*
9+
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
10+
* All rights reserved.</center></h2>
11+
*
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
16+
*
17+
******************************************************************************
18+
*/
19+
20+
/* BSPDependencies
21+
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
22+
- "stm32xxxxx_{eval}{discovery}_io.c"
23+
- "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c"
24+
EndBSPDependencies */
25+
26+
/* Includes ------------------------------------------------------------------*/
27+
#include "usbd_msc_storage_template.h"
28+
29+
30+
/* Private typedef -----------------------------------------------------------*/
31+
/* Private define ------------------------------------------------------------*/
32+
/* Private macro -------------------------------------------------------------*/
33+
/* Private variables ---------------------------------------------------------*/
34+
/* Private function prototypes -----------------------------------------------*/
35+
/* Extern function prototypes ------------------------------------------------*/
36+
/* Private functions ---------------------------------------------------------*/
37+
38+
#define STORAGE_LUN_NBR 1U
39+
#define STORAGE_BLK_NBR 0x10000U
40+
#define STORAGE_BLK_SIZ 0x200U
41+
42+
int8_t STORAGE_Init(uint8_t lun);
43+
44+
int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num,
45+
uint16_t *block_size);
46+
47+
int8_t STORAGE_IsReady(uint8_t lun);
48+
49+
int8_t STORAGE_IsWriteProtected(uint8_t lun);
50+
51+
int8_t STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr,
52+
uint16_t blk_len);
53+
54+
int8_t STORAGE_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr,
55+
uint16_t blk_len);
56+
57+
int8_t STORAGE_GetMaxLun(void);
58+
59+
/* USB Mass storage Standard Inquiry Data */
60+
int8_t STORAGE_Inquirydata[] = /* 36 */
61+
{
62+
63+
/* LUN 0 */
64+
0x00,
65+
0x80,
66+
0x02,
67+
0x02,
68+
(STANDARD_INQUIRY_DATA_LEN - 5),
69+
0x00,
70+
0x00,
71+
0x00,
72+
'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
73+
'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
74+
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
75+
'0', '.', '0', '1', /* Version : 4 Bytes */
76+
};
77+
78+
USBD_StorageTypeDef USBD_MSC_Template_fops =
79+
{
80+
STORAGE_Init,
81+
STORAGE_GetCapacity,
82+
STORAGE_IsReady,
83+
STORAGE_IsWriteProtected,
84+
STORAGE_Read,
85+
STORAGE_Write,
86+
STORAGE_GetMaxLun,
87+
STORAGE_Inquirydata,
88+
89+
};
90+
/*******************************************************************************
91+
* Function Name : Read_Memory
92+
* Description : Handle the Read operation from the microSD card.
93+
* Input : None.
94+
* Output : None.
95+
* Return : None.
96+
*******************************************************************************/
97+
int8_t STORAGE_Init(uint8_t lun)
98+
{
99+
return (0);
100+
}
101+
102+
/*******************************************************************************
103+
* Function Name : Read_Memory
104+
* Description : Handle the Read operation from the STORAGE card.
105+
* Input : None.
106+
* Output : None.
107+
* Return : None.
108+
*******************************************************************************/
109+
int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size)
110+
{
111+
*block_num = STORAGE_BLK_NBR;
112+
*block_size = STORAGE_BLK_SIZ;
113+
return (0);
114+
}
115+
116+
/*******************************************************************************
117+
* Function Name : Read_Memory
118+
* Description : Handle the Read operation from the STORAGE card.
119+
* Input : None.
120+
* Output : None.
121+
* Return : None.
122+
*******************************************************************************/
123+
int8_t STORAGE_IsReady(uint8_t lun)
124+
{
125+
return (0);
126+
}
127+
128+
/*******************************************************************************
129+
* Function Name : Read_Memory
130+
* Description : Handle the Read operation from the STORAGE card.
131+
* Input : None.
132+
* Output : None.
133+
* Return : None.
134+
*******************************************************************************/
135+
int8_t STORAGE_IsWriteProtected(uint8_t lun)
136+
{
137+
return 0;
138+
}
139+
140+
/*******************************************************************************
141+
* Function Name : Read_Memory
142+
* Description : Handle the Read operation from the STORAGE card.
143+
* Input : None.
144+
* Output : None.
145+
* Return : None.
146+
*******************************************************************************/
147+
int8_t STORAGE_Read(uint8_t lun, uint8_t *buf,
148+
uint32_t blk_addr, uint16_t blk_len)
149+
{
150+
return 0;
151+
}
152+
/*******************************************************************************
153+
* Function Name : Write_Memory
154+
* Description : Handle the Write operation to the STORAGE card.
155+
* Input : None.
156+
* Output : None.
157+
* Return : None.
158+
*******************************************************************************/
159+
int8_t STORAGE_Write(uint8_t lun, uint8_t *buf,
160+
uint32_t blk_addr, uint16_t blk_len)
161+
{
162+
return (0);
163+
}
164+
/*******************************************************************************
165+
* Function Name : Write_Memory
166+
* Description : Handle the Write operation to the STORAGE card.
167+
* Input : None.
168+
* Output : None.
169+
* Return : None.
170+
*******************************************************************************/
171+
int8_t STORAGE_GetMaxLun(void)
172+
{
173+
return (STORAGE_LUN_NBR - 1);
174+
}
175+
176+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
177+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
******************************************************************************
3+
* @file usbd_msc_storage.h
4+
* @author MCD Application Team
5+
* @brief Header file for the usbd_msc_storage.c file
6+
******************************************************************************
7+
* @attention
8+
*
9+
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
10+
* All rights reserved.</center></h2>
11+
*
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
16+
*
17+
******************************************************************************
18+
*/
19+
20+
/* Define to prevent recursive inclusion -------------------------------------*/
21+
#ifndef __USBD_MSC_STORAGE_H
22+
#define __USBD_MSC_STORAGE_H
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/* Includes ------------------------------------------------------------------*/
29+
#include "usbd_msc.h"
30+
31+
/** @addtogroup STM32_USB_DEVICE_LIBRARY
32+
* @{
33+
*/
34+
35+
/** @defgroup USBD_STORAGE
36+
* @brief header file for the usbd_msc_storage.c file
37+
* @{
38+
*/
39+
40+
/** @defgroup USBD_STORAGE_Exported_Defines
41+
* @{
42+
*/
43+
/**
44+
* @}
45+
*/
46+
47+
48+
/** @defgroup USBD_STORAGE_Exported_Types
49+
* @{
50+
*/
51+
52+
53+
/**
54+
* @}
55+
*/
56+
57+
58+
59+
/** @defgroup USBD_STORAGE_Exported_Macros
60+
* @{
61+
*/
62+
63+
/**
64+
* @}
65+
*/
66+
67+
/** @defgroup USBD_STORAGE_Exported_Variables
68+
* @{
69+
*/
70+
extern USBD_StorageTypeDef USBD_MSC_Template_fops;
71+
/**
72+
* @}
73+
*/
74+
75+
/** @defgroup USBD_STORAGE_Exported_FunctionsPrototype
76+
* @{
77+
*/
78+
79+
80+
/**
81+
* @}
82+
*/
83+
84+
#ifdef __cplusplus
85+
}
86+
#endif
87+
88+
#endif /* __USBD_MSC_STORAGE_H */
89+
90+
/**
91+
* @}
92+
*/
93+
94+
/**
95+
* @}
96+
*/
97+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)