Skip to content

Conversation

@piotrfila
Copy link
Contributor

@piotrfila piotrfila commented Jan 10, 2026

Changes:

  • usb_start_tx -> ep_writev, now returns number of bytes written
  • usb_start_rx -> ep_readv and ep_listen: This makes it easier to make interrupt-safe drivers
  • More error checking when constructing descriptors
  • First attempt at documenting the usb driver comptime interface
  • The drivers now assume ACKs are handled automatically. This is the case for the rp2xxx usb controller but I have no idea if other controllers also handle it that way.

Copy link

@github-actions github-actions bot left a 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.

@github-actions github-actions bot dismissed their stale review January 10, 2026 23:47

Updating with new lint results

Copy link

@github-actions github-actions bot left a 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.

Copy link

@github-actions github-actions bot left a 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.

@piotrfila piotrfila marked this pull request as draft January 12, 2026 18:37
Copy link

@github-actions github-actions bot left a 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.

_,
};

pub const SubclassCdc = enum(u8) {

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.

_,
};

pub const ProtocolCdc = enum(u8) {

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.

_,
};

pub const SubclassCdcData = enum(u8) {

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.

_,
};

pub const ProtocolCdcData = enum(u8) {

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.

_,
};

pub const SubclassHid = enum(u8) {

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.

_,
};

pub const ProtocolHid = enum(u8) {

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.

@github-actions github-actions bot dismissed their stale review January 17, 2026 13:37

Updating with new lint results

Copy link

@github-actions github-actions bot left a 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

pub const Unspecified = Default;
pub const Audio = Default;

pub const Cdc = enum(u8) {

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.

_,
};

pub const Hid = enum(u8) {

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.


pub const Hub = Default;

pub const CdcData = enum(u8) {

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.

pub const PersonalHealthcare = Default;
pub const AudioVideoDevice = Default;
pub const BillboardDevice = Default;
pub const USBTypeCBridge = Default;

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.

pub const AudioVideoDevice = Default;
pub const BillboardDevice = Default;
pub const USBTypeCBridge = Default;
pub const USBBulkDisplayProtocol = Default;

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.

_,
};

pub const Hid = enum(u8) {

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.


pub const Hub = Default;

pub const CdcData = enum(u8) {

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.

pub const PersonalHealthcare = Default;
pub const AudioVideoDevice = Default;
pub const BillboardDevice = Default;
pub const USBTypeCBridge = Default;

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.

pub const AudioVideoDevice = Default;
pub const BillboardDevice = Default;
pub const USBTypeCBridge = Default;
pub const USBBulkDisplayProtocol = Default;

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.

pub const BillboardDevice = Default;
pub const USBTypeCBridge = Default;
pub const USBBulkDisplayProtocol = Default;
pub const MCTPoverUSBProtocolEndpoint = Default;

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.

@github-actions github-actions bot dismissed their stale review January 17, 2026 13:43

Updating with new lint results

Copy link

@github-actions github-actions bot left a 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

pub const PersonalHealthcare = Default;
pub const AudioVideoDevice = Default;
pub const BillboardDevice = Default;
pub const TypeCBridge = Default;

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.

pub const BillboardDevice = Default;
pub const TypeCBridge = Default;
pub const BulkDisplayProtocol = Default;
pub const MCTP_over_USB_ProtocolEndpoint = Default;

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.

pub const PersonalHealthcare = Default;
pub const AudioVideoDevice = Default;
pub const BillboardDevice = Default;
pub const TypeCBridge = Default;

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.

pub const BillboardDevice = Default;
pub const TypeCBridge = Default;
pub const BulkDisplayProtocol = Default;
pub const MCTP_over_USB_ProtocolEndpoint = Default;

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.

@github-actions github-actions bot dismissed their stale review January 17, 2026 13:46

All lint issues have been resolved

Copy link

@github-actions github-actions bot left a 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


const utilities = @import("../../../utilities.zig");
const assert = std.debug.assert;
const EpNum = usb.types.Endpoint.Num;

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;

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.

const usb = @import("../../usb.zig");
const descriptor = usb.descriptor;
const types = usb.types;
const EpNum = usb.types.Endpoint.Num;

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.

@github-actions github-actions bot dismissed their stale review January 18, 2026 13:32

All lint issues have been resolved

@piotrfila piotrfila marked this pull request as ready for review January 18, 2026 13:39
@piotrfila piotrfila marked this pull request as draft January 18, 2026 16:55
@piotrfila piotrfila marked this pull request as ready for review January 18, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants