Skip to content

Commit

Permalink
drv/stm32h7-i2c-server: 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 c161c66 commit 1e21045
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions demo-stm32h7/app-h743.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ start = true
33 = 0b0000_0010 # I2C2 event
34 = 0b0000_0010 # I2C2 error

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

#
# SPI interrupts:
# spi1 = 35
Expand Down
4 changes: 4 additions & 0 deletions demo-stm32h7/app-h7b3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ start = true
95 = 0b0000_1000 # I2C4 event
96 = 0b0000_1000 # I2C4 error

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

[tasks.user_leds]
path = "../drv/user-leds"
name = "drv-user-leds"
Expand Down
14 changes: 7 additions & 7 deletions drv/stm32h7-i2c-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use fixedmap::*;
use ringbuf::*;
use userlib::*;

declare_task!(RCC, rcc_driver);
declare_task!(GPIO, gpio_driver);
task_slot!(RCC, rcc_driver);
task_slot!(GPIO, gpio_driver);

fn lookup_controller<'a>(
controllers: &'a [I2cController],
Expand Down Expand Up @@ -160,7 +160,7 @@ fn reset_if_needed(
}
}

let gpio = get_task_id(GPIO);
let gpio = GPIO.get_task_id();
let gpio = Gpio::from(gpio);

// First, bounce our I2C controller
Expand Down Expand Up @@ -601,7 +601,7 @@ fn main() -> ! {
}

fn turn_on_i2c(controllers: &[I2cController]) {
let rcc_driver = Rcc::from(get_task_id(RCC));
let rcc_driver = Rcc::from(RCC.get_task_id());

for controller in controllers {
controller.enable(&rcc_driver);
Expand Down Expand Up @@ -629,7 +629,7 @@ fn configure_port(
return;
}

let gpio = get_task_id(GPIO);
let gpio = GPIO.get_task_id();
let gpio = Gpio::from(gpio);

//
Expand Down Expand Up @@ -668,7 +668,7 @@ fn configure_pins(
pins: &[I2cPin],
map: &mut PortMap,
) {
let gpio = get_task_id(GPIO);
let gpio = GPIO.get_task_id();
let gpio = Gpio::from(gpio);

for pin in pins {
Expand Down Expand Up @@ -706,7 +706,7 @@ fn configure_muxes(
map: &mut PortMap,
ctrl: &I2cControl,
) {
let gpio = get_task_id(GPIO);
let gpio = GPIO.get_task_id();
let gpio = Gpio::from(gpio);

for mux in muxes {
Expand Down
4 changes: 4 additions & 0 deletions gemini-bu/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ start = true
95 = 0b0000_1000 # I2C4 event
96 = 0b0000_1000 # I2C4 error

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

[tasks.spd]
path = "../task-spd"
name = "task-spd"
Expand Down
4 changes: 4 additions & 0 deletions gimlet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ start = true
95 = 0b0000_1000 # I2C4 event
96 = 0b0000_1000 # I2C4 error

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

[tasks.spd]
path = "../task-spd"
name = "task-spd"
Expand Down
4 changes: 4 additions & 0 deletions gimletlet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ start = true
95 = 0b0000_1000 # I2C4 event
96 = 0b0000_1000 # I2C4 error

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

[tasks.spd]
path = "../task-spd"
name = "task-spd"
Expand Down

0 comments on commit 1e21045

Please sign in to comment.