Skip to content

Commit

Permalink
drv/lpc55-rng: convert to task_slot!
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-shift committed Oct 19, 2021
1 parent e4bc27f commit 8701387
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
13 changes: 4 additions & 9 deletions drv/lpc55-i2c/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ use drv_lpc55_syscon_api::{Peripheral, Syscon};
use lpc55_pac as device;
use userlib::*;

declare_task!(SYSCON, syscon_driver);

#[cfg(not(feature = "standalone"))]
const GPIO: Task = Task::gpio_driver;

#[cfg(feature = "standalone")]
const GPIO: Task = Task::anonymous;
task_slot!(SYSCON, syscon_driver);
task_slot!(GPIO, gpio_driver);

#[derive(FromPrimitive)]
enum Op {
Expand Down Expand Up @@ -57,7 +52,7 @@ struct Transmit {

#[export_name = "main"]
fn main() -> ! {
let syscon = Syscon::from(get_task_id(SYSCON));
let syscon = Syscon::from(SYSCON.get_task_id());

// Turn the actual peripheral on so that we can interact with it.
turn_on_flexcomm(&syscon);
Expand Down Expand Up @@ -149,7 +144,7 @@ fn muck_with_gpios(syscon: &Syscon) {
// The existing peripheral API makes doing this via messages
// maddening so just muck with IOCON manually for now

let gpio_driver = get_task_id(GPIO);
let gpio_driver = GPIO.get_task_id();
let iocon = Gpio::from(gpio_driver);

iocon
Expand Down
4 changes: 2 additions & 2 deletions drv/lpc55-rng/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use zerocopy::AsBytes;

use lpc55_pac as device;

declare_task!(SYSCON, syscon_driver);
task_slot!(SYSCON, syscon_driver);

#[repr(u32)]
enum ResponseCode {
Expand All @@ -45,7 +45,7 @@ impl From<ResponseCode> for u32 {

#[export_name = "main"]
fn main() -> ! {
let syscon = get_task_id(SYSCON);
let syscon = SYSCON.get_task_id();
let syscon = Syscon::from(syscon);

syscon.enable_clock(Peripheral::Rng);
Expand Down
3 changes: 3 additions & 0 deletions gemini-bu-rot/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ requires = {flash = 16384, ram = 1024}
uses = ["rng", "pmc"]
start = true

[tasks.rng_driver.task-slots]
syscon_driver = "syscon_driver"

[tasks.spi0_driver]
path = "../drv/lpc55-spi-server"
name = "drv-lpc55-spi-server"
Expand Down
7 changes: 7 additions & 0 deletions lpc55/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ uses = ["flexcomm4"]
start = true
stacksize = 1000

[tasks.i2c_driver.task-slots]
gpio_driver = "gpio_driver"
syscon_driver = "syscon_driver"

[tasks.rng_driver]
path = "../drv/lpc55-rng"
name = "drv-lpc55-rng"
Expand All @@ -148,6 +152,9 @@ uses = ["rng", "pmc"]
start = true
stacksize = 1000

[tasks.rng_driver.task-slots]
syscon_driver = "syscon_driver"

[tasks.spi_driver]
path = "../drv/lpc55-spi-server"
name = "drv-lpc55-spi-server"
Expand Down

0 comments on commit 8701387

Please sign in to comment.