Skip to content

Commit

Permalink
Rename USB interrupt handler.
Browse files Browse the repository at this point in the history
The name 'main' is just confusing.
  • Loading branch information
jonathanpallant committed Oct 4, 2024
1 parent 6dfee53 commit 646d12a
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion exercise-book/src/nrf52-usb-usb-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `USBD` peripheral on the nRF52840 contains a series of registers, called `EV

✅ Open the [`nrf52-code/usb-app/src/bin/usb-1.rs`][usb_1] file.

In this starter code the `USBD` peripheral is initialized in `init` and a task, named `main`, is bound to the interrupt signal called `USBD`. This task will be called every time a new `USBD` event needs to be handled. The `main` task uses `usbd::next_event()` to check all the event registers; if any event is set (i.e. that event just occurred) then the function returns the event, represented by the `Event` enum, wrapped in the `Some` variant. This `Event` is then passed to the `on_event` function for further processing.
In this starter code the `USBD` peripheral is initialized in `init` and a task, named `handle_usb_interrupt`, is bound to the interrupt signal called `USBD`. This task will be called every time a new `USBD` event needs to be handled. The `handle_usb_interrupt` task uses `usbd::next_event()` to check all the event registers; if any event is set (i.e. that event just occurred) then the function returns the event, represented by the `Event` enum, wrapped in the `Some` variant. This `Event` is then passed to the `on_event` function for further processing.

✅ Connect the USB cable to the port J3 then run the starter code.

Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app-solutions/src/bin/usb-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;

while let Some(event) = usbd::next_event(usbd) {
Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app-solutions/src/bin/usb-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;

while let Some(event) = usbd::next_event(usbd) {
Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app-solutions/src/bin/usb-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd, ep0in])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;
let ep0in = cx.local.ep0in;

Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app-solutions/src/bin/usb-4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd, ep0in, state])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;
let ep0in = cx.local.ep0in;
let state = cx.local.state;
Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app-solutions/src/bin/usb-5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd, ep0in, state])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;
let ep0in = cx.local.ep0in;
let state = cx.local.state;
Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app/src/bin/usb-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;

while let Some(event) = usbd::next_event(usbd) {
Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app/src/bin/usb-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;

while let Some(event) = usbd::next_event(usbd) {
Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app/src/bin/usb-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd, ep0in])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;
let ep0in = cx.local.ep0in;

Expand Down
2 changes: 1 addition & 1 deletion nrf52-code/usb-app/src/bin/usb-4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod app {
}

#[task(binds = USBD, local = [usbd, ep0in, state])]
fn main(cx: main::Context) {
fn handle_usb_interrupt(cx: handle_usb_interrupt::Context) {
let usbd = cx.local.usbd;
let ep0in = cx.local.ep0in;
let state = cx.local.state;
Expand Down

0 comments on commit 646d12a

Please sign in to comment.