µ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-2023 Liviu Ionescu. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software
7 * for any purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can
10 * be obtained from https://opensource.org/licenses/mit/.
11 */
12
13#ifndef CMSIS_PLUS_DRIVER_USBD_WRAPPER_H_
14#define CMSIS_PLUS_DRIVER_USBD_WRAPPER_H_
15
17
18// ----------------------------------------------------------------------------
19
20extern "C"
21{
22 // Avoid to include <Driver_USBD.h>
23 typedef void
24 (*ARM_USBD_SignalDeviceEvent_t) (uint32_t event);
25 typedef void
26 (*ARM_USBD_SignalEndpointEvent_t) (uint8_t ep_addr, uint32_t event);
27
28 typedef struct _ARM_DRIVER_USBD const ARM_DRIVER_USBD;
29}
30
31namespace os
32{
33 namespace driver
34 {
35 // ========================================================================
36
37#pragma GCC diagnostic push
38#if defined(__clang__)
39#pragma clang diagnostic ignored "-Wpadded"
40#elif defined(__GNUC__)
41#pragma GCC diagnostic ignored "-Wpadded"
42#endif
43
44 // This wrapper makes a CMSIS USBD Keil driver behave like a
45 // µOS++ Serial driver.
46
48 {
49 public:
50
51 // ----------------------------------------------------------------------
52
54 ARM_USBD_SignalDeviceEvent_t c_cb_device_func,
55 ARM_USBD_SignalEndpointEvent_t c_cb_endpoint_func) noexcept;
56
57 usbd_wrapper (const usbd_wrapper&) = delete;
58
60
62 operator= (const usbd_wrapper&) = delete;
63
66
67 virtual
68 ~usbd_wrapper () noexcept;
69
70 // ----------------------------------------------------------------------
71
72 protected:
73
74 virtual const Version&
75 do_get_version (void) noexcept override;
76
77 const usb::device::Capabilities&
78 do_get_capabilities (void) noexcept override;
79
80 virtual return_t
81 do_power (Power state) noexcept override;
82
83 virtual return_t
84 do_connect (void) noexcept override;
85
86 virtual return_t
87 do_disconnect (void) noexcept override;
88
89 virtual usb::device::Status&
90 do_get_status (void) noexcept override;
91
92 virtual return_t
93 do_wakeup_remote (void) noexcept override;
94
95 virtual return_t
96 do_configure_address (usb::device_address_t dev_addr) noexcept override;
97
98 virtual return_t
99 do_read_setup_packet (uint8_t* buf) noexcept override;
100
101 virtual usb::frame_number_t
102 do_get_frame_number (void) noexcept override;
103
104 virtual return_t
105 do_configure_endpoint (usb::endpoint_t ep_addr,
106 usb::Endpoint_type ep_type,
107 usb::packet_size_t ep_max_packet_size)
108 noexcept override;
109
110 virtual return_t
111 do_unconfigure_endpoint (usb::endpoint_t ep_addr) noexcept override;
112
113 virtual return_t
114 do_stall_endpoint (usb::endpoint_t ep_addr, bool stall) noexcept override;
115
116 virtual return_t
117 do_transfer (usb::endpoint_t ep_addr, uint8_t* data, std::size_t num)
118 noexcept override;
119
120 virtual std::size_t
121 do_get_transfer_count (usb::endpoint_t ep_addr) noexcept override;
122
123 virtual return_t
124 do_abort_transfer (usb::endpoint_t ep_addr) noexcept override;
125
126 // ----------------------------------------------------------------------
127
128 private:
129
132
137
138 // Attempts to somehow use && failed, since the Keil driver
139 // functions return temporary objects. So the only portable
140 // solution was to copy these objects here and return
141 // references to these objects.
142 // (Not particularly proud of this solution, but could not find
143 // a better one.)
144
146 { 0, 0 };
149
150 };
151
152#pragma GCC diagnostic pop
153
154 } /* namespace driver */
155} /* namespace os */
156
157// ----------------------------------------------------------------------------
158
159#endif /* CMSIS_PLUS_DRIVER_USBD_WRAPPER_H_ */
USB device driver capabilities.
Definition usb-device.h:64
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:47
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