libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::CH32USBDevice Class Reference
Inheritance diagram for LibXR::CH32USBDevice:
[legend]
Collaboration diagram for LibXR::CH32USBDevice:
[legend]

Public Member Functions

 CH32USBDevice (ch32_usb_dev_id_t id, size_t max_ep_num, USB::DeviceDescriptor::PacketSize0 packet_size, uint16_t vid, uint16_t pid, uint16_t bcd, const std::initializer_list< const USB::DescriptorStrings::LanguagePack * > LANG_LIST, const std::initializer_list< const std::initializer_list< USB::ConfigDescriptorItem * > > CONFIGS, USB::Speed speed=USB::Speed::FULL, USB::USBSpec spec=USB::USBSpec::USB_2_0)
 
void Init () override
 初始化 USB 设备 / Initialize USB device
 
void Deinit () override
 反初始化 USB 设备 / Deinitialize USB device
 
- Public Member Functions inherited from LibXR::USB::EndpointPool
 EndpointPool (size_t endpoint_num)
 构造函数 / Constructor
 
ErrorCode Get (Endpoint *&ep_info, Endpoint::Direction direction, Endpoint::EPNumber ep_num=Endpoint::EPNumber::EP_AUTO)
 分配端点 / Allocate endpoint
 
ErrorCode Release (Endpoint *ep_info)
 回收端点 / Release endpoint
 
ErrorCode FindEndpoint (uint8_t ep_addr, Endpoint *&ans)
 查找端点/ Lookup endpoint
 
EndpointGetEndpoint0Out ()
 获取端点0的OUT对象 / Get Endpoint 0's OUT object
 
EndpointGetEndpoint0In ()
 获取端点0的IN对象 / Get Endpoint 0's IN object
 
void SetEndpoint0 (Endpoint *ep0_in, Endpoint *ep0_out)
 设置端点0的IN/OUT对象 / Set Endpoint 0 IN/OUT objects
 
- Public Member Functions inherited from LibXR::USB::DeviceCore
 DeviceCore (EndpointPool &ep_pool, USBSpec spec, Speed speed, DeviceDescriptor::PacketSize0 packet_size, uint16_t vid, uint16_t pid, uint16_t bcd, const std::initializer_list< const DescriptorStrings::LanguagePack * > &lang_list, const std::initializer_list< const std::initializer_list< ConfigDescriptorItem * > > &configs)
 构造函数 / Constructor
 
virtual void Start ()=0
 启动 USB 设备 / Start USB device
 
virtual void Stop ()=0
 停止 USB 设备 / Stop USB device
 
void OnSetupPacket (bool in_isr, const SetupPacket *setup)
 处理主机发送的 SETUP 包 Handle USB setup packet from host
 

Data Fields

uint8_t id_
 
- Data Fields inherited from LibXR::USB::DeviceCore

Additional Inherited Members

- Public Types inherited from LibXR::USB::DeviceCore
enum  Context : uint8_t {
  UNKNOW , SETUP , DATA_OUT , STATUS_OUT ,
  DATA_IN , STATUS_IN , ZLP
}
 控制传输状态枚举 / Control transfer context enum More...
 
- Protected Types inherited from LibXR::LockFreePool< Endpoint * >
enum  SlotState
 槽状态 / Slot state More...
 
- Protected Member Functions inherited from LibXR::LockFreePool< Endpoint * >
Slot & operator[] (uint32_t index)
 
 LockFreePool (uint32_t slot_count)
 构造对象池 / Constructor for the pool
 
 ~LockFreePool ()
 析构,释放槽池内存 / Destructor, releasing pool memory
 
ErrorCode Put (const Endpoint *&data)
 向池中放入一个元素 / Put an element into the pool
 
ErrorCode Put (const Endpoint *&data, uint32_t &start_index)
 向池中放入一个元素,返回起始槽索引 / Put an element into the pool and return the starting slot index
 
ErrorCode PutToSlot (const Endpoint *&data, uint32_t index)
 向指定槽放入一个元素 / Put an element into a specific slot
 
ErrorCode Get (Endpoint *&data)
 从池中取出一个元素 / Retrieve an element from the pool
 
ErrorCode Get (Endpoint *&data, uint32_t &start_index)
 从指定槽位开始,取出一个元素 / Retrieve an element from the pool
 
ErrorCode GetFromSlot (Endpoint *&data, uint32_t index)
 从指定槽位开始,取出一个元素 / Retrieve an element from the pool
 
ErrorCode RecycleSlot (uint32_t index)
 回收指定槽位 / Recycle a slot
 
size_t Size () const
 查询池中可取元素数量 / Query the number of available elements in the pool
 
size_t EmptySize ()
 查询当前池可用槽数量 / Query the number of writable slots in the pool
 
uint32_t SlotCount () const
 获取槽总数 / Get the total number of slots in the pool
 

Detailed Description

Definition at line 13 of file ch32_usb_dev.hpp.

Constructor & Destructor Documentation

◆ CH32USBDevice()

LibXR::CH32USBDevice::CH32USBDevice ( ch32_usb_dev_id_t id,
size_t max_ep_num,
USB::DeviceDescriptor::PacketSize0 packet_size,
uint16_t vid,
uint16_t pid,
uint16_t bcd,
const std::initializer_list< const USB::DescriptorStrings::LanguagePack * > LANG_LIST,
const std::initializer_list< const std::initializer_list< USB::ConfigDescriptorItem * > > CONFIGS,
USB::Speed speed = USB::Speed::FULL,
USB::USBSpec spec = USB::USBSpec::USB_2_0 )
inline

Definition at line 16 of file ch32_usb_dev.hpp.

25 : USB::EndpointPool(max_ep_num),
26 USB::DeviceCore(*this, spec, speed, packet_size, vid, pid, bcd, LANG_LIST,
27 CONFIGS),
28 id_(id)
29 {
30 }
Speed speed
当前速度 / Current speed
Definition dev_core.hpp:351

Member Function Documentation

◆ Deinit()

void LibXR::CH32USBDevice::Deinit ( )
inlineoverridevirtual

反初始化 USB 设备 / Deinitialize USB device

Reimplemented from LibXR::USB::DeviceCore.

Definition at line 33 of file ch32_usb_dev.hpp.

virtual void Deinit()
反初始化 USB 设备 / Deinitialize USB device
Definition dev_core.cpp:102

◆ Init()

void LibXR::CH32USBDevice::Init ( )
inlineoverridevirtual

初始化 USB 设备 / Initialize USB device

Returns
void

Reimplemented from LibXR::USB::DeviceCore.

Definition at line 32 of file ch32_usb_dev.hpp.

virtual void Init()
初始化 USB 设备 / Initialize USB device
Definition dev_core.cpp:86

Field Documentation

◆ id_

uint8_t LibXR::CH32USBDevice::id_

Definition at line 35 of file ch32_usb_dev.hpp.


The documentation for this class was generated from the following file: