X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/9a97f16b07ea15e327b0d01be238b06623b033d6..a8871c7fba73307226bd13e2cad4c840c850e6f1:/Demos/Device/LowLevel/MassStorage/MassStorage.c diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.c b/Demos/Device/LowLevel/MassStorage/MassStorage.c index 93b7c6102..3bf2af16c 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.c +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.c @@ -76,7 +76,7 @@ void SetupHardware(void) /* Hardware Initialization */ LEDs_Init(); - SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); + SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); Dataflash_Init(); USB_Init(); @@ -108,23 +108,16 @@ void EVENT_USB_Device_Disconnect(void) */ void EVENT_USB_Device_ConfigurationChanged(void) { - /* Indicate USB connected and ready */ - LEDs_SetAllLEDs(LEDMASK_USB_READY); + bool ConfigSuccess = true; - /* Setup Mass Storage In and Out Endpoints */ - if (!(Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_IN, MASS_STORAGE_IO_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } - - if (!(Endpoint_ConfigureEndpoint(MASS_STORAGE_OUT_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_OUT, MASS_STORAGE_IO_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } + /* Setup Mass Storage Data Endpoints */ + ConfigSuccess &= Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN, + MASS_STORAGE_IO_EPSIZE, ENDPOINT_BANK_SINGLE); + ConfigSuccess &= Endpoint_ConfigureEndpoint(MASS_STORAGE_OUT_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_OUT, + MASS_STORAGE_IO_EPSIZE, ENDPOINT_BANK_SINGLE); + + /* Indicate endpoint configuration success or failure */ + LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); } /** Event handler for the USB_UnhandledControlPacket event. This is used to catch standard and class specific @@ -140,11 +133,10 @@ void EVENT_USB_Device_UnhandledControlRequest(void) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); /* Indicate that the current transfer should be aborted */ IsMassStoreReset = true; - - Endpoint_ClearStatusStage(); } break; @@ -156,8 +148,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) /* Indicate to the host the number of supported LUNs (virtual disks) on the device */ Endpoint_Write_Byte(TOTAL_LUNS - 1); - Endpoint_ClearIN(); - + Endpoint_ClearIN(); Endpoint_ClearStatusStage(); }