|
| 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>© 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 | + |
0 commit comments