[ FORK ] basic DAP library forked from va009039/USBDAP/

Dependents:   11u35_usbLocalFilesystem

Fork of USBDAP by Norimasa Okamoto

Files at this revision

API Documentation at this revision

Comitter:
k4zuki
Date:
Fri Mar 04 10:33:25 2016 +0000
Parent:
2:7dee016756ce
Commit message:
remove LPC1768 switch; remove ATD45DB161D; replace W25X40BV; add loader.h; add mystorage.h/.cpp; trying to implement W25X40BV device to interface as USBLocalFileSystem

Changed in this revision

USBDAP.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7dee016756ce -r 13462db266a8 USBDAP.cpp
--- a/USBDAP.cpp	Sat Jul 05 08:19:19 2014 +0000
+++ b/USBDAP.cpp	Fri Mar 04 10:33:25 2016 +0000
@@ -23,7 +23,7 @@
 USBDAP::USBDAP(const char *product, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect): USBDevice(vendor_id, product_id, product_release)
 {
     buildStringIproductDescriptor(product);
-   
+
     if(connect) {
         USBDevice::connect();
     }
@@ -33,7 +33,7 @@
 {
     const char* product = "CMSIS-DAP";
     buildStringIproductDescriptor(product);
-   
+
     if(connect) {
         USBDevice::connect();
     }
@@ -43,7 +43,7 @@
 {
     int len = 2+strlen(s)*2;
     _stringIproductDescriptor = new uint8_t[len];
-    _stringIproductDescriptor[0] = len; 
+    _stringIproductDescriptor[0] = len;
     _stringIproductDescriptor[1] = STRING_DESCRIPTOR;
     for (int i = 0; i < strlen(s); i++) {
         _stringIproductDescriptor[2+i*2] = s[i];
@@ -89,7 +89,8 @@
 }
 
 
-uint16_t USBDAP::reportDescLength() {
+uint16_t USBDAP::reportDescLength()
+{
     reportDesc();
     return reportLength;
 }
@@ -106,24 +107,21 @@
 // This is used to handle extensions to standard requests
 // and class specific requests
 // Return true if class handles this request
-bool USBDAP::USBCallback_request() {
+bool USBDAP::USBCallback_request()
+{
     bool success = false;
     CONTROL_TRANSFER * transfer = getTransferPtr();
     uint8_t *hidDescriptor;
 
     // Process additional standard requests
 
-    if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE))
-    {
-        switch (transfer->setup.bRequest)
-        {
+    if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) {
+        switch (transfer->setup.bRequest) {
             case GET_DESCRIPTOR:
-                switch (DESCRIPTOR_TYPE(transfer->setup.wValue))
-                {
+                switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) {
                     case REPORT_DESCRIPTOR:
                         if ((reportDesc() != NULL) \
-                            && (reportDescLength() != 0))
-                        {
+                                && (reportDescLength() != 0)) {
                             transfer->remaining = reportDescLength();
                             transfer->ptr = reportDesc();
                             transfer->direction = DEVICE_TO_HOST;
@@ -131,17 +129,16 @@
                         }
                         break;
                     case HID_DESCRIPTOR:
-                            // Find the HID descriptor, after the configuration descriptor
-                            hidDescriptor = findDescriptor(HID_DESCRIPTOR);
-                            if (hidDescriptor != NULL)
-                            {
-                                transfer->remaining = HID_DESCRIPTOR_LENGTH;
-                                transfer->ptr = hidDescriptor;
-                                transfer->direction = DEVICE_TO_HOST;
-                                success = true;
-                            }
-                            break;
-                     
+                        // Find the HID descriptor, after the configuration descriptor
+                        hidDescriptor = findDescriptor(HID_DESCRIPTOR);
+                        if (hidDescriptor != NULL) {
+                            transfer->remaining = HID_DESCRIPTOR_LENGTH;
+                            transfer->ptr = hidDescriptor;
+                            transfer->direction = DEVICE_TO_HOST;
+                            success = true;
+                        }
+                        break;
+
                     default:
                         break;
                 }
@@ -153,11 +150,9 @@
 
     // Process class-specific requests
 
-    if (transfer->setup.bmRequestType.Type == CLASS_TYPE)
-    {
-        switch (transfer->setup.bRequest)
-        {
-             case SET_REPORT:
+    if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
+        switch (transfer->setup.bRequest) {
+            case SET_REPORT:
                 // First byte will be used for report ID
                 outputReport.data[0] = transfer->setup.wValue & 0xff;
                 outputReport.length = transfer->setup.wLength + 1;
@@ -182,7 +177,8 @@
 // Called in ISR context
 // Set configuration. Return false if the
 // configuration is not supported
-bool USBDAP::USBCallback_setConfiguration(uint8_t configuration) {
+bool USBDAP::USBCallback_setConfiguration(uint8_t configuration)
+{
     if (configuration != DEFAULT_CONFIGURATION) {
         return false;
     }
@@ -197,7 +193,8 @@
 }
 
 
-uint8_t * USBDAP::stringIinterfaceDesc() {
+uint8_t * USBDAP::stringIinterfaceDesc()
+{
     static uint8_t stringIinterfaceDescriptor[] = {
         0x08,               //bLength
         STRING_DESCRIPTOR,  //bDescriptorType 0x03
@@ -206,7 +203,8 @@
     return stringIinterfaceDescriptor;
 }
 
-uint8_t * USBDAP::stringIproductDesc() {
+uint8_t * USBDAP::stringIproductDesc()
+{
     return _stringIproductDescriptor;
 }
 
@@ -239,7 +237,8 @@
                                + (1 * HID_DESCRIPTOR_LENGTH) \
                                + (2 * ENDPOINT_DESCRIPTOR_LENGTH))
 
-uint8_t * USBDAP::configurationDesc() {
+uint8_t * USBDAP::configurationDesc()
+{
     static uint8_t configurationDescriptor[] = {
         CONFIGURATION_DESCRIPTOR_LENGTH,// bLength
         CONFIGURATION_DESCRIPTOR,       // bDescriptorType