新手上路
- 积分
- 31
- 金钱
- 31
- 注册时间
- 2021-4-3
- 在线时间
- 7 小时
|
1金钱
正点原子的usb从机存储设备代码支持3种存储介质,我删掉spiflash和nandflash后,插到电脑无法识别usb。
#include "usbd_msc_mem.h"
#include "usb_conf.h"
#include "sdio_sdcard.h"
#define STORAGE_LUN_NBR 1
#define STORAGE_BLK_NBR 0x10000
#define STORAGE_BLK_SIZ 0x200
const int8_t STORAGE_Inquirydata[] = {
/* LUN 0 */
0x00,
0x80,
0x02,
0x02,
(USBD_STD_INQUIRY_LENGTH - 5),
0x00,
0x00,
0x00,
'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
'0', '.', '0' ,'1' /* Version : 4 Bytes */
};
int8_t STORAGE_Init (uint8_t lun);
int8_t STORAGE_GetCapacity (uint8_t lun,uint32_t *block_num,uint32_t *block_size);
int8_t STORAGE_IsReady (uint8_t lun);
int8_t STORAGE_IsWriteProtected (uint8_t lun);
int8_t STORAGE_Read (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len);
int8_t STORAGE_Write (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len);
int8_t STORAGE_GetMaxLun (void);
USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops =
{
STORAGE_Init,
STORAGE_GetCapacity,
STORAGE_IsReady,
STORAGE_IsWriteProtected,
STORAGE_Read,
STORAGE_Write,
STORAGE_GetMaxLun,
(int8_t *)STORAGE_Inquirydata,
};
USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops=&USBD_MICRO_SDIO_fops;//Ö¸ÏòUSBD_MICRO_SDIO_fops½á11ìå.
int8_t STORAGE_Init (uint8_t lun)
{
u8 res=0;
res=SD_Init();
return res;
}
int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_size)
{
*block_size=512;
*block_num=SDCardInfo.CardCapacity/512;
return 0;
}
int8_t STORAGE_IsReady (uint8_t lun)
{
USB_STATUS_REG|=0X10;//±ê¼ÇÂÖÑˉ
return 0;
}
int8_t STORAGE_IsWriteProtected (uint8_t lun)
{
return 0;
}
int8_t STORAGE_Read (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len)
{
int8_t res=0;
USB_STATUS_REG|=0X02;//±ê¼ÇÕyÔú¶áêy¾Y
res=SD_ReadDisk(buf,blk_addr,blk_len);
if(res)
{
USB_STATUS_REG|=0X08;//¶á′íÎó!
}
return res;
}
int8_t STORAGE_Write (uint8_t lun,uint8_t *buf,uint32_t blk_addr,uint16_t blk_len)
{
int8_t res=0;
USB_STATUS_REG|=0X01;//±ê¼ÇÕyÔúD′êy¾Y
res=SD_WriteDisk(buf,blk_addr,blk_len);
if(res)
{
USB_STATUS_REG|=0X04;//D′′íÎó!
}
return res;
}
int8_t STORAGE_GetMaxLun (void)
{
return (STORAGE_LUN_NBR-1);
}
这是我的代码,哪里有问题
|
|