diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2012-04-02 20:24:45 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2012-04-02 20:24:45 +0200 |
commit | 2529ce991e6eda9f8235084ed1b7a7e408c86866 (patch) | |
tree | cfbf4c9730d2924dfb43637c23f982d09f36c045 | |
parent | b1b3b431ac499d850a9f44b5ed104ebbcefc3c58 (diff) |
Added SET_CONFIGURATION.
-rw-r--r-- | main.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -52,16 +52,23 @@ void usb_write(uint32_t* bufp, uint32_t len) { } } -uint32_t dev_desc[] = {0x02000112, 0x400000ff, 0x56781234, 0x00000000, 0x0100}; -uint32_t conf_desc[] = {0x00090209, 0xc0000100, 0x00}; +uint8_t dev_desc[] = { + 0x12, 0x01, 0x00, 0x02, 0xff, 0x00, 0x00, 0x40, 0x34, 0x12, 0x78, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, +}; + +uint8_t conf_desc[] = { + 0x09, 0x02, 0x19, 0x00, 0x01, 0x01, 0x00, 0xc0, 0x00, + 0x09, 0x04, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, + 0x07, 0x05, 0x81, 0x02, 0x40, 0x00, 0x00, +}; bool get_descriptor(uint16_t wValue, uint16_t wIndex, uint16_t wLength) { switch(wValue) { case 0x100: - usb_write(dev_desc, wLength); + usb_write((uint32_t*)dev_desc, wLength > sizeof(dev_desc) ? sizeof(dev_desc) : wLength); return true; case 0x200: - usb_write(conf_desc, wLength); + usb_write((uint32_t*)conf_desc, wLength > sizeof(conf_desc) ? sizeof(conf_desc) : wLength); return true; default: return false; @@ -74,6 +81,15 @@ bool set_address(uint16_t wValue, uint16_t wIndex, uint16_t wLength) { return true; } +bool set_configuration(uint16_t wValue, uint16_t wIndex, uint16_t wLength) { + if(wValue > 1) { + return false; + } + + usb_write(0, 0); + return true; +} + bool jtag_shift(uint16_t wValue, uint16_t wIndex, uint16_t wLength) { if(wLength > 16) { return false; @@ -122,6 +138,13 @@ void handle_setup(const uint32_t* bufp) { } } + // SET_CONFIGURATION + if(bmRequestType == 0x00 && bRequest == 0x09) { + if(set_configuration(wValue, wIndex, wLength)) { + return; + } + } + // I2C_READ if(bmRequestType == 0xc0 && bRequest == 0xf0) { if(i2c_read(wValue, wIndex, wLength)) { |