I am trying to implement USB host in LPC1768 and have written a code which initiliazes a mass storage device and creates a file in the same.Unfortunately,the code doesn't works and am not able to decode the issues with it.
#include <stdio.h> #include "lpc17xx.h" #include "rl_fs.h" #include "cmsis_os.h" #include "rl_usb.h" #include "USBH_MSC.h" int main (void) { usbStatus usb_status; int32_t msc_status; FILE *f; uint8_t con = 0U; usb_status = USBH_Initialize (0U); // Initialize USB Host 0 if (usb_status != usbOK) { for (;;) { LPC_GPIO2->FIOPIN=0XFFFFFFFF; } } for (;;) { msc_status = USBH_MSC_DriveGetMediaStatus ("U0:"); LPC_GPIO2->FIOPIN=0XFFFFFFFF; if (msc_status == USBH_MSC_OK) { if (con == 0U) { con = 1U; msc_status = USBH_MSC_DriveMount ("U0:"); if (msc_status != USBH_MSC_OK) { continue; } f = fopen ("Test.txt", "w"); if (f == NULL) { continue; } fprintf (f, "USB Host Mass Storage!\n"); fclose (f); msc_status = USBH_MSC_DriveUnmount ("U0:"); if (msc_status != USBH_MSC_OK) { continue; } } } else { if (con == 1U) { con = 0U; } osDelay(100U); } }