summaryrefslogtreecommitdiffstats
path: root/firmware/usbstack/usb_serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usbstack/usb_serial.c')
-rw-r--r--firmware/usbstack/usb_serial.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c
index b49a5ca013..ae90b57078 100644
--- a/firmware/usbstack/usb_serial.c
+++ b/firmware/usbstack/usb_serial.c
@@ -174,7 +174,13 @@ static struct usb_endpoint_descriptor
.bInterval = 0
};
-static struct cdc_line_coding line_coding;
+union line_coding_buffer
+{
+ struct cdc_line_coding data;
+ unsigned char raw[64];
+};
+
+static union line_coding_buffer line_coding USB_DEVBSS_ATTR;
/* send_buffer: local ring buffer.
* transit_buffer: used to store aligned data that will be sent by the USB
@@ -184,10 +190,11 @@ static struct cdc_line_coding line_coding;
*/
#define BUFFER_SIZE 512
#define TRANSIT_BUFFER_SIZE 32
+#define RECV_BUFFER_SIZE 32
static unsigned char send_buffer[BUFFER_SIZE];
static unsigned char transit_buffer[TRANSIT_BUFFER_SIZE]
USB_DEVBSS_ATTR __attribute__((aligned(4)));
-static unsigned char receive_buffer[32]
+static unsigned char receive_buffer[512]
USB_DEVBSS_ATTR __attribute__((aligned(32)));
static void sendout(void);
@@ -293,13 +300,19 @@ bool usb_serial_control_request(struct usb_ctrlrequest* req, void* reqdata, unsi
{
if (req->bRequest == SET_LINE_CODING)
{
- if (req->wLength == sizeof(line_coding))
+ if (req->wLength == sizeof(struct cdc_line_coding))
{
/* Receive line coding into local copy */
- if(!reqdata)
- usb_drv_control_response(USB_CONTROL_RECEIVE, &line_coding, sizeof(line_coding));
+ if (!reqdata)
+ {
+ usb_drv_control_response(USB_CONTROL_RECEIVE, line_coding.raw,
+ sizeof(struct cdc_line_coding));
+ }
else
+ {
usb_drv_control_response(USB_CONTROL_ACK, NULL, 0);
+ }
+
handled = true;
}
}
@@ -317,10 +330,11 @@ bool usb_serial_control_request(struct usb_ctrlrequest* req, void* reqdata, unsi
{
if (req->bRequest == GET_LINE_CODING)
{
- if (req->wLength == sizeof(line_coding))
+ if (req->wLength == sizeof(struct cdc_line_coding))
{
/* Send back line coding so host is happy */
- usb_drv_control_response(USB_CONTROL_ACK, &line_coding, sizeof(line_coding));
+ usb_drv_control_response(USB_CONTROL_ACK, line_coding.raw,
+ sizeof(struct cdc_line_coding));
handled = true;
}
}
@@ -332,7 +346,7 @@ bool usb_serial_control_request(struct usb_ctrlrequest* req, void* reqdata, unsi
void usb_serial_init_connection(void)
{
/* prime rx endpoint */
- usb_drv_recv_nonblocking(ep_out, receive_buffer, sizeof receive_buffer);
+ usb_drv_recv_nonblocking(ep_out, receive_buffer, RECV_BUFFER_SIZE);
/* we come here too after a bus reset, so reset some data */
buffer_transitlength = 0;
@@ -423,7 +437,7 @@ void usb_serial_transfer_complete(int ep,int dir, int status, int length)
/* Data received. TODO : Do something with it ? */
/* Get the next bit */
- usb_drv_recv_nonblocking(ep_out, receive_buffer, sizeof receive_buffer);
+ usb_drv_recv_nonblocking(ep_out, receive_buffer, RECV_BUFFER_SIZE);
break;
case USB_DIR_IN: