µ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-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_USBH_WRAPPER_H_
14#define CMSIS_PLUS_DRIVER_USBH_WRAPPER_H_
15
17
18// ----------------------------------------------------------------------------
19
20extern "C"
21{
22 // Avoid to include <Driver_USBH.h>
23 typedef uint32_t ARM_USBH_PIPE_HANDLE;
24
25 typedef void
26 (*ARM_USBH_SignalPortEvent_t) (uint8_t port, uint32_t event);
27 typedef void
29 uint32_t event);
30
31 typedef struct _ARM_DRIVER_USBH const ARM_DRIVER_USBH;
32}
33
34namespace os
35{
36 namespace driver
37 {
38 // ======================================================================
39
40#pragma GCC diagnostic push
41#if defined(__clang__)
42#pragma clang diagnostic ignored "-Wpadded"
43#elif defined(__GNUC__)
44#pragma GCC diagnostic ignored "-Wpadded"
45#endif
46
47 // This wrapper makes a CMSIS USBH Keil driver behave like a
48 // µOS++ Serial driver.
49
50 class usbh_wrapper : public usb::Host
51 {
52 public:
53
54 // --------------------------------------------------------------------
55
57 ARM_USBH_SignalPortEvent_t c_cb_port_func,
58 ARM_USBH_SignalPipeEvent_t c_cb_pipe_func) noexcept;
59
60 usbh_wrapper (const usbh_wrapper&) = delete;
61
63
65 operator= (const usbh_wrapper&) = delete;
66
69
70 virtual
71 ~usbh_wrapper () noexcept;
72
73 // --------------------------------------------------------------------
74
75 protected:
76
77 virtual const Version&
78 do_get_version (void) noexcept override;
79
80 virtual return_t
81 do_power (Power state) noexcept override;
82
83 virtual const usb::host::Capabilities&
84 do_get_capabilities (void) noexcept override;
85
86 virtual return_t
87 do_power_port_vbus (usb::port_t port, bool vbus) noexcept override;
88
89 virtual return_t
90 do_reset_port (usb::port_t port) noexcept override;
91
92 virtual return_t
93 do_suspend_port (usb::port_t port) noexcept override;
94
95 virtual return_t
96 do_resume_port (usb::port_t port) noexcept override;
97
98 virtual usb::host::Status&
99 do_get_port_status (usb::port_t port) noexcept override;
100
101 virtual usb::pipe_t
102 do_create_pipe (usb::device_address_t dev_addr, usb::speed_t dev_speed,
103 usb::hub_addr_t hub_addr, usb::hub_port_t hub_port,
104 usb::endpoint_t ep_addr, usb::endpoint_type_t ep_type,
105 usb::packet_size_t ep_max_packet_size,
106 usb::polling_interval_t ep_interval) noexcept override;
107
108 virtual return_t
109 do_modify_pipe (usb::pipe_t pipe, usb::device_address_t dev_addr,
110 usb::speed_t dev_speed, usb::hub_addr_t hub_addr,
111 usb::hub_port_t hub_port,
112 usb::packet_size_t ep_max_packet_size) noexcept override;
113
114 virtual return_t
115 do_delete_pipe (usb::pipe_t pipe) noexcept override;
116
117 virtual return_t
118 do_reset_pipe (usb::pipe_t pipe) noexcept override;
119
120 virtual return_t
121 do_transfer (usb::pipe_t pipe, uint32_t packet, uint8_t* data,
122 std::size_t num) noexcept override;
123
124 virtual std::size_t
125 do_get_transfer_count (usb::pipe_t pipe) noexcept override;
126
127 virtual return_t
128 do_abort_transfer (usb::pipe_t pipe) noexcept override;
129
130 virtual uint16_t
131 do_get_frame_number (void) noexcept override;
132
133 // --------------------------------------------------------------------
134
135 private:
136
139
144
145 // Attempts to somehow use && failed, since the Keil driver
146 // functions return temporary objects. So the only portable
147 // solution was to copy these objects here and return
148 // references to these objects.
149 // (Not particularly proud of this solution, but could not find
150 // a better one.)
151
153 { 0, 0 };
156
157 };
158
159#pragma GCC diagnostic pop
160
161 } /* namespace driver */
162} /* namespace os */
163
164// ----------------------------------------------------------------------------
165
166#endif /* CMSIS_PLUS_DRIVER_USBH_WRAPPER_H_ */
USB host driver capabilities.
Definition usb-host.h:64
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:47
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