-
Notifications
You must be signed in to change notification settings - Fork 164
usb: Allow partial packet writes, add error checking and documentation #848
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
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.
🔍 Lint Results
Found 1 issue on changed lines in 1 file:
- core/src/core/usb/drivers/cdc.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 14 issue(s) exist but are not on lines changed in this PR:
core/src/core/usb.zig:357: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb.zig:359: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb.zig:429: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/cdc.zig:217: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/hid.zig:93: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/hid.zig:103: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/hid.zig:116: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/types.zig:149: Suggestion: Rename `U16Le` to `U16_Le`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
examples/raspberrypi/rp2xxx/src/custom_clock_config.zig:11: TODO style comments need to have a linked microzig issue on the same line.
examples/raspberrypi/rp2xxx/src/usb_cdc.zig:14: Suggestion: Rename `UsbSerial` to `USB_Serial`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:11: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:64: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:183: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:223: TODO style comments need to have a linked microzig issue on the same line.
Updating with new lint results
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.
🔍 Lint Results
ℹ️ Additional issues on unchanged lines
The following 14 issue(s) exist but are not on lines changed in this PR:
core/src/core/usb.zig:358: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb.zig:360: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb.zig:430: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/cdc.zig:216: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/hid.zig:93: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/hid.zig:103: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/drivers/hid.zig:116: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/types.zig:149: Suggestion: Rename `U16Le` to `U16_Le`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
examples/raspberrypi/rp2xxx/src/custom_clock_config.zig:11: TODO style comments need to have a linked microzig issue on the same line.
examples/raspberrypi/rp2xxx/src/usb_cdc.zig:14: Suggestion: Rename `UsbSerial` to `USB_Serial`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:11: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:64: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:183: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:223: TODO style comments need to have a linked microzig issue on the same line.
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.
🔍 Lint Results
ℹ️ Additional issues on unchanged lines
The following 6 issue(s) exist but are not on lines changed in this PR:
core/src/core/usb/descriptor/hid.zig:17: Suggestion: Rename `Hid` to `HID`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
examples/raspberrypi/rp2xxx/src/custom_clock_config.zig:11: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:11: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:64: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:183: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:223: TODO style comments need to have a linked microzig issue on the same line.
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.
🔍 Lint Results
Found 6 issues on changed lines in 1 file:
- core/src/core/usb/types.zig: 6 issues
ℹ️ Additional issues on unchanged lines
The following 8 issue(s) exist but are not on lines changed in this PR:
core/src/core/usb/descriptor/hid.zig:17: Suggestion: Rename `Hid` to `HID`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
examples/raspberrypi/rp2xxx/src/custom_clock_config.zig:11: TODO style comments need to have a linked microzig issue on the same line.
examples/raspberrypi/rp2xxx/src/usb_hid.zig:83: TODO style comments need to have a linked microzig issue on the same line.
examples/raspberrypi/rp2xxx/src/usb_hid.zig:14: Suggestion: Rename `HidDriver` to `HID_Driver`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:11: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:64: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:183: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/clocks/common.zig:223: TODO style comments need to have a linked microzig issue on the same line.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const SubclassCdc = enum(u8) { |
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 SubclassCdc to Subclass_CDC, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const ProtocolCdc = enum(u8) { |
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 ProtocolCdc to Protocol_CDC, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const SubclassCdcData = enum(u8) { |
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 SubclassCdcData to Subclass_CDC_Data, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const ProtocolCdcData = enum(u8) { |
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 ProtocolCdcData to Protocol_CDC_Data, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const SubclassHid = enum(u8) { |
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 SubclassHid to Subclass_HID, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const ProtocolHid = enum(u8) { |
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 ProtocolHid to Protocol_HID, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
Updating with new lint results
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.
🔍 Lint Results
Found 12 issues on changed lines in 1 file:
- core/src/core/usb/types.zig: 12 issues
core/src/core/usb/types.zig
Outdated
| pub const Unspecified = Default; | ||
| pub const Audio = Default; | ||
|
|
||
| pub const Cdc = enum(u8) { |
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 Cdc to CDC, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const Hid = enum(u8) { |
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 Hid to HID, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
|
|
||
| pub const Hub = Default; | ||
|
|
||
| pub const CdcData = enum(u8) { |
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 CdcData to CDC_Data, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const PersonalHealthcare = Default; | ||
| pub const AudioVideoDevice = Default; | ||
| pub const BillboardDevice = Default; | ||
| pub const USBTypeCBridge = Default; |
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 USBTypeCBridge to USB_Type_C_Bridge, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const AudioVideoDevice = Default; | ||
| pub const BillboardDevice = Default; | ||
| pub const USBTypeCBridge = Default; | ||
| pub const USBBulkDisplayProtocol = Default; |
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 USBBulkDisplayProtocol to USB_BulkDisplayProtocol, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| _, | ||
| }; | ||
|
|
||
| pub const Hid = enum(u8) { |
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 Hid to HID, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
|
|
||
| pub const Hub = Default; | ||
|
|
||
| pub const CdcData = enum(u8) { |
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 CdcData to CDC_Data, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const PersonalHealthcare = Default; | ||
| pub const AudioVideoDevice = Default; | ||
| pub const BillboardDevice = Default; | ||
| pub const USBTypeCBridge = Default; |
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 USBTypeCBridge to USB_Type_C_Bridge, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const AudioVideoDevice = Default; | ||
| pub const BillboardDevice = Default; | ||
| pub const USBTypeCBridge = Default; | ||
| pub const USBBulkDisplayProtocol = Default; |
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 USBBulkDisplayProtocol to USB_BulkDisplayProtocol, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const BillboardDevice = Default; | ||
| pub const USBTypeCBridge = Default; | ||
| pub const USBBulkDisplayProtocol = Default; | ||
| pub const MCTPoverUSBProtocolEndpoint = Default; |
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 MCTPoverUSBProtocolEndpoint to MCT_Pover_USB_ProtocolEndpoint, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
Updating with new lint results
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.
🔍 Lint Results
Found 4 issues on changed lines in 1 file:
- core/src/core/usb/types.zig: 4 issues
core/src/core/usb/types.zig
Outdated
| pub const PersonalHealthcare = Default; | ||
| pub const AudioVideoDevice = Default; | ||
| pub const BillboardDevice = Default; | ||
| pub const TypeCBridge = Default; |
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 TypeCBridge to Type_C_Bridge, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const BillboardDevice = Default; | ||
| pub const TypeCBridge = Default; | ||
| pub const BulkDisplayProtocol = Default; | ||
| pub const MCTP_over_USB_ProtocolEndpoint = Default; |
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 MCTP_over_USB_ProtocolEndpoint to MCTP_Over_USB_ProtocolEndpoint, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const PersonalHealthcare = Default; | ||
| pub const AudioVideoDevice = Default; | ||
| pub const BillboardDevice = Default; | ||
| pub const TypeCBridge = Default; |
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 TypeCBridge to Type_C_Bridge, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/types.zig
Outdated
| pub const BillboardDevice = Default; | ||
| pub const TypeCBridge = Default; | ||
| pub const BulkDisplayProtocol = Default; | ||
| pub const MCTP_over_USB_ProtocolEndpoint = Default; |
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 MCTP_over_USB_ProtocolEndpoint to MCTP_Over_USB_ProtocolEndpoint, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
All lint issues have been resolved
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.
🔍 Lint Results
Found 3 issues on changed lines in 3 files:
- core/src/core/usb/drivers/cdc.zig: 1 issue
- core/src/core/usb/drivers/example.zig: 1 issue
- core/src/core/usb/drivers/hid.zig: 1 issue
core/src/core/usb/drivers/cdc.zig
Outdated
|
|
||
| const utilities = @import("../../../utilities.zig"); | ||
| const assert = std.debug.assert; | ||
| const EpNum = usb.types.Endpoint.Num; |
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 EpNum to EP_Num, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| @@ -0,0 +1,99 @@ | |||
| const std = @import("std"); | |||
| const usb = @import("../../usb.zig"); | |||
| const EpNum = usb.types.Endpoint.Num; | |||
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 EpNum to EP_Num, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
core/src/core/usb/drivers/hid.zig
Outdated
| const usb = @import("../../usb.zig"); | ||
| const descriptor = usb.descriptor; | ||
| const types = usb.types; | ||
| const EpNum = usb.types.Endpoint.Num; |
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 EpNum to EP_Num, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
All lint issues have been resolved
Changes:
usb_start_tx->ep_writev, now returns number of bytes writtenusb_start_rx->ep_readvandep_listen: This makes it easier to make interrupt-safe drivers