USBDevice for STM support

Dependents:   Nucleo_Usb_JoyMouse Nucleo_usbmouse ELEC350_1-referral-2018-usb-hid USBJoystick_HelloWorld2_wip ... more

This library contains all mbed usb device library (mbed-os\features\unsupported\USBDevice).

Committer:
frq08711@LMECWL0871.LME.ST.COM
Date:
Tue Mar 28 11:00:57 2017 +0200
Branch:
master
Revision:
4:50ec00aa4515
Parent:
1:2a3ae13b45ef
update for 5.4.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 2 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 4 * and associated documentation files (the "Software"), to deal in the Software without
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 7 * Software is furnished to do so, subject to the following conditions:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 8 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 9 * The above copyright notice and this permission notice shall be included in all copies or
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 10 * substantial portions of the Software.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 11 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 17 */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 18
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 19 #include "stdint.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 20 #include "USBMSD.h"
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 21
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 22 #define DISK_OK 0x00
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 23 #define NO_INIT 0x01
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 24 #define NO_DISK 0x02
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 25 #define WRITE_PROTECT 0x04
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 26
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 27 #define CBW_Signature 0x43425355
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 28 #define CSW_Signature 0x53425355
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 29
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 30 // SCSI Commands
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 31 #define TEST_UNIT_READY 0x00
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 32 #define REQUEST_SENSE 0x03
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 33 #define FORMAT_UNIT 0x04
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 34 #define INQUIRY 0x12
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 35 #define MODE_SELECT6 0x15
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 36 #define MODE_SENSE6 0x1A
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 37 #define START_STOP_UNIT 0x1B
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 38 #define MEDIA_REMOVAL 0x1E
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 39 #define READ_FORMAT_CAPACITIES 0x23
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 40 #define READ_CAPACITY 0x25
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 41 #define READ10 0x28
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 42 #define WRITE10 0x2A
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 43 #define VERIFY10 0x2F
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 44 #define READ12 0xA8
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 45 #define WRITE12 0xAA
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 46 #define MODE_SELECT10 0x55
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 47 #define MODE_SENSE10 0x5A
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 48
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 49 // MSC class specific requests
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 50 #define MSC_REQUEST_RESET 0xFF
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 51 #define MSC_REQUEST_GET_MAX_LUN 0xFE
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 52
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 53 #define DEFAULT_CONFIGURATION (1)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 54
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 55 // max packet size
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 56 #define MAX_PACKET MAX_PACKET_SIZE_EPBULK
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 57
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 58 // CSW Status
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 59 enum Status {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 60 CSW_PASSED,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 61 CSW_FAILED,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 62 CSW_ERROR,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 63 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 64
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 65
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 66 USBMSD::USBMSD(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 67 stage = READ_CBW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 68 memset((void *)&cbw, 0, sizeof(CBW));
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 69 memset((void *)&csw, 0, sizeof(CSW));
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 70 page = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 71 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 72
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 73 USBMSD::~USBMSD() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 74 disconnect();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 75 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 76
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 77
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 78 // Called in ISR context to process a class specific request
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 79 bool USBMSD::USBCallback_request(void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 80
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 81 bool success = false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 82 CONTROL_TRANSFER * transfer = getTransferPtr();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 83 static uint8_t maxLUN[1] = {0};
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 84
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 85 if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 86 switch (transfer->setup.bRequest) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 87 case MSC_REQUEST_RESET:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 88 reset();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 89 success = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 90 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 91 case MSC_REQUEST_GET_MAX_LUN:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 92 transfer->remaining = 1;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 93 transfer->ptr = maxLUN;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 94 transfer->direction = DEVICE_TO_HOST;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 95 success = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 96 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 97 default:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 98 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 99 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 100 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 101
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 102 return success;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 103 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 104
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 105
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 106 bool USBMSD::connect(bool blocking) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 107 //disk initialization
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 108 if (disk_status() & NO_INIT) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 109 if (disk_initialize()) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 110 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 111 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 112 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 113
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 114 // get number of blocks
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 115 BlockCount = disk_sectors();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 116
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 117 // get memory size
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 118 MemorySize = disk_size();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 119
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 120 if (BlockCount > 0) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 121 BlockSize = MemorySize / BlockCount;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 122 if (BlockSize != 0) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 123 free(page);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 124 page = (uint8_t *)malloc(BlockSize * sizeof(uint8_t));
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 125 if (page == NULL)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 126 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 127 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 128 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 129 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 130 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 131
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 132 //connect the device
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 133 USBDevice::connect(blocking);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 134 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 135 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 136
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 137 void USBMSD::disconnect() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 138 USBDevice::disconnect();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 139 //De-allocate MSD page size:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 140 free(page);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 141 page = NULL;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 142 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 143
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 144 void USBMSD::reset() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 145 stage = READ_CBW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 146 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 147
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 148
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 149 // Called in ISR context called when a data is received
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 150 bool USBMSD::EPBULK_OUT_callback() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 151 uint32_t size = 0;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 152 uint8_t buf[MAX_PACKET_SIZE_EPBULK];
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 153 readEP(EPBULK_OUT, buf, &size, MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 154 switch (stage) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 155 // the device has to decode the CBW received
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 156 case READ_CBW:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 157 CBWDecode(buf, size);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 158 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 159
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 160 // the device has to receive data from the host
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 161 case PROCESS_CBW:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 162 switch (cbw.CB[0]) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 163 case WRITE10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 164 case WRITE12:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 165 memoryWrite(buf, size);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 166 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 167 case VERIFY10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 168 memoryVerify(buf, size);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 169 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 170 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 171 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 172
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 173 // an error has occured: stall endpoint and send CSW
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 174 default:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 175 stallEndpoint(EPBULK_OUT);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 176 csw.Status = CSW_ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 177 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 178 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 179 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 180
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 181 //reactivate readings on the OUT bulk endpoint
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 182 readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 183 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 184 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 185
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 186 // Called in ISR context when a data has been transferred
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 187 bool USBMSD::EPBULK_IN_callback() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 188 switch (stage) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 189
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 190 // the device has to send data to the host
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 191 case PROCESS_CBW:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 192 switch (cbw.CB[0]) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 193 case READ10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 194 case READ12:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 195 memoryRead();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 196 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 197 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 198 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 199
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 200 //the device has to send a CSW
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 201 case SEND_CSW:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 202 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 203 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 204
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 205 // the host has received the CSW -> we wait a CBW
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 206 case WAIT_CSW:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 207 stage = READ_CBW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 208 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 209
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 210 // an error has occured
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 211 default:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 212 stallEndpoint(EPBULK_IN);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 213 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 214 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 215 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 216 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 217 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 218
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 219
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 220 void USBMSD::memoryWrite (uint8_t * buf, uint16_t size) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 221
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 222 if ((addr + size) > MemorySize) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 223 size = MemorySize - addr;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 224 stage = ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 225 stallEndpoint(EPBULK_OUT);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 226 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 227
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 228 // we fill an array in RAM of 1 block before writing it in memory
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 229 for (int i = 0; i < size; i++)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 230 page[addr%BlockSize + i] = buf[i];
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 231
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 232 // if the array is filled, write it in memory
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 233 if (!((addr + size)%BlockSize)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 234 if (!(disk_status() & WRITE_PROTECT)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 235 disk_write(page, addr/BlockSize, 1);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 236 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 237 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 238
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 239 addr += size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 240 length -= size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 241 csw.DataResidue -= size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 242
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 243 if ((!length) || (stage != PROCESS_CBW)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 244 csw.Status = (stage == ERROR) ? CSW_FAILED : CSW_PASSED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 245 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 246 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 247 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 248
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 249 void USBMSD::memoryVerify (uint8_t * buf, uint16_t size) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 250 uint32_t n;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 251
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 252 if ((addr + size) > MemorySize) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 253 size = MemorySize - addr;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 254 stage = ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 255 stallEndpoint(EPBULK_OUT);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 256 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 257
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 258 // beginning of a new block -> load a whole block in RAM
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 259 if (!(addr%BlockSize))
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 260 disk_read(page, addr/BlockSize, 1);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 261
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 262 // info are in RAM -> no need to re-read memory
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 263 for (n = 0; n < size; n++) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 264 if (page[addr%BlockSize + n] != buf[n]) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 265 memOK = false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 266 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 267 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 268 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 269
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 270 addr += size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 271 length -= size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 272 csw.DataResidue -= size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 273
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 274 if ( !length || (stage != PROCESS_CBW)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 275 csw.Status = (memOK && (stage == PROCESS_CBW)) ? CSW_PASSED : CSW_FAILED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 276 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 277 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 278 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 279
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 280
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 281 bool USBMSD::inquiryRequest (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 282 uint8_t inquiry[] = { 0x00, 0x80, 0x00, 0x01,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 283 36 - 4, 0x80, 0x00, 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 284 'M', 'B', 'E', 'D', '.', 'O', 'R', 'G',
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 285 'M', 'B', 'E', 'D', ' ', 'U', 'S', 'B', ' ', 'D', 'I', 'S', 'K', ' ', ' ', ' ',
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 286 '1', '.', '0', ' ',
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 287 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 288 if (!write(inquiry, sizeof(inquiry))) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 289 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 290 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 291 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 292 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 293
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 294
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 295 bool USBMSD::readFormatCapacity() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 296 uint8_t capacity[] = { 0x00, 0x00, 0x00, 0x08,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 297 (uint8_t)((BlockCount >> 24) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 298 (uint8_t)((BlockCount >> 16) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 299 (uint8_t)((BlockCount >> 8) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 300 (uint8_t)((BlockCount >> 0) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 301
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 302 0x02,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 303 (uint8_t)((BlockSize >> 16) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 304 (uint8_t)((BlockSize >> 8) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 305 (uint8_t)((BlockSize >> 0) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 306 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 307 if (!write(capacity, sizeof(capacity))) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 308 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 309 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 310 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 311 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 312
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 313
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 314 bool USBMSD::readCapacity (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 315 uint8_t capacity[] = {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 316 (uint8_t)(((BlockCount - 1) >> 24) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 317 (uint8_t)(((BlockCount - 1) >> 16) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 318 (uint8_t)(((BlockCount - 1) >> 8) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 319 (uint8_t)(((BlockCount - 1) >> 0) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 320
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 321 (uint8_t)((BlockSize >> 24) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 322 (uint8_t)((BlockSize >> 16) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 323 (uint8_t)((BlockSize >> 8) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 324 (uint8_t)((BlockSize >> 0) & 0xff),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 325 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 326 if (!write(capacity, sizeof(capacity))) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 327 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 328 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 329 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 330 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 331
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 332 bool USBMSD::write (uint8_t * buf, uint16_t size) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 333
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 334 if (size >= cbw.DataLength) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 335 size = cbw.DataLength;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 336 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 337 stage = SEND_CSW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 338
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 339 if (!writeNB(EPBULK_IN, buf, size, MAX_PACKET_SIZE_EPBULK)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 340 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 341 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 342
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 343 csw.DataResidue -= size;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 344 csw.Status = CSW_PASSED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 345 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 346 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 347
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 348
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 349 bool USBMSD::modeSense6 (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 350 uint8_t sense6[] = { 0x03, 0x00, 0x00, 0x00 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 351 if (!write(sense6, sizeof(sense6))) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 352 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 353 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 354 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 355 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 356
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 357 void USBMSD::sendCSW() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 358 csw.Signature = CSW_Signature;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 359 writeNB(EPBULK_IN, (uint8_t *)&csw, sizeof(CSW), MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 360 stage = WAIT_CSW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 361 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 362
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 363 bool USBMSD::requestSense (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 364 uint8_t request_sense[] = {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 365 0x70,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 366 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 367 0x05, // Sense Key: illegal request
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 368 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 369 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 370 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 371 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 372 0x0A,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 373 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 374 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 375 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 376 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 377 0x30,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 378 0x01,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 379 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 380 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 381 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 382 0x00,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 383 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 384
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 385 if (!write(request_sense, sizeof(request_sense))) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 386 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 387 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 388
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 389 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 390 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 391
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 392 void USBMSD::fail() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 393 csw.Status = CSW_FAILED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 394 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 395 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 396
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 397
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 398 void USBMSD::CBWDecode(uint8_t * buf, uint16_t size) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 399 if (size == sizeof(cbw)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 400 memcpy((uint8_t *)&cbw, buf, size);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 401 if (cbw.Signature == CBW_Signature) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 402 csw.Tag = cbw.Tag;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 403 csw.DataResidue = cbw.DataLength;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 404 if ((cbw.CBLength < 1) || (cbw.CBLength > 16) ) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 405 fail();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 406 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 407 switch (cbw.CB[0]) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 408 case TEST_UNIT_READY:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 409 testUnitReady();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 410 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 411 case REQUEST_SENSE:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 412 requestSense();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 413 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 414 case INQUIRY:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 415 inquiryRequest();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 416 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 417 case MODE_SENSE6:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 418 modeSense6();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 419 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 420 case READ_FORMAT_CAPACITIES:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 421 readFormatCapacity();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 422 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 423 case READ_CAPACITY:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 424 readCapacity();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 425 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 426 case READ10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 427 case READ12:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 428 if (infoTransfer()) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 429 if ((cbw.Flags & 0x80)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 430 stage = PROCESS_CBW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 431 memoryRead();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 432 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 433 stallEndpoint(EPBULK_OUT);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 434 csw.Status = CSW_ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 435 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 436 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 437 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 438 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 439 case WRITE10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 440 case WRITE12:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 441 if (infoTransfer()) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 442 if (!(cbw.Flags & 0x80)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 443 stage = PROCESS_CBW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 444 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 445 stallEndpoint(EPBULK_IN);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 446 csw.Status = CSW_ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 447 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 448 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 449 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 450 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 451 case VERIFY10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 452 if (!(cbw.CB[1] & 0x02)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 453 csw.Status = CSW_PASSED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 454 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 455 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 456 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 457 if (infoTransfer()) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 458 if (!(cbw.Flags & 0x80)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 459 stage = PROCESS_CBW;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 460 memOK = true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 461 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 462 stallEndpoint(EPBULK_IN);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 463 csw.Status = CSW_ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 464 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 465 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 466 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 467 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 468 case MEDIA_REMOVAL:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 469 csw.Status = CSW_PASSED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 470 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 471 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 472 default:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 473 fail();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 474 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 475 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 476 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 477 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 478 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 479 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 480
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 481 void USBMSD::testUnitReady (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 482
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 483 if (cbw.DataLength != 0) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 484 if ((cbw.Flags & 0x80) != 0) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 485 stallEndpoint(EPBULK_IN);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 486 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 487 stallEndpoint(EPBULK_OUT);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 488 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 489 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 490
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 491 csw.Status = CSW_PASSED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 492 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 493 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 494
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 495
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 496 void USBMSD::memoryRead (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 497 uint32_t n;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 498
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 499 n = (length > MAX_PACKET) ? MAX_PACKET : length;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 500
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 501 if ((addr + n) > MemorySize) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 502 n = MemorySize - addr;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 503 stage = ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 504 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 505
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 506 // we read an entire block
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 507 if (!(addr%BlockSize))
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 508 disk_read(page, addr/BlockSize, 1);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 509
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 510 // write data which are in RAM
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 511 writeNB(EPBULK_IN, &page[addr%BlockSize], n, MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 512
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 513 addr += n;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 514 length -= n;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 515
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 516 csw.DataResidue -= n;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 517
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 518 if ( !length || (stage != PROCESS_CBW)) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 519 csw.Status = (stage == PROCESS_CBW) ? CSW_PASSED : CSW_FAILED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 520 stage = (stage == PROCESS_CBW) ? SEND_CSW : stage;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 521 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 522 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 523
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 524
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 525 bool USBMSD::infoTransfer (void) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 526 uint32_t n;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 527
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 528 // Logical Block Address of First Block
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 529 n = (cbw.CB[2] << 24) | (cbw.CB[3] << 16) | (cbw.CB[4] << 8) | (cbw.CB[5] << 0);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 530
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 531 addr = n * BlockSize;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 532
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 533 // Number of Blocks to transfer
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 534 switch (cbw.CB[0]) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 535 case READ10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 536 case WRITE10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 537 case VERIFY10:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 538 n = (cbw.CB[7] << 8) | (cbw.CB[8] << 0);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 539 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 540
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 541 case READ12:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 542 case WRITE12:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 543 n = (cbw.CB[6] << 24) | (cbw.CB[7] << 16) | (cbw.CB[8] << 8) | (cbw.CB[9] << 0);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 544 break;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 545 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 546
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 547 length = n * BlockSize;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 548
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 549 if (!cbw.DataLength) { // host requests no data
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 550 csw.Status = CSW_FAILED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 551 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 552 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 553 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 554
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 555 if (cbw.DataLength != length) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 556 if ((cbw.Flags & 0x80) != 0) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 557 stallEndpoint(EPBULK_IN);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 558 } else {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 559 stallEndpoint(EPBULK_OUT);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 560 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 561
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 562 csw.Status = CSW_FAILED;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 563 sendCSW();
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 564 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 565 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 566
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 567 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 568 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 569
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 570
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 571
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 572
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 573
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 574 // Called in ISR context
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 575 // Set configuration. Return false if the
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 576 // configuration is not supported.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 577 bool USBMSD::USBCallback_setConfiguration(uint8_t configuration) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 578 if (configuration != DEFAULT_CONFIGURATION) {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 579 return false;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 580 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 581
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 582 // Configure endpoints > 0
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 583 addEndpoint(EPBULK_IN, MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 584 addEndpoint(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 585
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 586 //activate readings
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 587 readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 588 return true;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 589 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 590
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 591
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 592 uint8_t * USBMSD::stringIinterfaceDesc() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 593 static uint8_t stringIinterfaceDescriptor[] = {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 594 0x08, //bLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 595 STRING_DESCRIPTOR, //bDescriptorType 0x03
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 596 'M',0,'S',0,'D',0 //bString iInterface - MSD
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 597 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 598 return stringIinterfaceDescriptor;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 599 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 600
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 601 uint8_t * USBMSD::stringIproductDesc() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 602 static uint8_t stringIproductDescriptor[] = {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 603 0x12, //bLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 604 STRING_DESCRIPTOR, //bDescriptorType 0x03
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 605 'M',0,'b',0,'e',0,'d',0,' ',0,'M',0,'S',0,'D',0 //bString iProduct - Mbed Audio
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 606 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 607 return stringIproductDescriptor;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 608 }
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 609
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 610
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 611 uint8_t * USBMSD::configurationDesc() {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 612 static uint8_t configDescriptor[] = {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 613
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 614 // Configuration 1
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 615 9, // bLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 616 2, // bDescriptorType
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 617 LSB(9 + 9 + 7 + 7), // wTotalLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 618 MSB(9 + 9 + 7 + 7),
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 619 0x01, // bNumInterfaces
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 620 0x01, // bConfigurationValue: 0x01 is used to select this configuration
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 621 0x00, // iConfiguration: no string to describe this configuration
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 622 0xC0, // bmAttributes
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 623 100, // bMaxPower, device power consumption is 100 mA
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 624
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 625 // Interface 0, Alternate Setting 0, MSC Class
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 626 9, // bLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 627 4, // bDescriptorType
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 628 0x00, // bInterfaceNumber
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 629 0x00, // bAlternateSetting
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 630 0x02, // bNumEndpoints
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 631 0x08, // bInterfaceClass
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 632 0x06, // bInterfaceSubClass
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 633 0x50, // bInterfaceProtocol
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 634 0x04, // iInterface
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 635
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 636 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 637 7, // bLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 638 5, // bDescriptorType
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 639 PHY_TO_DESC(EPBULK_IN), // bEndpointAddress
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 640 0x02, // bmAttributes (0x02=bulk)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 641 LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 642 MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 643 0, // bInterval
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 644
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 645 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 646 7, // bLength
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 647 5, // bDescriptorType
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 648 PHY_TO_DESC(EPBULK_OUT), // bEndpointAddress
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 649 0x02, // bmAttributes (0x02=bulk)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 650 LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 651 MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 652 0 // bInterval
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 653 };
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 654 return configDescriptor;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 655 }