File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ extern "C" uint8_t usb_host_msd_get_lun_num();
26
26
extern " C" uint32_t usb_host_msd_get_num_of_blocks (uint8_t lun);
27
27
extern " C" uint32_t usb_host_msd_get_block_size (uint8_t lun);
28
28
extern " C" void usb_host_msd_attach_mnt_cbk (void (*fnc)(void ));
29
-
29
+ extern " C " void usb_host_msd_attach_umnt_cbk ( void (*fnc)( void ));
30
30
31
31
/* -------------------------------------------------------------------------- */
32
32
/* CONSTRUCTOR */
@@ -224,4 +224,11 @@ const char *USBHostMSD::get_type() const {
224
224
225
225
bool USBHostMSD::attach_detected_callback (void (*cbk)()) {
226
226
usb_host_msd_attach_mnt_cbk (cbk);
227
+ return true ;
228
+ }
229
+
230
+ bool USBHostMSD::attach_removed_callback (void (*cbk)()) {
231
+ usb_host_msd_attach_umnt_cbk (cbk);
232
+ return true ;
227
233
}
234
+
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class USBHostMSD : public BlockDevice {
47
47
virtual bool select_lun (uint8_t lun);
48
48
virtual uint8_t get_lun_num ();
49
49
bool attach_detected_callback (void (*cbk)());
50
+ bool attach_removed_callback (void (*cbk)());
50
51
51
52
private:
52
53
uint8_t get_lun ();
Original file line number Diff line number Diff line change @@ -68,11 +68,16 @@ uint32_t usb_host_msd_get_block_size(uint8_t lun) {
68
68
}
69
69
70
70
static void (* mount_fnc )(void ) = NULL ;
71
+ static void (* unmount_fnc )(void ) = NULL ;
71
72
72
73
void usb_host_msd_attach_mnt_cbk (void (* fnc )(void )) {
73
74
mount_fnc = fnc ;
74
75
}
75
76
77
+ void usb_host_msd_attach_umnt_cbk (void (* fnc )(void )) {
78
+ unmount_fnc = fnc ;
79
+ }
80
+
76
81
//--------------------------------------------------------------------+
77
82
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
78
83
//--------------------------------------------------------------------+
@@ -167,6 +172,10 @@ void tuh_msc_umount_cb(uint8_t dev_addr) {
167
172
168
173
device_address = -1 ;
169
174
175
+ if (unmount_fnc != NULL ) {
176
+ unmount_fnc ();
177
+ }
178
+
170
179
// uint8_t phy_disk = dev_addr-1;
171
180
//
172
181
// f_mount(phy_disk, NULL); // unmount disk
You can’t perform that action at this time.
0 commit comments