File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 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();
2626extern " C" uint32_t usb_host_msd_get_num_of_blocks (uint8_t lun);
2727extern " C" uint32_t usb_host_msd_get_block_size (uint8_t lun);
2828extern " 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 ));
3030
3131/* -------------------------------------------------------------------------- */
3232/* CONSTRUCTOR */
@@ -224,4 +224,11 @@ const char *USBHostMSD::get_type() const {
224224
225225bool USBHostMSD::attach_detected_callback (void (*cbk)()) {
226226 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 ;
227233}
234+
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class USBHostMSD : public BlockDevice {
4747 virtual bool select_lun (uint8_t lun);
4848 virtual uint8_t get_lun_num ();
4949 bool attach_detected_callback (void (*cbk)());
50+ bool attach_removed_callback (void (*cbk)());
5051
5152private:
5253 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) {
6868}
6969
7070static void (* mount_fnc )(void ) = NULL ;
71+ static void (* unmount_fnc )(void ) = NULL ;
7172
7273void usb_host_msd_attach_mnt_cbk (void (* fnc )(void )) {
7374 mount_fnc = fnc ;
7475}
7576
77+ void usb_host_msd_attach_umnt_cbk (void (* fnc )(void )) {
78+ unmount_fnc = fnc ;
79+ }
80+
7681//--------------------------------------------------------------------+
7782// MACRO TYPEDEF CONSTANT ENUM DECLARATION
7883//--------------------------------------------------------------------+
@@ -167,6 +172,10 @@ void tuh_msc_umount_cb(uint8_t dev_addr) {
167172
168173 device_address = -1 ;
169174
175+ if (unmount_fnc != NULL ) {
176+ unmount_fnc ();
177+ }
178+
170179// uint8_t phy_disk = dev_addr-1;
171180//
172181// f_mount(phy_disk, NULL); // unmount disk
You can’t perform that action at this time.
0 commit comments