diff options
Diffstat (limited to 'lib/chibios-contrib/os/hal/include/usbh/dev/aoa.h')
-rw-r--r-- | lib/chibios-contrib/os/hal/include/usbh/dev/aoa.h | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/include/usbh/dev/aoa.h b/lib/chibios-contrib/os/hal/include/usbh/dev/aoa.h new file mode 100644 index 000000000..1f36370fb --- /dev/null +++ b/lib/chibios-contrib/os/hal/include/usbh/dev/aoa.h | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio | ||
3 | Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) | ||
4 | |||
5 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | you may not use this file except in compliance with the License. | ||
7 | You may obtain a copy of the License at | ||
8 | |||
9 | http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | |||
11 | Unless required by applicable law or agreed to in writing, software | ||
12 | distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | See the License for the specific language governing permissions and | ||
15 | limitations under the License. | ||
16 | */ | ||
17 | |||
18 | #ifndef USBH_AOA_H_ | ||
19 | #define USBH_AOA_H_ | ||
20 | |||
21 | #include "hal_usbh.h" | ||
22 | |||
23 | #if HAL_USE_USBH && HAL_USBH_USE_AOA | ||
24 | |||
25 | /*===========================================================================*/ | ||
26 | /* Driver pre-compile time settings. */ | ||
27 | /*===========================================================================*/ | ||
28 | |||
29 | /*===========================================================================*/ | ||
30 | /* Derived constants and error checks. */ | ||
31 | /*===========================================================================*/ | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /* Driver data structures and types. */ | ||
35 | /*===========================================================================*/ | ||
36 | |||
37 | typedef enum { | ||
38 | USBHAOA_CHANNEL_STATE_UNINIT = 0, | ||
39 | USBHAOA_CHANNEL_STATE_STOP = 1, | ||
40 | USBHAOA_CHANNEL_STATE_ACTIVE = 2, | ||
41 | USBHAOA_CHANNEL_STATE_READY = 3 | ||
42 | } usbhaoa_channel_state_t; | ||
43 | |||
44 | typedef enum { | ||
45 | USBHAOA_STATE_UNINIT = 0, | ||
46 | USBHAOA_STATE_STOP = 1, | ||
47 | USBHAOA_STATE_ACTIVE = 2, | ||
48 | USBHAOA_STATE_READY = 3 | ||
49 | } usbhaoa_state_t; | ||
50 | |||
51 | typedef enum { | ||
52 | USBHAOA_AUDIO_MODE_DISABLED = 0, | ||
53 | USBHAOA_AUDIO_MODE_2CH_16BIT_PCM_44100 = 1, | ||
54 | } usbhaoa_audio_mode_t; | ||
55 | |||
56 | typedef struct { | ||
57 | struct _aoa_channel_cfg { | ||
58 | const char *manufacturer; | ||
59 | const char *model; | ||
60 | const char *description; | ||
61 | const char *version; | ||
62 | const char *uri; | ||
63 | const char *serial; | ||
64 | } channel; | ||
65 | |||
66 | struct _aoa_audio_cfg { | ||
67 | usbhaoa_audio_mode_t mode; | ||
68 | } audio; | ||
69 | |||
70 | } USBHAOAConfig; | ||
71 | |||
72 | #define _aoa_driver_methods \ | ||
73 | _base_asynchronous_channel_methods | ||
74 | |||
75 | struct AOADriverVMT { | ||
76 | _aoa_driver_methods | ||
77 | }; | ||
78 | |||
79 | typedef struct USBHAOAChannel USBHAOAChannel; | ||
80 | typedef struct USBHAOADriver USBHAOADriver; | ||
81 | |||
82 | struct USBHAOAChannel { | ||
83 | /* inherited from abstract asyncrhonous channel driver */ | ||
84 | const struct AOADriverVMT *vmt; | ||
85 | _base_asynchronous_channel_data | ||
86 | |||
87 | usbh_ep_t epin; | ||
88 | usbh_urb_t iq_urb; | ||
89 | threads_queue_t iq_waiting; | ||
90 | uint32_t iq_counter; | ||
91 | USBH_DECLARE_STRUCT_MEMBER(uint8_t iq_buff[64]); | ||
92 | uint8_t *iq_ptr; | ||
93 | |||
94 | usbh_ep_t epout; | ||
95 | usbh_urb_t oq_urb; | ||
96 | threads_queue_t oq_waiting; | ||
97 | uint32_t oq_counter; | ||
98 | USBH_DECLARE_STRUCT_MEMBER(uint8_t oq_buff[64]); | ||
99 | uint8_t *oq_ptr; | ||
100 | |||
101 | virtual_timer_t vt; | ||
102 | |||
103 | usbhaoa_channel_state_t state; | ||
104 | }; | ||
105 | |||
106 | struct USBHAOADriver { | ||
107 | /* inherited from abstract class driver */ | ||
108 | _usbh_base_classdriver_data | ||
109 | |||
110 | USBHAOAChannel channel; | ||
111 | |||
112 | usbhaoa_state_t state; | ||
113 | |||
114 | }; | ||
115 | |||
116 | #define USBHAOA_ACCESSORY_STRING_MANUFACTURER 0 | ||
117 | #define USBHAOA_ACCESSORY_STRING_MODEL 1 | ||
118 | #define USBHAOA_ACCESSORY_STRING_DESCRIPTION 2 | ||
119 | #define USBHAOA_ACCESSORY_STRING_VERSION 3 | ||
120 | #define USBHAOA_ACCESSORY_STRING_URI 4 | ||
121 | #define USBHAOA_ACCESSORY_STRING_SERIAL 5 | ||
122 | |||
123 | typedef bool (*usbhaoa_filter_callback_t)(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem, USBHAOAConfig *config); | ||
124 | |||
125 | /*===========================================================================*/ | ||
126 | /* Driver macros. */ | ||
127 | /*===========================================================================*/ | ||
128 | #define usbhaoaStop(aoap) | ||
129 | |||
130 | #define usbhaoaGetState(aoap) ((aoap)->state) | ||
131 | |||
132 | #define usbhaoaGetChannelState(aoap) ((aoap)->channel.state) | ||
133 | #define usbhaoaGetHost(aoap) ((aoap)->dev->host) | ||
134 | |||
135 | /*===========================================================================*/ | ||
136 | /* External declarations. */ | ||
137 | /*===========================================================================*/ | ||
138 | extern USBHAOADriver USBHAOAD[HAL_USBHAOA_MAX_INSTANCES]; | ||
139 | |||
140 | #ifdef __cplusplus | ||
141 | extern "C" { | ||
142 | #endif | ||
143 | /* AOA device driver */ | ||
144 | void usbhaoaChannelStart(USBHAOADriver *aoap); | ||
145 | void usbhaoaChannelStop(USBHAOADriver *aoap); | ||
146 | #ifdef __cplusplus | ||
147 | } | ||
148 | #endif | ||
149 | |||
150 | |||
151 | #endif | ||
152 | |||
153 | #endif /* USBH_AOA_H_ */ | ||