µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
usbd-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_USBD_WRAPPER_H_
29#define CMSIS_PLUS_DRIVER_USBD_WRAPPER_H_
30
32
33// ----------------------------------------------------------------------------
34
35extern "C"
36{
37 // Avoid to include <Driver_USBD.h>
38 typedef void
39 (*ARM_USBD_SignalDeviceEvent_t) (uint32_t event);
40 typedef void
41 (*ARM_USBD_SignalEndpointEvent_t) (uint8_t ep_addr, uint32_t event);
42
43 typedef struct _ARM_DRIVER_USBD const ARM_DRIVER_USBD;
44}
45
46namespace os
47{
48 namespace driver
49 {
50 // ========================================================================
51
52#pragma GCC diagnostic push
53#pragma GCC diagnostic ignored "-Wpadded"
54
55 // This wrapper makes a CMSIS USBD Keil driver behave like a
56 // µOS++ Serial driver.
57
59 {
60 public:
61
62 // ----------------------------------------------------------------------
63
65 ARM_USBD_SignalDeviceEvent_t c_cb_device_func,
66 ARM_USBD_SignalEndpointEvent_t c_cb_endpoint_func) noexcept;
67
68 usbd_wrapper (const usbd_wrapper&) = delete;
69
71
73 operator= (const usbd_wrapper&) = delete;
74
77
78 virtual
79 ~usbd_wrapper () noexcept;
80
81 // ----------------------------------------------------------------------
82
83 protected:
84
85 virtual const Version&
86 do_get_version (void) noexcept override;
87
88 const usb::device::Capabilities&
89 do_get_capabilities (void) noexcept override;
90
91 virtual return_t
92 do_power (Power state) noexcept override;
93
94 virtual return_t
95 do_connect (void) noexcept override;
96
97 virtual return_t
98 do_disconnect (void) noexcept override;
99
100 virtual usb::device::Status&
101 do_get_status (void) noexcept override;
102
103 virtual return_t
104 do_wakeup_remote (void) noexcept override;
105
106 virtual return_t
107 do_configure_address (usb::device_address_t dev_addr) noexcept override;
108
109 virtual return_t
110 do_read_setup_packet (uint8_t* buf) noexcept override;
111
112 virtual usb::frame_number_t
113 do_get_frame_number (void) noexcept override;
114
115 virtual return_t
116 do_configure_endpoint (usb::endpoint_t ep_addr,
117 usb::Endpoint_type ep_type,
118 usb::packet_size_t ep_max_packet_size)
119 noexcept override;
120
121 virtual return_t
122 do_unconfigure_endpoint (usb::endpoint_t ep_addr) noexcept override;
123
124 virtual return_t
125 do_stall_endpoint (usb::endpoint_t ep_addr, bool stall) noexcept override;
126
127 virtual return_t
128 do_transfer (usb::endpoint_t ep_addr, uint8_t* data, std::size_t num)
129 noexcept override;
130
131 virtual std::size_t
132 do_get_transfer_count (usb::endpoint_t ep_addr) noexcept override;
133
134 virtual return_t
135 do_abort_transfer (usb::endpoint_t ep_addr) noexcept override;
136
137 // ----------------------------------------------------------------------
138
139 private:
140
143
148
149 // Attempts to somehow use && failed, since the Keil driver
150 // functions return temporary objects. So the only portable
151 // solution was to copy these objects here and return
152 // references to these objects.
153 // (Not particularly proud of this solution, but could not find
154 // a better one.)
155
157 { 0, 0 };
160
161 };
162
163#pragma GCC diagnostic pop
164
165 } /* namespace driver */
166} /* namespace os */
167
168// ----------------------------------------------------------------------------
169
170#endif /* CMSIS_PLUS_DRIVER_USBD_WRAPPER_H_ */
USB device driver capabilities.
Definition usb-device.h:76
ARM_USBD_SignalDeviceEvent_t c_cb_device_func_
usb::device::Capabilities capa_
virtual return_t do_unconfigure_endpoint(usb::endpoint_t ep_addr) noexcept override
virtual ~usbd_wrapper() noexcept
usb::device::Status status_
usbd_wrapper & operator=(const usbd_wrapper &)=delete
virtual usb::device::Status & do_get_status(void) noexcept override
virtual return_t do_connect(void) noexcept override
ARM_DRIVER_USBD * driver_
Pointer to CMSIS USBD Keil driver.
const usb::device::Capabilities & do_get_capabilities(void) noexcept override
virtual usb::frame_number_t do_get_frame_number(void) noexcept override
usbd_wrapper(const usbd_wrapper &)=delete
virtual return_t do_disconnect(void) noexcept override
virtual return_t do_configure_address(usb::device_address_t dev_addr) noexcept override
virtual const Version & do_get_version(void) noexcept override
virtual return_t do_configure_endpoint(usb::endpoint_t ep_addr, usb::Endpoint_type ep_type, usb::packet_size_t ep_max_packet_size) noexcept override
ARM_USBD_SignalEndpointEvent_t c_cb_endpoint_func_
virtual return_t do_abort_transfer(usb::endpoint_t ep_addr) noexcept override
virtual std::size_t do_get_transfer_count(usb::endpoint_t ep_addr) noexcept override
virtual return_t do_transfer(usb::endpoint_t ep_addr, uint8_t *data, std::size_t num) noexcept override
virtual return_t do_power(Power state) noexcept override
virtual return_t do_stall_endpoint(usb::endpoint_t ep_addr, bool stall) noexcept override
virtual return_t do_wakeup_remote(void) noexcept override
virtual return_t do_read_setup_packet(uint8_t *buf) noexcept override
usbd_wrapper(usbd_wrapper &&)=delete
int32_t return_t
Definition common.h:63
System namespace.
Standard std namespace.
void(* ARM_USBD_SignalEndpointEvent_t)(uint8_t ep_addr, uint32_t event)
Pointer to endpoint event callback.
void(* ARM_USBD_SignalDeviceEvent_t)(uint32_t event)
Pointer to device event callback.
struct _ARM_DRIVER_USBD const ARM_DRIVER_USBD