SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lorcansmith 0:2a53a4c3238c 1
lorcansmith 0:2a53a4c3238c 2 /*
lorcansmith 0:2a53a4c3238c 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
lorcansmith 0:2a53a4c3238c 4
lorcansmith 0:2a53a4c3238c 5 Permission is hereby granted, free of charge, to any person obtaining a copy
lorcansmith 0:2a53a4c3238c 6 of this software and associated documentation files (the "Software"), to deal
lorcansmith 0:2a53a4c3238c 7 in the Software without restriction, including without limitation the rights
lorcansmith 0:2a53a4c3238c 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
lorcansmith 0:2a53a4c3238c 9 copies of the Software, and to permit persons to whom the Software is
lorcansmith 0:2a53a4c3238c 10 furnished to do so, subject to the following conditions:
lorcansmith 0:2a53a4c3238c 11
lorcansmith 0:2a53a4c3238c 12 The above copyright notice and this permission notice shall be included in
lorcansmith 0:2a53a4c3238c 13 all copies or substantial portions of the Software.
lorcansmith 0:2a53a4c3238c 14
lorcansmith 0:2a53a4c3238c 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
lorcansmith 0:2a53a4c3238c 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
lorcansmith 0:2a53a4c3238c 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
lorcansmith 0:2a53a4c3238c 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
lorcansmith 0:2a53a4c3238c 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
lorcansmith 0:2a53a4c3238c 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
lorcansmith 0:2a53a4c3238c 21 THE SOFTWARE.
lorcansmith 0:2a53a4c3238c 22 */
lorcansmith 0:2a53a4c3238c 23
lorcansmith 0:2a53a4c3238c 24 #include "UsbDevice.h"
lorcansmith 0:2a53a4c3238c 25
lorcansmith 0:2a53a4c3238c 26 #include "netCfg.h"
lorcansmith 0:2a53a4c3238c 27 #if NET_USB
lorcansmith 0:2a53a4c3238c 28
lorcansmith 0:2a53a4c3238c 29 //#define __DEBUG
lorcansmith 0:2a53a4c3238c 30 #include "dbg/dbg.h"
lorcansmith 0:2a53a4c3238c 31
lorcansmith 0:2a53a4c3238c 32 UsbDevice::UsbDevice( UsbHostMgr* pMgr, int hub, int port, int addr ) : m_pControlEp(NULL), /*m_controlEp( this, 0x00, false, USB_CONTROL, 8 ),*/
lorcansmith 0:2a53a4c3238c 33 m_pMgr(pMgr), m_connected(false), m_enumerated(false), m_hub(hub), m_port(port), m_addr(addr), m_refs(0),
lorcansmith 0:2a53a4c3238c 34 m_vid(0), m_pid(0)
lorcansmith 0:2a53a4c3238c 35 {
lorcansmith 0:2a53a4c3238c 36
lorcansmith 0:2a53a4c3238c 37 }
lorcansmith 0:2a53a4c3238c 38
lorcansmith 0:2a53a4c3238c 39 UsbDevice::~UsbDevice()
lorcansmith 0:2a53a4c3238c 40 {
lorcansmith 0:2a53a4c3238c 41 if(m_pControlEp)
lorcansmith 0:2a53a4c3238c 42 delete m_pControlEp;
lorcansmith 0:2a53a4c3238c 43 }
lorcansmith 0:2a53a4c3238c 44
lorcansmith 0:2a53a4c3238c 45 UsbErr UsbDevice::enumerate()
lorcansmith 0:2a53a4c3238c 46 {
lorcansmith 0:2a53a4c3238c 47 // USB_INT32S rc;
lorcansmith 0:2a53a4c3238c 48
lorcansmith 0:2a53a4c3238c 49 UsbErr rc;
lorcansmith 0:2a53a4c3238c 50
lorcansmith 0:2a53a4c3238c 51 DBG("Starting enumeration (m_pMgr = %p)\n", m_pMgr);
lorcansmith 0:2a53a4c3238c 52
lorcansmith 0:2a53a4c3238c 53 #if 1
lorcansmith 0:2a53a4c3238c 54 m_pMgr->resetPort(m_hub, m_port);
lorcansmith 0:2a53a4c3238c 55 #else
lorcansmith 0:2a53a4c3238c 56 wait_ms(100); /* USB 2.0 spec says atleast 50ms delay beore port reset */
lorcansmith 0:2a53a4c3238c 57 LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRS; // Initiate port reset
lorcansmith 0:2a53a4c3238c 58 while (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_PRS)
lorcansmith 0:2a53a4c3238c 59 __WFI(); // Wait for port reset to complete...
lorcansmith 0:2a53a4c3238c 60 LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC; // ...and clear port reset signal
lorcansmith 0:2a53a4c3238c 61 wait_ms(200); /* Wait for 100 MS after port reset */
lorcansmith 0:2a53a4c3238c 62 #endif
lorcansmith 0:2a53a4c3238c 63
lorcansmith 0:2a53a4c3238c 64 DBG("Port reset\n");
lorcansmith 0:2a53a4c3238c 65
lorcansmith 0:2a53a4c3238c 66 wait_ms(200);
lorcansmith 0:2a53a4c3238c 67
lorcansmith 0:2a53a4c3238c 68 m_pControlEp = new UsbEndpoint( this, 0x00, false, USB_CONTROL, 8, 0 );
lorcansmith 0:2a53a4c3238c 69
lorcansmith 0:2a53a4c3238c 70 //EDCtrl->Control = 8 << 16;/* Put max pkt size = 8 */
lorcansmith 0:2a53a4c3238c 71 /* Read first 8 bytes of device desc */
lorcansmith 0:2a53a4c3238c 72 rc = controlReceive(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR, (USB_DESCRIPTOR_TYPE_DEVICE << 8)|(0), 0, m_controlDataBuf, 8);
lorcansmith 0:2a53a4c3238c 73 if (rc)
lorcansmith 0:2a53a4c3238c 74 {
lorcansmith 0:2a53a4c3238c 75 DBG("RC=%d",rc);
lorcansmith 0:2a53a4c3238c 76 return (rc);
lorcansmith 0:2a53a4c3238c 77 }
lorcansmith 0:2a53a4c3238c 78
lorcansmith 0:2a53a4c3238c 79 DBG("Got descriptor, max ep size is %d\n", m_controlDataBuf[7]);
lorcansmith 0:2a53a4c3238c 80
lorcansmith 0:2a53a4c3238c 81 m_pControlEp->updateSize(m_controlDataBuf[7]); /* Get max pkt size of endpoint 0 */
lorcansmith 0:2a53a4c3238c 82 rc = controlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_ADDRESS, m_addr, 0, NULL, 0); /* Set the device address to m_addr */
lorcansmith 0:2a53a4c3238c 83 if (rc)
lorcansmith 0:2a53a4c3238c 84 {
lorcansmith 0:2a53a4c3238c 85 // PRINT_Err(rc);
lorcansmith 0:2a53a4c3238c 86 return (rc);
lorcansmith 0:2a53a4c3238c 87 }
lorcansmith 0:2a53a4c3238c 88 wait_ms(2);
lorcansmith 0:2a53a4c3238c 89 //EDCtrl->Control = (EDCtrl->Control) | 1; /* Modify control pipe with address 1 */
lorcansmith 0:2a53a4c3238c 90
lorcansmith 0:2a53a4c3238c 91 //Update address
lorcansmith 0:2a53a4c3238c 92 m_pControlEp->updateAddr(m_addr);
lorcansmith 0:2a53a4c3238c 93 DBG("Ep addr is now %d", m_addr);
lorcansmith 0:2a53a4c3238c 94 /**/
lorcansmith 0:2a53a4c3238c 95
lorcansmith 0:2a53a4c3238c 96 //rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_DEVICE, 0, TDBuffer, 17); //Read full device descriptor
lorcansmith 0:2a53a4c3238c 97 rc = controlReceive(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR, (USB_DESCRIPTOR_TYPE_DEVICE << 8)|(0), 0, m_controlDataBuf, 17);
lorcansmith 0:2a53a4c3238c 98 if (rc)
lorcansmith 0:2a53a4c3238c 99 {
lorcansmith 0:2a53a4c3238c 100 //PRINT_Err(rc);
lorcansmith 0:2a53a4c3238c 101 return (rc);
lorcansmith 0:2a53a4c3238c 102 }
lorcansmith 0:2a53a4c3238c 103 /*
lorcansmith 0:2a53a4c3238c 104 rc = SerialCheckVidPid();
lorcansmith 0:2a53a4c3238c 105 if (rc != OK) {
lorcansmith 0:2a53a4c3238c 106 PRINT_Err(rc);
lorcansmith 0:2a53a4c3238c 107 return (rc);
lorcansmith 0:2a53a4c3238c 108 }
lorcansmith 0:2a53a4c3238c 109 */
lorcansmith 0:2a53a4c3238c 110 /**/
lorcansmith 0:2a53a4c3238c 111
lorcansmith 0:2a53a4c3238c 112 m_vid = *((uint16_t*)&m_controlDataBuf[8]);
lorcansmith 0:2a53a4c3238c 113 m_pid = *((uint16_t*)&m_controlDataBuf[10]);
lorcansmith 0:2a53a4c3238c 114
lorcansmith 0:2a53a4c3238c 115 DBG("VID: %02x, PID: %02x\n", m_vid, m_pid);
lorcansmith 0:2a53a4c3238c 116 /* Get the configuration descriptor */
lorcansmith 0:2a53a4c3238c 117 //rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_CONFIGURATION, 0, TDBuffer, 9);
lorcansmith 0:2a53a4c3238c 118 rc = controlReceive(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR, (USB_DESCRIPTOR_TYPE_CONFIGURATION << 8)|(0), 0, m_controlDataBuf, 9);
lorcansmith 0:2a53a4c3238c 119 if (rc)
lorcansmith 0:2a53a4c3238c 120 {
lorcansmith 0:2a53a4c3238c 121 //PRINT_Err(rc);
lorcansmith 0:2a53a4c3238c 122 return (rc);
lorcansmith 0:2a53a4c3238c 123 }
lorcansmith 0:2a53a4c3238c 124 /* Get the first configuration data */
lorcansmith 0:2a53a4c3238c 125 //rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_CONFIGURATION, 0, TDBuffer, *((uint16_t*)&TDBuffer[2]));
lorcansmith 0:2a53a4c3238c 126 rc = controlReceive(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR, (USB_DESCRIPTOR_TYPE_CONFIGURATION << 8)|(0), 0, m_controlDataBuf, *((uint16_t*)&m_controlDataBuf[2]));
lorcansmith 0:2a53a4c3238c 127 if (rc)
lorcansmith 0:2a53a4c3238c 128 {
lorcansmith 0:2a53a4c3238c 129 //PRINT_Err(rc);
lorcansmith 0:2a53a4c3238c 130 return (rc);
lorcansmith 0:2a53a4c3238c 131 }
lorcansmith 0:2a53a4c3238c 132
lorcansmith 0:2a53a4c3238c 133 DBG("Desc len is %d\n", *((uint16_t*)&m_controlDataBuf[2]));
lorcansmith 0:2a53a4c3238c 134
lorcansmith 0:2a53a4c3238c 135 DBG("Set configuration\n");
lorcansmith 0:2a53a4c3238c 136
lorcansmith 0:2a53a4c3238c 137 //rc = USBH_SET_CONFIGURATION(1);/* Select device configuration 1 */
lorcansmith 0:2a53a4c3238c 138 rc = controlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_CONFIGURATION, 1, 0, NULL, 0);
lorcansmith 0:2a53a4c3238c 139 if (rc)
lorcansmith 0:2a53a4c3238c 140 {
lorcansmith 0:2a53a4c3238c 141 // PRINT_Err(rc);
lorcansmith 0:2a53a4c3238c 142 return rc;
lorcansmith 0:2a53a4c3238c 143 }
lorcansmith 0:2a53a4c3238c 144 wait_ms(100);/* Some devices may require this delay */
lorcansmith 0:2a53a4c3238c 145
lorcansmith 0:2a53a4c3238c 146 m_enumerated = true;
lorcansmith 0:2a53a4c3238c 147 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 148 }
lorcansmith 0:2a53a4c3238c 149
lorcansmith 0:2a53a4c3238c 150 bool UsbDevice::connected()
lorcansmith 0:2a53a4c3238c 151 {
lorcansmith 0:2a53a4c3238c 152 return m_connected;
lorcansmith 0:2a53a4c3238c 153 }
lorcansmith 0:2a53a4c3238c 154
lorcansmith 0:2a53a4c3238c 155 bool UsbDevice::enumerated()
lorcansmith 0:2a53a4c3238c 156 {
lorcansmith 0:2a53a4c3238c 157 return m_enumerated;
lorcansmith 0:2a53a4c3238c 158 }
lorcansmith 0:2a53a4c3238c 159
lorcansmith 0:2a53a4c3238c 160 int UsbDevice::getPid()
lorcansmith 0:2a53a4c3238c 161 {
lorcansmith 0:2a53a4c3238c 162 return m_pid;
lorcansmith 0:2a53a4c3238c 163 }
lorcansmith 0:2a53a4c3238c 164
lorcansmith 0:2a53a4c3238c 165 int UsbDevice::getVid()
lorcansmith 0:2a53a4c3238c 166 {
lorcansmith 0:2a53a4c3238c 167 return m_vid;
lorcansmith 0:2a53a4c3238c 168 }
lorcansmith 0:2a53a4c3238c 169
lorcansmith 0:2a53a4c3238c 170 UsbErr UsbDevice::getConfigurationDescriptor(int config, uint8_t** pBuf)
lorcansmith 0:2a53a4c3238c 171 {
lorcansmith 0:2a53a4c3238c 172 //For now olny one config
lorcansmith 0:2a53a4c3238c 173 *pBuf = m_controlDataBuf;
lorcansmith 0:2a53a4c3238c 174 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 175 }
lorcansmith 0:2a53a4c3238c 176
lorcansmith 0:2a53a4c3238c 177 UsbErr UsbDevice::getInterfaceDescriptor(int config, int item, uint8_t** pBuf)
lorcansmith 0:2a53a4c3238c 178 {
lorcansmith 0:2a53a4c3238c 179 byte* desc_ptr = m_controlDataBuf;
lorcansmith 0:2a53a4c3238c 180
lorcansmith 0:2a53a4c3238c 181 /* if (desc_ptr[1] != USB_DESCRIPTOR_TYPE_CONFIGURATION)
lorcansmith 0:2a53a4c3238c 182 {
lorcansmith 0:2a53a4c3238c 183 return USBERR_BADCONFIG;
lorcansmith 0:2a53a4c3238c 184 }*/
lorcansmith 0:2a53a4c3238c 185
lorcansmith 0:2a53a4c3238c 186 if(item>=m_controlDataBuf[4])//Interfaces count
lorcansmith 0:2a53a4c3238c 187 return USBERR_NOTFOUND;
lorcansmith 0:2a53a4c3238c 188
lorcansmith 0:2a53a4c3238c 189 desc_ptr += desc_ptr[0];
lorcansmith 0:2a53a4c3238c 190
lorcansmith 0:2a53a4c3238c 191 *pBuf = NULL;
lorcansmith 0:2a53a4c3238c 192
lorcansmith 0:2a53a4c3238c 193 while (desc_ptr < m_controlDataBuf + *((uint16_t*)&m_controlDataBuf[2]))
lorcansmith 0:2a53a4c3238c 194 {
lorcansmith 0:2a53a4c3238c 195
lorcansmith 0:2a53a4c3238c 196 switch (desc_ptr[1]) {
lorcansmith 0:2a53a4c3238c 197 case USB_DESCRIPTOR_TYPE_INTERFACE:
lorcansmith 0:2a53a4c3238c 198 if(desc_ptr[2] == item)
lorcansmith 0:2a53a4c3238c 199 {
lorcansmith 0:2a53a4c3238c 200 *pBuf = desc_ptr;
lorcansmith 0:2a53a4c3238c 201 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 202 }
lorcansmith 0:2a53a4c3238c 203 desc_ptr += desc_ptr[0]; // Move to next descriptor start
lorcansmith 0:2a53a4c3238c 204 break;
lorcansmith 0:2a53a4c3238c 205 }
lorcansmith 0:2a53a4c3238c 206
lorcansmith 0:2a53a4c3238c 207 }
lorcansmith 0:2a53a4c3238c 208
lorcansmith 0:2a53a4c3238c 209 if(*pBuf == NULL)
lorcansmith 0:2a53a4c3238c 210 return USBERR_NOTFOUND;
lorcansmith 0:2a53a4c3238c 211
lorcansmith 0:2a53a4c3238c 212 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 213 }
lorcansmith 0:2a53a4c3238c 214
lorcansmith 0:2a53a4c3238c 215
lorcansmith 0:2a53a4c3238c 216 UsbErr UsbDevice::setConfiguration(int config)
lorcansmith 0:2a53a4c3238c 217 {
lorcansmith 0:2a53a4c3238c 218 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 219 }
lorcansmith 0:2a53a4c3238c 220
lorcansmith 0:2a53a4c3238c 221 UsbErr UsbDevice::controlSend(byte requestType, byte request, word value, word index, const byte* buf, int len)
lorcansmith 0:2a53a4c3238c 222 {
lorcansmith 0:2a53a4c3238c 223 UsbErr rc;
lorcansmith 0:2a53a4c3238c 224 fillControlBuf(requestType, request, value, index, len);
lorcansmith 0:2a53a4c3238c 225 m_pControlEp->setNextToken(TD_SETUP);
lorcansmith 0:2a53a4c3238c 226 rc = m_pControlEp->transfer(m_controlBuf, 8);
lorcansmith 0:2a53a4c3238c 227 while(m_pControlEp->status() == USBERR_PROCESSING);
lorcansmith 0:2a53a4c3238c 228 rc = (UsbErr) MIN(0, m_pControlEp->status());
lorcansmith 0:2a53a4c3238c 229 if(rc)
lorcansmith 0:2a53a4c3238c 230 return rc;
lorcansmith 0:2a53a4c3238c 231 if(len)
lorcansmith 0:2a53a4c3238c 232 {
lorcansmith 0:2a53a4c3238c 233 m_pControlEp->setNextToken(TD_OUT);
lorcansmith 0:2a53a4c3238c 234 rc = m_pControlEp->transfer((byte*)buf, len);
lorcansmith 0:2a53a4c3238c 235 while(m_pControlEp->status() == USBERR_PROCESSING);
lorcansmith 0:2a53a4c3238c 236 rc = (UsbErr) MIN(0, m_pControlEp->status());
lorcansmith 0:2a53a4c3238c 237 if(rc)
lorcansmith 0:2a53a4c3238c 238 return rc;
lorcansmith 0:2a53a4c3238c 239 }
lorcansmith 0:2a53a4c3238c 240 m_pControlEp->setNextToken(TD_IN);
lorcansmith 0:2a53a4c3238c 241 rc = m_pControlEp->transfer(NULL, 0);
lorcansmith 0:2a53a4c3238c 242 while(m_pControlEp->status() == USBERR_PROCESSING);
lorcansmith 0:2a53a4c3238c 243 rc = (UsbErr) MIN(0, m_pControlEp->status());
lorcansmith 0:2a53a4c3238c 244 if(rc)
lorcansmith 0:2a53a4c3238c 245 return rc;
lorcansmith 0:2a53a4c3238c 246 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 247 }
lorcansmith 0:2a53a4c3238c 248
lorcansmith 0:2a53a4c3238c 249 UsbErr UsbDevice::controlReceive(byte requestType, byte request, word value, word index, const byte* buf, int len)
lorcansmith 0:2a53a4c3238c 250 {
lorcansmith 0:2a53a4c3238c 251 UsbErr rc;
lorcansmith 0:2a53a4c3238c 252 fillControlBuf(requestType, request, value, index, len);
lorcansmith 0:2a53a4c3238c 253 m_pControlEp->setNextToken(TD_SETUP);
lorcansmith 0:2a53a4c3238c 254 rc = m_pControlEp->transfer(m_controlBuf, 8);
lorcansmith 0:2a53a4c3238c 255 while(m_pControlEp->status() == USBERR_PROCESSING);
lorcansmith 0:2a53a4c3238c 256 rc = (UsbErr) MIN(0, m_pControlEp->status());
lorcansmith 0:2a53a4c3238c 257 if(rc)
lorcansmith 0:2a53a4c3238c 258 return rc;
lorcansmith 0:2a53a4c3238c 259 if(len)
lorcansmith 0:2a53a4c3238c 260 {
lorcansmith 0:2a53a4c3238c 261 m_pControlEp->setNextToken(TD_IN);
lorcansmith 0:2a53a4c3238c 262 rc = m_pControlEp->transfer( (byte*) buf, len);
lorcansmith 0:2a53a4c3238c 263 while(m_pControlEp->status() == USBERR_PROCESSING);
lorcansmith 0:2a53a4c3238c 264 rc = (UsbErr) MIN(0, m_pControlEp->status());
lorcansmith 0:2a53a4c3238c 265 if(rc)
lorcansmith 0:2a53a4c3238c 266 return rc;
lorcansmith 0:2a53a4c3238c 267 }
lorcansmith 0:2a53a4c3238c 268 m_pControlEp->setNextToken(TD_OUT);
lorcansmith 0:2a53a4c3238c 269 rc = m_pControlEp->transfer(NULL, 0);
lorcansmith 0:2a53a4c3238c 270 while(m_pControlEp->status() == USBERR_PROCESSING);
lorcansmith 0:2a53a4c3238c 271 rc = (UsbErr) MIN(0, m_pControlEp->status());
lorcansmith 0:2a53a4c3238c 272 if(rc)
lorcansmith 0:2a53a4c3238c 273 return rc;
lorcansmith 0:2a53a4c3238c 274 return USBERR_OK;
lorcansmith 0:2a53a4c3238c 275 }
lorcansmith 0:2a53a4c3238c 276
lorcansmith 0:2a53a4c3238c 277 void UsbDevice::fillControlBuf(byte requestType, byte request, word value, word index, int len)
lorcansmith 0:2a53a4c3238c 278 {
lorcansmith 0:2a53a4c3238c 279 #ifdef __BIG_ENDIAN
lorcansmith 0:2a53a4c3238c 280 #error "Must implement BE to LE conv here"
lorcansmith 0:2a53a4c3238c 281 #endif
lorcansmith 0:2a53a4c3238c 282 m_controlBuf[0] = requestType;
lorcansmith 0:2a53a4c3238c 283 m_controlBuf[1] = request;
lorcansmith 0:2a53a4c3238c 284 //We are in LE so it's fine
lorcansmith 0:2a53a4c3238c 285 *((word*)&m_controlBuf[2]) = value;
lorcansmith 0:2a53a4c3238c 286 *((word*)&m_controlBuf[4]) = index;
lorcansmith 0:2a53a4c3238c 287 *((word*)&m_controlBuf[6]) = (word) len;
lorcansmith 0:2a53a4c3238c 288 }
lorcansmith 0:2a53a4c3238c 289
lorcansmith 0:2a53a4c3238c 290
lorcansmith 0:2a53a4c3238c 291 #endif