Compare commits
1 Commits
29404fe9ba
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d63fb5d93 |
1
tprais_semestralka1/.gitignore
vendored
1
tprais_semestralka1/.gitignore
vendored
@@ -5,6 +5,7 @@ target/
|
|||||||
.zed/
|
.zed/
|
||||||
.helix/
|
.helix/
|
||||||
.env
|
.env
|
||||||
|
LPS22HB.PDF
|
||||||
|
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ use embassy_net::{Runner, StackResources};
|
|||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_sync::signal::Signal;
|
use embassy_sync::signal::Signal;
|
||||||
use embassy_time::{Duration, Instant, Timer};
|
use embassy_time::{Duration, Instant, Timer};
|
||||||
|
use esp_hal::{
|
||||||
|
i2c::master::{Config, I2c},
|
||||||
|
Async,
|
||||||
|
};
|
||||||
use projekt_final::mqtt::client::{mqtt_publish, mqtt_task};
|
use projekt_final::mqtt::client::{mqtt_publish, mqtt_task};
|
||||||
|
|
||||||
use esp_alloc as _;
|
use esp_alloc as _;
|
||||||
@@ -59,14 +63,26 @@ esp_bootloader_esp_idf::esp_app_desc!();
|
|||||||
#[esp_hal_embassy::main]
|
#[esp_hal_embassy::main]
|
||||||
async fn main(spawner: Spawner) -> ! {
|
async fn main(spawner: Spawner) -> ! {
|
||||||
esp_println::logger::init_logger_from_env();
|
esp_println::logger::init_logger_from_env();
|
||||||
info!("===============================");
|
|
||||||
info!("ESP32 IoT Firmware Starting");
|
info!("ESP32 IoT Firmware Starting");
|
||||||
info!("===============================");
|
|
||||||
|
|
||||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||||
let peripherals = esp_hal::init(config);
|
let peripherals = esp_hal::init(config);
|
||||||
esp_alloc::heap_allocator!(size: 72 * 1024);
|
esp_alloc::heap_allocator!(size: 72 * 1024);
|
||||||
|
|
||||||
|
let i2c_config = Config::default().with_frequency(esp_hal::time::Rate::from_khz(400));
|
||||||
|
info!("Init I2C");
|
||||||
|
let mut i2c = I2c::new(peripherals.I2C0, i2c_config)
|
||||||
|
.expect("Failed to init i2c")
|
||||||
|
.with_sda(peripherals.GPIO21)
|
||||||
|
.with_scl(peripherals.GPIO22)
|
||||||
|
.into_async();
|
||||||
|
|
||||||
|
let mut buffer = [0u8; 1];
|
||||||
|
let SAD = 0x5C;
|
||||||
|
let SUB = &[0x0F];
|
||||||
|
i2c.write_read_async(SAD, SUB, &mut buffer).await.unwrap();
|
||||||
|
info!("WHO_AM_I: {:x}", buffer[0]);
|
||||||
|
|
||||||
info!("Initializing WiFi...");
|
info!("Initializing WiFi...");
|
||||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||||
let mut rng = Rng::new(peripherals.RNG);
|
let mut rng = Rng::new(peripherals.RNG);
|
||||||
|
|||||||
Reference in New Issue
Block a user