void usba10_usb_pipe_reset( dev_info_t *dip, usb_pipe_handle_t pipe_handle, usb_flags_t usb_flags, void (*cb)( usb_pipe_handle_t ph, usb_opaque_t arg, int rval, usb_cb_flags_t flags), usb_opaque_t cb_arg) { usb_pipe_reset(dip, pipe_handle, usb_flags, cb, cb_arg); }
/** Event handler for the library USB Control Request reception event. */ bool EVENT_USB_Device_ControlRequest(USB_Request_Header_t* req){ // zero out ep0_buf_in for (uint8_t i = 0; i < 64; i++) ep0_buf_in[i] = 0; usb_cmd = 0; if ((req->bmRequestType & CONTROL_REQTYPE_TYPE) == REQTYPE_VENDOR){ switch(req->bRequest){ case 0x00: // Info if (req->wIndex == 0){ USB_ep0_send_progmem((uint8_t*)hwversion, sizeof(hwversion)); }else if (req->wIndex == 1){ USB_ep0_send_progmem((uint8_t*)fwversion, sizeof(fwversion)); } return true; // bother a specified I2C address, return '1' if address ACKs, '0' if NACK // mnemonic - 0xBotherAddress case 0xBA: ep0_buf_in[0] = botherAddress(req->wIndex, req->wValue); USB_ep0_send(1); return true; // start sampling // mnemonic - 0xConfigure7imer case 0xC7: usb_pipe_reset(&ep_in); if (req->wIndex != 0) { startConversion(); ep0_buf_in[0] = 1; timeout_or_sampling_no_longer_enabled = 0; TCC0.CCA = req->wValue; TCC0.PER = 1 << 15; } else { TCC0.PER = 0; ep0_buf_in[0] = 0; timeout_or_sampling_no_longer_enabled = 1; } TCC0.CNT = 0; USB_ep0_send(1); return true; // return a bitmap of alive cells // mnemonic - 0x5Can case 0x5C: getAlive(); _delay_ms(5); for (uint8_t i = 0; i < 8; i++) {ep0_buf_in[i] = bitmap[i];} USB_ep0_send(8); return true; // return calibration information // mnemonic - 0x6etCalibration case 0x6C: { getCalibrationData(); _delay_ms(5); uint8_t offset = 40*req->wIndex+8*req->wValue; for (uint8_t i = 0; i < 8; i++) {ep0_buf_in[i] = calibrationData[offset+i];} USB_ep0_send(8); return true; } // disconnect from USB, jump to bootloader case 0xBB: USB_enter_bootloader(); return true; } } return false; }