µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
usbh-wrapper.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ distribution.
3 * (https://github.com/micro-os-plus)
4 * Copyright (c) 2016 Liviu Ionescu.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#ifndef CMSIS_PLUS_DRIVER_USBH_WRAPPER_H_
29#define CMSIS_PLUS_DRIVER_USBH_WRAPPER_H_
30
32
33// ----------------------------------------------------------------------------
34
35extern "C"
36{
37 // Avoid to include <Driver_USBH.h>
38 typedef uint32_t ARM_USBH_PIPE_HANDLE;
39
40 typedef void
41 (*ARM_USBH_SignalPortEvent_t) (uint8_t port, uint32_t event);
42 typedef void
44 uint32_t event);
45
46 typedef struct _ARM_DRIVER_USBH const ARM_DRIVER_USBH;
47}
48
49namespace os
50{
51 namespace driver
52 {
53 // ======================================================================
54
55#pragma GCC diagnostic push
56#pragma GCC diagnostic ignored "-Wpadded"
57
58 // This wrapper makes a CMSIS USBH Keil driver behave like a
59 // µOS++ Serial driver.
60
61 class usbh_wrapper : public usb::Host
62 {
63 public:
64
65 // --------------------------------------------------------------------
66
68 ARM_USBH_SignalPortEvent_t c_cb_port_func,
69 ARM_USBH_SignalPipeEvent_t c_cb_pipe_func) noexcept;
70
71 usbh_wrapper (const usbh_wrapper&) = delete;
72
74
76 operator= (const usbh_wrapper&) = delete;
77
80
81 virtual
82 ~usbh_wrapper () noexcept;
83
84 // --------------------------------------------------------------------
85
86 protected:
87
88 virtual const Version&
89 do_get_version (void) noexcept override;
90
91 virtual return_t
92 do_power (Power state) noexcept override;
93
94 virtual const usb::host::Capabilities&
95 do_get_capabilities (void) noexcept override;
96
97 virtual return_t
98 do_power_port_vbus (usb::port_t port, bool vbus) noexcept override;
99
100 virtual return_t
101 do_reset_port (usb::port_t port) noexcept override;
102
103 virtual return_t
104 do_suspend_port (usb::port_t port) noexcept override;
105
106 virtual return_t
107 do_resume_port (usb::port_t port) noexcept override;
108
109 virtual usb::host::Status&
110 do_get_port_status (usb::port_t port) noexcept override;
111
112 virtual usb::pipe_t
113 do_create_pipe (usb::device_address_t dev_addr, usb::speed_t dev_speed,
114 usb::hub_addr_t hub_addr, usb::hub_port_t hub_port,
115 usb::endpoint_t ep_addr, usb::endpoint_type_t ep_type,
116 usb::packet_size_t ep_max_packet_size,
117 usb::polling_interval_t ep_interval) noexcept override;
118
119 virtual return_t
120 do_modify_pipe (usb::pipe_t pipe, usb::device_address_t dev_addr,
121 usb::speed_t dev_speed, usb::hub_addr_t hub_addr,
122 usb::hub_port_t hub_port,
123 usb::packet_size_t ep_max_packet_size) noexcept override;
124
125 virtual return_t
126 do_delete_pipe (usb::pipe_t pipe) noexcept override;
127
128 virtual return_t
129 do_reset_pipe (usb::pipe_t pipe) noexcept override;
130
131 virtual return_t
132 do_transfer (usb::pipe_t pipe, uint32_t packet, uint8_t* data,
133 std::size_t num) noexcept override;
134
135 virtual std::size_t
136 do_get_transfer_count (usb::pipe_t pipe) noexcept override;
137
138 virtual return_t
139 do_abort_transfer (usb::pipe_t pipe) noexcept override;
140
141 virtual uint16_t
142 do_get_frame_number (void) noexcept override;
143
144 // --------------------------------------------------------------------
145
146 private:
147
150
155
156 // Attempts to somehow use && failed, since the Keil driver
157 // functions return temporary objects. So the only portable
158 // solution was to copy these objects here and return
159 // references to these objects.
160 // (Not particularly proud of this solution, but could not find
161 // a better one.)
162
164 { 0, 0 };
167
168 };
169
170#pragma GCC diagnostic pop
171
172 } /* namespace driver */
173} /* namespace os */
174
175// ----------------------------------------------------------------------------
176
177#endif /* CMSIS_PLUS_DRIVER_USBH_WRAPPER_H_ */
USB host driver capabilities.
Definition usb-host.h:76
virtual return_t do_transfer(usb::pipe_t pipe, uint32_t packet, uint8_t *data, std::size_t num) noexcept override
virtual return_t do_reset_pipe(usb::pipe_t pipe) noexcept override
virtual return_t do_modify_pipe(usb::pipe_t pipe, usb::device_address_t dev_addr, usb::speed_t dev_speed, usb::hub_addr_t hub_addr, usb::hub_port_t hub_port, usb::packet_size_t ep_max_packet_size) noexcept override
ARM_USBH_SignalPipeEvent_t c_cb_pipe_func_
virtual ~usbh_wrapper() noexcept
virtual const usb::host::Capabilities & do_get_capabilities(void) noexcept override
virtual uint16_t do_get_frame_number(void) noexcept override
virtual const Version & do_get_version(void) noexcept override
ARM_USBH_SignalPortEvent_t c_cb_port_func_
virtual usb::pipe_t do_create_pipe(usb::device_address_t dev_addr, usb::speed_t dev_speed, usb::hub_addr_t hub_addr, usb::hub_port_t hub_port, usb::endpoint_t ep_addr, usb::endpoint_type_t ep_type, usb::packet_size_t ep_max_packet_size, usb::polling_interval_t ep_interval) noexcept override
virtual return_t do_power_port_vbus(usb::port_t port, bool vbus) noexcept override
usb::host::Status status_
usb::host::Capabilities capa_
virtual std::size_t do_get_transfer_count(usb::pipe_t pipe) noexcept override
virtual return_t do_power(Power state) noexcept override
usbh_wrapper & operator=(const usbh_wrapper &)=delete
virtual return_t do_suspend_port(usb::port_t port) noexcept override
virtual return_t do_delete_pipe(usb::pipe_t pipe) noexcept override
usbh_wrapper(const usbh_wrapper &)=delete
ARM_DRIVER_USBH * driver_
Pointer to CMSIS USBD Keil driver.
virtual return_t do_reset_port(usb::port_t port) noexcept override
virtual return_t do_resume_port(usb::port_t port) noexcept override
virtual return_t do_abort_transfer(usb::pipe_t pipe) noexcept override
usbh_wrapper(usbh_wrapper &&)=delete
virtual usb::host::Status & do_get_port_status(usb::port_t port) noexcept override
int32_t return_t
Definition common.h:63
System namespace.
Standard std namespace.
unsigned int speed_t
Definition termios.h:276
void(* ARM_USBH_SignalPipeEvent_t)(ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t event)
Pointer to pipe event callback.
uint32_t ARM_USBH_PIPE_HANDLE
void(* ARM_USBH_SignalPortEvent_t)(uint8_t port, uint32_t event)
Pointer to port event callback.
struct _ARM_DRIVER_USBH const ARM_DRIVER_USBH