cherry-embedded / CherryUSB

CherryUSB is a tiny, beautiful and portable USB host and device stack for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.21k stars 256 forks source link

Class 的注册方式能使用数组吗? #90

Closed AnemosCiel closed 1 year ago

AnemosCiel commented 1 year ago

Class的注册使用编译进内存的方式在不同编译器下移植起来太麻烦了,对编译原理和内存分区理解不够,能有一个分支用数组的方式实现吗?将Class的句柄加进数组就是注册。 我尝试改了一下,但是似乎哪里出了点问题。

sakumisu commented 1 year ago

跟编译原理和内存分区没有一点关系,仅仅只是链表跟数组的赋值和查找区别,这可是大学的基本功啊。

sakumisu commented 1 year ago

usbd_add_interface 里面换成数组就一句 intf_arr[intf->intf_num] = intf; ,哪有难度?