libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::STM32USBDevice Class Reference

STM32 USB 设备核心实现 / STM32 USB device core implementation. More...

#include <stm32_usb_dev.hpp>

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, ConstRawData uid={nullptr, 0}, USB::Speed speed=USB::Speed::FULL, USB::USBSpec spec=USB::USBSpec::USB_2_1)
 构造 USB 设备核心对象 / Construct USB device core object
 
void Init (bool in_isr) override
 初始化 / Initialize
 
void Deinit (bool in_isr) override
 反初始化 / Deinitialize
 
void Start (bool) override
 启动设备(由子类实现)/ Start device (implemented by derived class)
 
void Stop (bool) override
 停止设备(由子类实现)/ Stop device (implemented by derived class)
 
- 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, ConstRawData uid={nullptr, 0})
 构造函数 / Constructor
 
void OnSetupPacket (bool in_isr, const SetupPacket *setup)
 处理 Setup 包 / Handle Setup packet
 

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 {
  UNKNOWN = 0 , SETUP , DATA_OUT , STATUS_OUT ,
  DATA_IN , STATUS_IN , ZLP
}
 控制传输上下文 / Control transfer context 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
 
- Protected Member Functions inherited from LibXR::USB::DeviceCore
virtual ErrorCode SetAddress (uint8_t address, Context state)=0
 设置设备地址(由子类实现) Set device address (implemented by derived class).
 
virtual void EnableRemoteWakeup ()
 启用远程唤醒 / Enable remote wakeup
 
virtual void DisableRemoteWakeup ()
 禁用远程唤醒 / Disable remote wakeup
 
virtual bool IsRemoteWakeupEnabled () const
 远程唤醒是否启用 / Whether remote wakeup is enabled
 
Speed GetSpeed () const
 获取设备速度 / Get device speed
 

Detailed Description

STM32 USB 设备核心实现 / STM32 USB device core implementation.

Definition at line 21 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,
ConstRawData uid = {nullptr, 0},
USB::Speed speed = USB::Speed::FULL,
USB::USBSpec spec = USB::USBSpec::USB_2_1 )
inline

构造 USB 设备核心对象 / Construct USB device core object

Definition at line 27 of file stm32_usb_dev.hpp.

34 {nullptr, 0}, USB::Speed speed = USB::Speed::FULL,
35 USB::USBSpec spec = USB::USBSpec::USB_2_1)
36 : LibXR::USB::EndpointPool(max_ep_num),
37 LibXR::USB::DeviceCore(*this, spec, speed, packet_size, vid, pid, bcd, LANG_LIST,
38 CONFIGS, uid),
39 hpcd_(hpcd),
40 id_(id)
41 {
42 map_[id] = this;
43 }
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, ConstRawData uid={nullptr, 0})
构造函数 / Constructor
Definition dev_core.cpp:36
Speed speed
设备速度 / Device speed
Definition dev_core.hpp:346
EndpointPool(size_t endpoint_num)
构造函数 / Constructor
Definition ep_pool.cpp:5
LibXR 命名空间
Definition ch32_can.hpp:14

Member Function Documentation

◆ Deinit()

void LibXR::STM32USBDevice::Deinit ( bool in_isr)
inlineoverridevirtual

反初始化 / Deinitialize

Parameters
in_isr是否在 ISR / Whether in ISR context

Reimplemented from LibXR::USB::DeviceCore.

Definition at line 47 of file stm32_usb_dev.hpp.

virtual void Deinit(bool in_isr)
反初始化 / Deinitialize
Definition dev_core.cpp:151

◆ Init()

void LibXR::STM32USBDevice::Init ( bool in_isr)
inlineoverridevirtual

初始化 / Initialize

Parameters
in_isr是否在 ISR / Whether in ISR context

Reimplemented from LibXR::USB::DeviceCore.

Definition at line 45 of file stm32_usb_dev.hpp.

virtual void Init(bool in_isr)
初始化 / Initialize
Definition dev_core.cpp:129

◆ Start()

void LibXR::STM32USBDevice::Start ( bool in_isr)
inlineoverridevirtual

启动设备(由子类实现)/ Start device (implemented by derived class)

Parameters
in_isr是否在 ISR / Whether in ISR context

Implements LibXR::USB::DeviceCore.

Definition at line 49 of file stm32_usb_dev.hpp.

49{ HAL_PCD_Start(hpcd_); }

◆ Stop()

void LibXR::STM32USBDevice::Stop ( bool in_isr)
inlineoverridevirtual

停止设备(由子类实现)/ Stop device (implemented by derived class)

Parameters
in_isr是否在 ISR / Whether in ISR context

Implements LibXR::USB::DeviceCore.

Definition at line 50 of file stm32_usb_dev.hpp.

50{ HAL_PCD_Stop(hpcd_); }

Field Documentation

◆ hpcd_

PCD_HandleTypeDef* LibXR::STM32USBDevice::hpcd_

Definition at line 52 of file stm32_usb_dev.hpp.

◆ id_

stm32_usb_dev_id_t LibXR::STM32USBDevice::id_

Definition at line 53 of file stm32_usb_dev.hpp.

◆ map_

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

Definition at line 54 of file stm32_usb_dev.hpp.

54{};

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