-
Notifications
You must be signed in to change notification settings - Fork 164
ch32 USBHD/USBHS driver implementation #893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Started replacing constants with enums, changed the reset state for ep0 tx/rx ctrl from DATA0 to DATA1, I think that did it.
…into origin/umain
…oards. ch32 USBHS still sends packets twice.
…ual mode. CDC Works without extra packets!
…ed code in usb_cdc.zig
Lint ResultsFound 7 issues on changed lines in 3 files:
|
| }, | ||
| }; | ||
|
|
||
| const USBController = usb.DeviceController(.{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename USBController to USB_Controller, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| /// | ||
| /// Note: The SVD names bit31 as `USBFSSRC`, but the reference manual | ||
| /// describes it as `USBHSSRC` ("USBHS 48MHz clock source selection"). | ||
| pub const UsbHsClockConfig = struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename UsbHsClockConfig to USB_HsClockConfig, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
|
|
||
| const Regs = peripherals.USBHS; | ||
|
|
||
| const EpState = struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename EpState to EP_State, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| } | ||
|
|
||
| // We use offset-based access for per-EP regs to keep helpers compact. | ||
| const RegU32 = microzig.mmio.Mmio(packed struct(u32) { v: u32 = 0 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename RegU32 to Reg_U32, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
|
|
||
| // We use offset-based access for per-EP regs to keep helpers compact. | ||
| const RegU32 = microzig.mmio.Mmio(packed struct(u32) { v: u32 = 0 }); | ||
| const RegU16 = microzig.mmio.Mmio(packed struct(u16) { v: u16 = 0 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename RegU16 to Reg_U16, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| // We use offset-based access for per-EP regs to keep helpers compact. | ||
| const RegU32 = microzig.mmio.Mmio(packed struct(u32) { v: u32 = 0 }); | ||
| const RegU16 = microzig.mmio.Mmio(packed struct(u16) { v: u16 = 0 }); | ||
| const RegU8 = microzig.mmio.Mmio(packed struct(u8) { v: u8 = 0 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename RegU8 to Reg_U8, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| _reserved1: u2 = 0, | ||
| }); | ||
|
|
||
| fn baseAddr() usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to base_addr, in MicroZig we use snake case for function names.
This adds a new driver for the ch32 USBHD/USBHS peripheral, along with an example for the ch32v307 board that exposes the port.