337: Examples: Clarify extern section r=korken89 a=dbrgn

Some beginners are confused about the "extern" section, so I added an explanation comment to all examples.

![image](https://user-images.githubusercontent.com/105168/85903840-9ad2a780-b807-11ea-943d-3f37b814c23f.png)

Furthermore, using the UARTx interrupts when UART is actually being used in the same example may be confusing, so I changed them all to SSI0/QEI0.

Co-authored-by: Danilo Bargen <mail@dbrgn.ch>
This commit is contained in:
bors[bot] 2020-06-30 20:16:46 +00:00 committed by GitHub
commit bfb498e722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 65 additions and 22 deletions

View file

@ -45,7 +45,10 @@ const APP: () = {
cx.spawn.foo().unwrap(); cx.spawn.foo().unwrap();
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART1(); fn SSI0();
} }
}; };

View file

@ -38,8 +38,10 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS); debug::exit(debug::EXIT_SUCCESS);
} }
// Interrupt handlers used to dispatch software tasks // RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART1(); fn SSI0();
} }
}; };

View file

@ -57,8 +57,11 @@ const APP: () = {
.ok(); .ok();
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
fn UART1(); fn QEI0();
} }
}; };

View file

@ -43,7 +43,10 @@ const APP: () = {
c.spawn.foo().unwrap(); c.spawn.foo().unwrap();
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
} }
}; };

View file

@ -53,8 +53,11 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS); debug::exit(debug::EXIT_SUCCESS);
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
fn UART1(); fn QEI0();
} }
}; };

View file

@ -36,7 +36,10 @@ const APP: () = {
let _: &NotSync = c.resources.shared; let _: &NotSync = c.resources.shared;
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
} }
}; };

View file

@ -29,7 +29,10 @@ const APP: () = {
cx.schedule.foo(cx.scheduled + PERIOD.cycles()).unwrap(); cx.schedule.foo(cx.scheduled + PERIOD.cycles()).unwrap();
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
} }
}; };

View file

@ -59,8 +59,11 @@ const APP: () = {
// drop(x); // drop(x);
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
fn UART1(); fn QEI0();
} }
}; };

View file

@ -44,7 +44,10 @@ const APP: () = {
hprintln!("bar @ {:?}", Instant::now()).unwrap(); hprintln!("bar @ {:?}", Instant::now()).unwrap();
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
} }
}; };

View file

@ -43,8 +43,11 @@ const APP: () = {
#[task] #[task]
fn quux(_: quux::Context) {} fn quux(_: quux::Context) {}
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
fn UART1(); fn QEI0();
} }
}; };

View file

@ -53,7 +53,10 @@ const APP: () = {
#[task] #[task]
fn baz(_: baz::Context, _x: u32, _y: u32) {} fn baz(_: baz::Context, _x: u32, _y: u32) {}
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART1(); fn SSI0();
} }
}; };

View file

@ -52,7 +52,10 @@ const APP: () = {
#[task] #[task]
fn baz(_: baz::Context, _x: u32, _y: u32) {} fn baz(_: baz::Context, _x: u32, _y: u32) {}
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART1(); fn SSI0();
} }
}; };

View file

@ -18,7 +18,10 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS); debug::exit(debug::EXIT_SUCCESS);
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
} }
}; };

View file

@ -45,9 +45,11 @@ const APP: () = {
hprintln!("baz").unwrap(); hprintln!("baz").unwrap();
} }
// Interrupt handlers used to dispatch software tasks // RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART0(); fn SSI0();
fn UART1(); fn QEI0();
} }
}; };

View file

@ -52,7 +52,10 @@ const APP: () = {
let _: foo::Spawn = cx.spawn; let _: foo::Spawn = cx.spawn;
} }
// RTIC requires that unused interrupts are declared in an extern block when
// using software tasks; these free interrupts will be used to dispatch the
// software tasks.
extern "C" { extern "C" {
fn UART1(); fn SSI0();
} }
}; };