Skip to content

Commit

Permalink
Remove the timer macro
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Sep 6, 2023
1 parent 7d0e50a commit 653ad34
Show file tree
Hide file tree
Showing 56 changed files with 368 additions and 213 deletions.
10 changes: 7 additions & 3 deletions examples-esp32/examples/access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand Down
16 changes: 12 additions & 4 deletions examples-esp32/examples/async_ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Ble,
timer,
Expand All @@ -154,7 +158,11 @@ fn main() -> ! {

let bluetooth = examples_util::get_bluetooth!(peripherals);

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
Expand Down
10 changes: 7 additions & 3 deletions examples-esp32/examples/ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Ble,
timer,
Expand Down
10 changes: 7 additions & 3 deletions examples-esp32/examples/coex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::WifiBle,
timer,
Expand Down
10 changes: 7 additions & 3 deletions examples-esp32/examples/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand Down
16 changes: 12 additions & 4 deletions examples-esp32/examples/embassy_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand All @@ -59,7 +63,11 @@ fn main() -> ! {
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiMode::Ap).unwrap();

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);

let config = Config {
Expand Down
16 changes: 12 additions & 4 deletions examples-esp32/examples/embassy_dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand All @@ -60,7 +64,11 @@ fn main() -> ! {
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiMode::Sta).unwrap();

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);

let config = Config::dhcpv4(Default::default());
Expand Down
16 changes: 12 additions & 4 deletions examples-esp32/examples/embassy_esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand All @@ -87,7 +91,11 @@ fn main() -> ! {
let esp_now = esp_wifi::esp_now::EspNow::new(&init, wifi).unwrap();
println!("esp-now version {}", esp_now.get_version().unwrap());

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
Expand Down
10 changes: 7 additions & 3 deletions examples-esp32/examples/esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand Down
10 changes: 7 additions & 3 deletions examples-esp32/examples/static_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.DPORT.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = esp32_hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand Down
5 changes: 2 additions & 3 deletions examples-esp32c2/examples/access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use esp_wifi::wifi::WifiMode;
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::{peripherals::Peripherals, prelude::*};
use hal::{systimer::SystemTimer, Rng};

use smoltcp::iface::SocketStorage;

Expand All @@ -30,10 +30,9 @@ fn main() -> ! {
let peripherals = Peripherals::take();

let system = peripherals.SYSTEM.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand Down
11 changes: 7 additions & 4 deletions examples-esp32c2/examples/async_ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,10 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.SYSTEM.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.SYSTEM.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
EspWifiInitFor::Ble,
timer,
Expand All @@ -154,7 +153,11 @@ fn main() -> ! {

let bluetooth = examples_util::get_bluetooth!(peripherals);

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
Expand Down
5 changes: 2 additions & 3 deletions examples-esp32c2/examples/ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use esp_backtrace as _;
use esp_println::println;
use esp_wifi::{ble::controller::BleConnector, initialize, EspWifiInitFor};
use examples_util::hal;
use hal::{clock::ClockControl, peripherals::*, prelude::*, Rng, IO};
use hal::{clock::ClockControl, peripherals::*, prelude::*, systimer::SystemTimer, Rng, IO};

#[entry]
fn main() -> ! {
Expand All @@ -22,10 +22,9 @@ fn main() -> ! {
let peripherals = Peripherals::take();

let system = peripherals.SYSTEM.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
EspWifiInitFor::Ble,
timer,
Expand Down
5 changes: 2 additions & 3 deletions examples-esp32c2/examples/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use esp_wifi::wifi::{WifiError, WifiMode};
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::{peripherals::Peripherals, prelude::*};
use hal::{systimer::SystemTimer, Rng};
use smoltcp::iface::SocketStorage;
use smoltcp::wire::IpAddress;
use smoltcp::wire::Ipv4Address;
Expand All @@ -32,10 +32,9 @@ fn main() -> ! {
let peripherals = Peripherals::take();

let system = peripherals.SYSTEM.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand Down
13 changes: 8 additions & 5 deletions examples-esp32c2/examples/embassy_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use esp_println::{print, println};
use esp_wifi::wifi::{WifiController, WifiDevice, WifiEvent, WifiMode, WifiState};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};
use hal::{systimer::SystemTimer, Rng};

macro_rules! singleton {
($val:expr) => {{
Expand All @@ -42,11 +42,10 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = peripherals.SYSTEM.split();
let mut peripheral_clock_control = system.peripheral_clock_control;
let mut system = peripherals.SYSTEM.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand All @@ -60,7 +59,11 @@ fn main() -> ! {
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiMode::Ap).unwrap();

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);

let config = Config {
Expand Down
Loading

0 comments on commit 653ad34

Please sign in to comment.