Merge pull request #93 from zyp/master
[fw/stlink] / example / stm32f4 / STM32_USB_Device_Library / Class / msc / src / usbd_storage_template.c
1 /**
2   ******************************************************************************
3   * @file    usbd_storage_template.c
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    22-July-2011
7   * @brief   Memory management layer
8   ******************************************************************************
9   * @attention
10   *
11   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17   *
18   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19   ******************************************************************************
20   */ 
21
22
23 /* Includes ------------------------------------------------------------------*/
24 #include "usbd_msc_mem.h"
25
26 /* Private typedef -----------------------------------------------------------*/
27 /* Private define ------------------------------------------------------------*/
28 /* Private macro -------------------------------------------------------------*/
29 /* Private variables ---------------------------------------------------------*/
30 /* Private function prototypes -----------------------------------------------*/
31 /* Extern function prototypes ------------------------------------------------*/
32 /* Private functions ---------------------------------------------------------*/
33
34 #define STORAGE_LUN_NBR                  1                    
35
36 int8_t STORAGE_Init (uint8_t lun);
37
38 int8_t STORAGE_GetCapacity (uint8_t lun, 
39                            uint32_t *block_num, 
40                            uint16_t *block_size);
41
42 int8_t  STORAGE_IsReady (uint8_t lun);
43
44 int8_t  STORAGE_IsWriteProtected (uint8_t lun);
45
46 int8_t STORAGE_Read (uint8_t lun, 
47                         uint8_t *buf, 
48                         uint32_t blk_addr,
49                         uint16_t blk_len);
50
51 int8_t STORAGE_Write (uint8_t lun, 
52                         uint8_t *buf, 
53                         uint32_t blk_addr,
54                         uint16_t blk_len);
55
56 int8_t STORAGE_GetMaxLun (void);
57
58 /* USB Mass storage Standard Inquiry Data */
59 const int8_t  STORAGE_Inquirydata[] = {//36
60   
61   /* LUN 0 */
62   0x00,         
63   0x80,         
64   0x02,         
65   0x02,
66   (USBD_STD_INQUIRY_LENGTH - 5),
67   0x00,
68   0x00, 
69   0x00,
70   'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
71   'P', 'r', 'o', 'd', 'u', 't', ' ', ' ', /* Product      : 16 Bytes */
72   ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
73   '0', '.', '0' ,'1',                     /* Version      : 4 Bytes */
74 }; 
75
76 USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops =
77 {
78   STORAGE_Init,
79   STORAGE_GetCapacity,
80   STORAGE_IsReady,
81   STORAGE_IsWriteProtected,
82   STORAGE_Read,
83   STORAGE_Write,
84   STORAGE_GetMaxLun,
85   STORAGE_Inquirydata,
86   
87 };
88
89 USBD_STORAGE_cb_TypeDef  *USBD_STORAGE_fops = &USBD_MICRO_SDIO_fops;
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   return (0);
112 }
113
114 /*******************************************************************************
115 * Function Name  : Read_Memory
116 * Description    : Handle the Read operation from the STORAGE card.
117 * Input          : None.
118 * Output         : None.
119 * Return         : None.
120 *******************************************************************************/
121 int8_t  STORAGE_IsReady (uint8_t lun)
122 {
123   return (0);
124 }
125
126 /*******************************************************************************
127 * Function Name  : Read_Memory
128 * Description    : Handle the Read operation from the STORAGE card.
129 * Input          : None.
130 * Output         : None.
131 * Return         : None.
132 *******************************************************************************/
133 int8_t  STORAGE_IsWriteProtected (uint8_t lun)
134 {
135   return  0;
136 }
137
138 /*******************************************************************************
139 * Function Name  : Read_Memory
140 * Description    : Handle the Read operation from the STORAGE card.
141 * Input          : None.
142 * Output         : None.
143 * Return         : None.
144 *******************************************************************************/
145 int8_t STORAGE_Read (uint8_t lun, 
146                  uint8_t *buf, 
147                  uint32_t blk_addr,                       
148                  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, 
160                   uint8_t *buf, 
161                   uint32_t blk_addr,
162                   uint16_t blk_len)
163 {
164   return (0);
165 }
166 /*******************************************************************************
167 * Function Name  : Write_Memory
168 * Description    : Handle the Write operation to the STORAGE card.
169 * Input          : None.
170 * Output         : None.
171 * Return         : None.
172 *******************************************************************************/
173 int8_t STORAGE_GetMaxLun (void)
174 {
175   return (STORAGE_LUN_NBR - 1);
176 }
177
178 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
179