Skip to content

Commit d613776

Browse files
tannewtdhalbert
authored andcommitted
atmel-samd: Add support for ERR_ABORTED to indicate medium not present.
1 parent ab7da93 commit d613776

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

ports/atmel-samd/usb_mass_storage.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ int32_t usb_msc_disk_eject(uint8_t lun) {
7777
if (lun > 1) {
7878
return ERR_NOT_FOUND;
7979
}
80+
fs_user_mount_t* current_mount = get_vfs(lun);
81+
// Return ERR_NOT_READY if not ready, otherwise ERR_NONE.
82+
if (current_mount == NULL) {
83+
return ERR_ABORTED;
84+
}
8085
// TODO(tannewt): Should we flush here?
8186
return ERR_NONE;
8287
}
@@ -92,11 +97,10 @@ int32_t usb_msc_disk_is_ready(uint8_t lun) {
9297
}
9398

9499
fs_user_mount_t* current_mount = get_vfs(lun);
95-
// Return ERR_NOT_READY if not ready, otherwise ERR_NONE.
96-
if (current_mount != NULL) {
97-
return ERR_NONE;
100+
if (current_mount == NULL) {
101+
return ERR_ABORTED;
98102
}
99-
return ERR_NOT_READY;
103+
return ERR_NONE;
100104
}
101105

102106
/**
@@ -111,9 +115,12 @@ uint8_t *usb_msc_inquiry_info(uint8_t lun) {
111115
for (uint8_t i = 0; i < 36; i++) {
112116
inquiry_info[lun][i] = 0;
113117
}
114-
inquiry_info[lun][1] = (0x1 << 7);
115-
inquiry_info[lun][3] = 0x01;
116-
inquiry_info[lun][4] = 31;
118+
inquiry_info[lun][0] = SCSI_INQ_PQ_CONNECTED | SCSI_INQ_DT_DIR_ACCESS;
119+
// connected, direct access
120+
inquiry_info[lun][1] = SCSI_INQ_RMB; // removable medium
121+
inquiry_info[lun][2] = SCSI_INQ_VER_SPC; // SBC version of SCSI primary commands
122+
inquiry_info[lun][3] = SCSI_INQ_RSP_SPC2;// SPC-2 response format
123+
inquiry_info[lun][4] = 31; // 31 bytes following
117124
return &inquiry_info[lun][0];
118125
}
119126
}

0 commit comments

Comments
 (0)