avr-fw-modules/usb/src/usb_cdc_class_setup.c

40 lines
865 B
C

#include <usb/usb.h>
#include <string.h>
#include <stdlib.h>
struct usb_cdc_linecoding cdc_linecoding = {
dwDTERate: 56000,
bCharFormat: 0,
bParityType: 0,
bDataBits: 8
};
cdc_linestate_t _usb_cdc;
static uint32_t temp32;
int usb_cdc_setup_request(int endpoint,usb_device_request_t *request){
switch (request->bRequest)
{
case CDC_REQUEST_GETLINECODING:
usb_endpoint_set_buffer( endpoint, &cdc_linecoding, sizeof(cdc_linecoding));
return 0;
case CDC_REQUEST_SETLINECODING:
usb_endpoint_set_buffer( endpoint, &cdc_linecoding, sizeof(cdc_linecoding));
return 0;
case CDC_REQUEST_SETCONTROL_LINE_STATE:
_usb_cdc.value = request->wValue;
usb_endpoint_set_buffer( endpoint, &temp32, 0 );
return 0;
case CDC_REQUEST_SENDBREAK:
usb_endpoint_set_buffer( endpoint, &temp32, 0 );
return 0;
default:
return -1;
};
};