NUC472_NUC442_BSP V3.03.004
The Board Support Package for NUC472/NUC442
lw_umass.h
Go to the documentation of this file.
1#ifndef _LW_UMASS_H_
2#define _LW_UMASS_H_
3
4#include "diskio.h" /* FatFs lower layer API */
5
15
16#define USB_CLASS_MASS_STORAGE 8
17
18/* Sub Classes */
19#define UMAS_SC_RBC 0x01 /* Typically, flash devices */
20#define UMAS_SC_8020 0x02 /* CD-ROM */
21#define UMAS_SC_QIC 0x03 /* QIC-157 Tapes */
22#define UMAS_SC_UFI 0x04 /* Floppy */
23#define UMAS_SC_8070 0x05 /* Removable media */
24#define UMAS_SC_SCSI 0x06 /* Transparent */
25
26/* Protocols */
27#define UMAS_PR_CBI 0x00 /* Control/Bulk/Interrupt */
28#define UMAS_PR_CB 0x01 /* Control/Bulk w/o interrupt */
29#define UMAS_PR_BULK 0x50 /* bulk only */
30#define UMAS_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
31
32
33/* command block wrapper */
34struct bulk_cb_wrap
35{
36 uint32_t Signature; /* contains 'USBC' */
37 uint32_t Tag; /* unique per command id */
38 uint32_t DataTransferLength; /* size of data */
39 uint8_t Flags; /* direction in bit 0 */
40 uint8_t Lun; /* LUN normally 0 */
41 uint8_t Length; /* of of the CDB */
42 uint8_t CDB[16]; /* max command */
43};
44
45#define UMAS_BULK_CB_WRAP_LEN 31
46#define UMAS_BULK_CB_SIGN 0x43425355 /* spells out USBC */
47#define UMAS_BULK_FLAG_IN 1
48#define UMAS_BULK_FLAG_OUT 0
49
50/* command status wrapper */
51struct bulk_cs_wrap
52{
53 uint32_t Signature; /* should = 'USBS' */
54 uint32_t Tag; /* same as original command */
55 uint32_t Residue; /* amount not transferred */
56 uint8_t Status; /* see below */
57};
58
59#define UMAS_BULK_CS_WRAP_LEN 13
60#define UMAS_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */
61#define UMAS_BULK_STAT_OK 0 /* command passed */
62#define UMAS_BULK_STAT_FAIL 1 /* command failed */
63#define UMAS_BULK_STAT_PHASE 2 /* phase error */
64
65/* bulk-only class specific requests */
66#define UMAS_BULK_RESET_REQUEST 0xff
67#define UMAS_BULK_GET_MAX_LUN 0xfe
68
69
70/*
71 * SCSI opcodes
72 */
73#define TEST_UNIT_READY 0x00
74#define REQUEST_SENSE 0x03
75#define INQUIRY 0x12
76#define MODE_SENSE 0x1a
77#define READ_CAPACITY 0x25
78#define READ_10 0x28
79#define WRITE_10 0x2a
80#define MODE_SENSE_10 0x5a
81
82DRESULT usbh_umas_read(uint8_t *buff, uint32_t sector_no, int number_of_sector);
83DRESULT usbh_umas_write(uint8_t *buff, uint32_t sector_no, int number_of_sector);
84DRESULT usbh_umas_ioctl(int cmd, void *buff);
85int usbh_umas_disk_status(void);
86
88
93int usbh_probe_umass(void);
94 /* end of group NUC472_442_LWHCD_EXPORTED_FUNCTIONS */
96 /* end of group NUC472_442_LWHCD_Driver */
98 /* end of group NUC472_442_Device_Driver */
100
101#endif /* _LW_UMASS_H_ */
102
103/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
104
105
int usbh_probe_umass(void)
Try to probe and initialize an USB mass storage device.
Definition: lw_umass.c:434