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

Public Member Functions

 STM32USBDevice (PCD_HandleTypeDef *hpcd, stm32_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
 
void Start () override
 启动 USB 设备 / Start USB device
 
void Stop () override
 停止 USB 设备 / Stop 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
 
void OnSetupPacket (bool in_isr, const SetupPacket *setup)
 处理主机发送的 SETUP 包 Handle USB setup packet from host
 

Data Fields

PCD_HandleTypeDef * hpcd_
 
stm32_usb_dev_id_t id_
 
- Data Fields inherited from LibXR::USB::DeviceCore

Static Public Attributes

static STM32USBDevicemap_ [STM32_USB_DEV_ID_NUM] = {}
 

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 18 of file stm32_usb_dev.hpp.

Constructor & Destructor Documentation

◆ STM32USBDevice()

LibXR::STM32USBDevice::STM32USBDevice ( PCD_HandleTypeDef * hpcd,
stm32_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 21 of file stm32_usb_dev.hpp.

29 : LibXR::USB::EndpointPool(max_ep_num),
30 LibXR::USB::DeviceCore(*this, spec, speed, packet_size, vid, pid, bcd, LANG_LIST,
31 CONFIGS),
32 hpcd_(hpcd),
33 id_(id)
34 {
35 map_[id] = this;
36 }
USB 设备协议栈核心类,负责端点 0 控制传输及配置、描述符、标准请求处理等。 USB device protocol stack core class. Handles EP0 control tr...
Definition dev_core.hpp:108
Speed speed
当前速度 / Current speed
Definition dev_core.hpp:351
USB端点池类 / USB endpoint pool class.
Definition ep_pool.hpp:23

Member Function Documentation

◆ Deinit()

void LibXR::STM32USBDevice::Deinit ( )
inlineoverridevirtual

反初始化 USB 设备 / Deinitialize USB device

Reimplemented from LibXR::USB::DeviceCore.

Definition at line 40 of file stm32_usb_dev.hpp.

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

◆ Init()

void LibXR::STM32USBDevice::Init ( )
inlineoverridevirtual

初始化 USB 设备 / Initialize USB device

Returns
void

Reimplemented from LibXR::USB::DeviceCore.

Definition at line 38 of file stm32_usb_dev.hpp.

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

◆ Start()

void LibXR::STM32USBDevice::Start ( )
inlineoverridevirtual

启动 USB 设备 / Start USB device

Implements LibXR::USB::DeviceCore.

Definition at line 42 of file stm32_usb_dev.hpp.

42{ HAL_PCD_Start(hpcd_); }

◆ Stop()

void LibXR::STM32USBDevice::Stop ( )
inlineoverridevirtual

停止 USB 设备 / Stop USB device

Implements LibXR::USB::DeviceCore.

Definition at line 43 of file stm32_usb_dev.hpp.

43{ HAL_PCD_Stop(hpcd_); }

Field Documentation

◆ hpcd_

PCD_HandleTypeDef* LibXR::STM32USBDevice::hpcd_

Definition at line 45 of file stm32_usb_dev.hpp.

◆ id_

stm32_usb_dev_id_t LibXR::STM32USBDevice::id_

Definition at line 46 of file stm32_usb_dev.hpp.

◆ map_

STM32USBDevice* LibXR::STM32USBDevice::map_[STM32_USB_DEV_ID_NUM] = {}
inlinestatic

Definition at line 47 of file stm32_usb_dev.hpp.

47{};

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