Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Enable https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames with a threshold of 1024 (#241)

### Changed

### Fixed
Expand Down
1 change: 1 addition & 0 deletions template/.clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stack-size-threshold = 1024
20 changes: 13 additions & 7 deletions template/src/bin/async_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
holding buffers for the duration of a data transfer."
)]
#![deny(clippy::large_stack_frames)]

use esp_hal::clock::CpuClock;
use esp_hal::timer::timg::TimerGroup;
Expand Down Expand Up @@ -57,6 +58,10 @@ const L2CAP_CHANNELS_MAX: usize = 1;
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();

#[allow(
clippy::large_stack_frames,
reason = "it's not unusual to allocate larger buffers etc. in main"
)]
#[esp_rtos::main]
async fn main(spawner: Spawner) -> ! {
//REPLACE generate-version generate-version
Expand Down Expand Up @@ -88,9 +93,10 @@ async fn main(spawner: Spawner) -> ! {
//IF option("esp32") || option("esp32s2") || option("esp32s3")
esp_rtos::start(timg0.timer0);
//ELSE
let sw_interrupt = esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
let sw_interrupt =
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
//ENDIF
//ENDIF

//IF option("defmt") || option("log")
info!("Embassy initialized!");
Expand All @@ -99,17 +105,17 @@ async fn main(spawner: Spawner) -> ! {
//ENDIF

//IF option("ble-trouble") || option("ble-bleps") || option("wifi")
let radio_init = esp_radio::init()
.expect("Failed to initialize Wi-Fi/BLE controller");
let radio_init = esp_radio::init().expect("Failed to initialize Wi-Fi/BLE controller");
//ENDIF
//IF option("wifi")
let (mut _wifi_controller, _interfaces) = esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
.expect("Failed to initialize Wi-Fi controller");
let (mut _wifi_controller, _interfaces) =
esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
.expect("Failed to initialize Wi-Fi controller");
//ENDIF
//IF option("ble-trouble")
// find more examples https://github.com/embassy-rs/trouble/tree/main/examples/esp32
let transport = BleConnector::new(&radio_init, peripherals.BT, Default::default()).unwrap();
let ble_controller = ExternalController::<_, 20>::new(transport);
let ble_controller = ExternalController::<_, 1>::new(transport);
let mut resources: HostResources<DefaultPacketPool, CONNECTIONS_MAX, L2CAP_CHANNELS_MAX> =
HostResources::new();
let _stack = trouble_host::new(ble_controller, &mut resources);
Expand Down
18 changes: 12 additions & 6 deletions template/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
holding buffers for the duration of a data transfer."
)]
#![deny(clippy::large_stack_frames)]

use esp_hal::{
clock::CpuClock,
Expand Down Expand Up @@ -49,6 +50,10 @@ extern crate alloc;
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();

#[allow(
clippy::large_stack_frames,
reason = "it's not unusual to allocate larger buffers etc. in main"
)]
#[main]
fn main() -> ! {
//REPLACE generate-version generate-version
Expand Down Expand Up @@ -85,15 +90,16 @@ fn main() -> ! {
//IF option("esp32") || option("esp32s2") || option("esp32s3")
esp_rtos::start(timg0.timer0);
//ELSE
let sw_interrupt = esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
let sw_interrupt =
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
//ENDIF
let radio_init = esp_radio::init()
.expect("Failed to initialize Wi-Fi/BLE controller");
//ENDIF
let radio_init = esp_radio::init().expect("Failed to initialize Wi-Fi/BLE controller");
//ENDIF
//IF option("wifi")
let (mut _wifi_controller, _interfaces) = esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
.expect("Failed to initialize Wi-Fi controller");
let (mut _wifi_controller, _interfaces) =
esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default())
.expect("Failed to initialize Wi-Fi controller");
//ENDIF
//IF option("ble-bleps")
let _connector = BleConnector::new(&radio_init, peripherals.BT, Default::default());
Expand Down
Loading