-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathusb_queue_not_blocking.diff
51 lines (42 loc) · 1.9 KB
/
usb_queue_not_blocking.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
diff -rupN a/os/hal/include/serial_usb.h b/os/hal/include/serial_usb.h
--- a/os/hal/include/serial_usb.h 2013-05-11 08:13:40.000000000 +0200
+++ b/os/hal/include/serial_usb.h 2015-08-18 20:45:10.213602883 +0200
@@ -161,6 +161,14 @@ typedef struct {
* @brief Interrupt IN endpoint used for notifications.
*/
usbep_t int_in;
+ /**
+ * @brief Default timeout to use for output operations (write/put).
+ */
+ systime_t out_tout;
+ /**
+ * @brief Default timeout to use for input operations (read/get).
+ */
+ systime_t in_tout;
} SerialUSBConfig;
/**
diff -rupN a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c
--- a/os/hal/src/serial_usb.c 2013-05-11 08:13:46.000000000 +0200
+++ b/os/hal/src/serial_usb.c 2015-08-18 20:45:46.060759983 +0200
@@ -69,23 +69,25 @@ static cdc_linecoding_t linecoding = {
static size_t write(void *ip, const uint8_t *bp, size_t n) {
return chOQWriteTimeout(&((SerialUSBDriver *)ip)->oqueue, bp,
- n, TIME_INFINITE);
+ n, ((SerialUSBDriver *)ip)->config->out_tout);
}
static size_t read(void *ip, uint8_t *bp, size_t n) {
return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp,
- n, TIME_INFINITE);
+ n, ((SerialUSBDriver *)ip)->config->in_tout);
}
static msg_t put(void *ip, uint8_t b) {
- return chOQPutTimeout(&((SerialUSBDriver *)ip)->oqueue, b, TIME_INFINITE);
+ return chOQPutTimeout(&((SerialUSBDriver *)ip)->oqueue,
+ b, ((SerialUSBDriver *)ip)->config->out_tout);
}
static msg_t get(void *ip) {
- return chIQGetTimeout(&((SerialUSBDriver *)ip)->iqueue, TIME_INFINITE);
+ return chIQGetTimeout(&((SerialUSBDriver *)ip)->iqueue,
+ ((SerialUSBDriver *)ip)->config->in_tout);
}
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {