Skip to content

nrf5x: USBD implementation and examples#965

Open
kotokrad wants to merge 4 commits into
ZigEmbeddedGroup:mainfrom
kotokrad:nrf5x-usbd
Open

nrf5x: USBD implementation and examples#965
kotokrad wants to merge 4 commits into
ZigEmbeddedGroup:mainfrom
kotokrad:nrf5x-usbd

Conversation

@kotokrad

Copy link
Copy Markdown
Contributor

Working USBD, both CDC and HID examples work on nrf52840 (tested on nice!nano and a clone). For PR I adapted them for nrf52840_mdk for consistency but haven't tested as I don't have this board.
HAL structure and examples are based on usb for rp2xxx port.

  • There's a workaround for regz: stride is not applied in cluster arrays #962
  • HFXO is assumed to be enabled by user before initializing USBD.
  • It reads from POWER peripheral to detect VBUS event, but it will be not accessible with softdevice enabled. Probably need some generic way to access it
  • Suspend/resume are not implemented, also it would need access to CLOCK to stop/start HFXO which might be blocked by softdevice.
  • ISO endpoints are not implemented
  • It compiles for nrf52833, but not tested

@mattnite

Copy link
Copy Markdown
Contributor

@kotokrad This is a great looking patch. Please ignore failing macos related actions, it seems that it's too new for Zig 0.15.2. It looks like you have some unused imports. Once those are fixed this is ready for a merge.

@kotokrad

Copy link
Copy Markdown
Contributor Author

@mattnite fixed 👌

@Grazfather

Copy link
Copy Markdown
Collaborator

I have the MDK. Give me a few days to test it.

Comment thread port/nordic/nrf5x/src/hal/usbd/errata.zig
Comment thread port/nordic/nrf5x/src/hal/usbd.zig Outdated
// Bus reset
if (peripherals.USBD.EVENTS_USBRESET.raw != 0) {
peripherals.USBD.EVENTS_USBRESET.write_raw(0);
_ = peripherals.USBD.EVENTS_USBRESET.read();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same spurious interrupt WAR? Can you please comment so

};
}

pub fn poll(self: *@This(), controller: anytype) void {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please do const Self = @This(); in the class and use that?

}
}

// Suspend (not implemented)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add greppable TODOs for these.

peripherals.USBD.SHORTS.write(.{ .EP0DATADONE_EP0STATUS = .Disabled });
}

// Here, nrf-usbd does this:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we not doing this?

@Grazfather

Copy link
Copy Markdown
Collaborator

Tested on my MDK. Works without issue. Please address my comments and figure out why CI if failing and we can merge this.

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.

3 participants