libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
ch32_usb_endpoint.hpp
1#pragma once
2
3#include "ch32_usb.hpp"
4#include "libxr_def.hpp"
5#include "usb/core/ep.hpp"
6
7namespace LibXR
8{
9#if defined(USBFSD)
10class CH32EndpointOtgFs : public USB::Endpoint
11{
12 public:
13 CH32EndpointOtgFs(EPNumber ep_num, Direction dir, LibXR::RawData buffer,
14 bool is_isochronous);
15
16 void Configure(const Config& cfg) override;
17 void Close() override;
18 ErrorCode Transfer(size_t size) override;
19
20 void TransferComplete(size_t size);
21 ErrorCode Stall() override;
22 ErrorCode ClearStall() override;
23
24 void SwitchBuffer() override;
25
26 bool tog_ = false;
27 bool is_isochronous_ = false;
28
29 size_t last_transfer_size_ = 0;
30
31 RawData dma_buffer_;
32
33 static constexpr uint8_t EP_OTG_FS_MAX_SIZE = 8;
34 static inline CH32EndpointOtgFs* map_otg_fs_[EP_OTG_FS_MAX_SIZE][2] = {};
35};
36#endif
37
38#if defined(USBHSD)
39class CH32EndpointOtgHs : public USB::Endpoint
40{
41 public:
42 CH32EndpointOtgHs(EPNumber ep_num, Direction dir, LibXR::RawData buffer,
43 bool double_buffer);
44
45 void Configure(const Config& cfg) override;
46 void Close() override;
47 ErrorCode Transfer(size_t size) override;
48
49 void TransferComplete(size_t size);
50 ErrorCode Stall() override;
51 ErrorCode ClearStall() override;
52
53 void SwitchBuffer() override;
54
55 uint8_t dev_id_;
56 bool tog0_ = false;
57 bool tog1_ = false;
58 bool hw_double_buffer_ = false;
59
60 size_t last_transfer_size_ = 0;
61
62 RawData dma_buffer_;
63
64 static constexpr uint8_t EP_OTG_HS_MAX_SIZE = 16;
65 static inline CH32EndpointOtgHs* map_otg_hs_[EP_OTG_HS_MAX_SIZE][2] = {};
66};
67#endif
68} // namespace LibXR
原始数据封装类。 A class for encapsulating raw data.
LibXR 命名空间