BRT Community

General Category => Discussion - MCU => Topic started by: A.STARR@NIWA.CO.NZ on May 05, 2021, 03:40:16 AM

Title: FT90X USBH BOMS Example - USBH_finalise() missing?
Post by: A.STARR@NIWA.CO.NZ on May 05, 2021, 03:40:16 AM
Hi all,

I'm developing a product using the FT908 that serves as a bridge between a sensor (that emulates a USB flash drive) and an SDI-12 recorder. I need to be able to deactivate the USB host port, and I see there is a function in the documentation for doing this: USBH_finalise(). It has a prototype in the ft900_usbh.h header file, but the function itself is not in usbh.c. I've tried using sys_disable(sys_device_usb_host), but this doesn't seem to have any effect.

Can anyone shed any light here?

Thanks in advance!
Title: Re: FT90X USBH BOMS Example - USBH_finalise() missing?
Post by: BRT Community on May 05, 2021, 04:57:18 PM
Hello,

I checked this and also couldn't see the source code.

I will ask for this to be added into the APIs.

Something like the following sequence in USBH_finalise() would be required to deactivate the USB Host:

{
// Remove all devices/interfaces/endpoints from root hub.
usbh_hub_port_remove(NULL, 1);
usbh_hw_disable_int();
interrupt_detach(interrupt_usb_host);

CRITICAL_SECTION_BEGIN
               usbh_intr_xfer = 0;
               usbh_intr_port = 0;
CRITICAL_SECTION_END

// Clear Status Register
usbh_hw_clrsts();
usbh_hw_stop();
usbh_hw_reset();
sys_disable(sys_device_usb_host);
}

Please test this out and provide any feedback.
You can modify the source APIs to add this.
See BRT TN 002 Modifying FT9xx API Functions (http://brtchip.com/wp-content/uploads/Support/Documentation/Technical_Notes/ICs/MCU/BRT_TN_002_Modifying-FT9xx-API-Functions.pdf) for details on how to do this.
Simply copy the source .c into your project and it will override the library version.

To activate the USB host port again, you would then perform USBH_initialise().

Best Regards,
BRT Community
Title: Re: FT90X USBH BOMS Example - USBH_finalise() missing?
Post by: A.STARR@NIWA.CO.NZ on May 06, 2021, 01:53:28 AM
Thanks very much, this worked fine.

Just a note: I had to enable the compliation of the usbh_hw_disable_int() function in usbh.c, by changing the preceding #if 0 to #if 1

Thanks again