-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusbcdc.h
More file actions
94 lines (81 loc) · 2.97 KB
/
Copy pathusbcdc.h
File metadata and controls
94 lines (81 loc) · 2.97 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
*
* Copyright 2019 The wookey project team <wookey@ssi.gouv.fr>
* - Ryad Benadjila
* - Arnauld Michelizza
* - Mathieu Renard
* - Philippe Thierry
* - Philippe Trebuchet
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* the Free Software Foundation; either version 2.1 of the License, or (at
* ur option) any later version.
*
* This package is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with this package; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef USBCDC_H_
#define USBCDC_H_
#include "libc/types.h"
#include "libc/stdio.h"
#include "libc/syscall.h"
#include "api/libusbcdc.h"
#include "libusbctrl.h"
#include "autoconf.h"
#if CONFIG_USR_LIB_USBCDC_DEBUG && !__FRAMAC__
# define log_printf(...) printf(__VA_ARGS__)
#else
# define log_printf(...)
#endif
/* 2 interfaces per fonction (composite device) */
#define MAX_USBCDC_FUNCTIONS 2
typedef struct {
uint8_t id; /* IN EP identifier */
} usbcdc_inep_t;
/*
* Each USB HID interface is composed of:
* - an interface id (used to determine which interface is called by the host), set by libxDCI,
* as other classes may declare interfaces to libxDCI
* - a usbctrl_interface_t structure, passed to the lower libxDCI interface
* - an IN EP specific HID level meta-properties, associated to the IN EP declared in the
* usbctrl_interface_t
* - various callbacks for standard HID requests
* - a 'configured' flag, which control that the interface has been properly set and
* configured.
*/
typedef struct {
usb_cdc_receive_t receive;
usb_cdc_sent_t sent;
usbctrl_interface_t iface;
uint8_t *buf;
uint16_t buf_len;
uint16_t buf_idx;
uint8_t stty_mode;
bool configured;
bool declared;
bool data_received;
bool data_sent;
bool data_being_sent;
uint8_t id;
} usbcdc_iface_t;
/*
* A USB HID context may have one or more concurrent HID interface(s).
* These interfaces are declared successively.
*/
typedef struct {
uint8_t rqstbuf[64];
uint8_t rqstbuflen;
uint8_t num_iface; /* number of reports */
usbcdc_iface_t cdc_ifaces[2*MAX_USBCDC_FUNCTIONS];
} usbcdc_context_t;
usbcdc_context_t *usbcdc_get_context(void);
bool usbcdc_interface_exists(uint8_t cdc_handler);
mbed_error_t usbcdc_ctrl_send(uint32_t dev_id __attribute__((unused)), uint32_t size, uint8_t ep_id);
#endif/*!USBCDC_H_*/