initial commit
This commit is contained in:
commit
20fa0560bb
12 changed files with 1361 additions and 0 deletions
28
src/main.rs
Normal file
28
src/main.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_nrf::{
|
||||
bind_interrupts, peripherals,
|
||||
twim::{self, Twim},
|
||||
};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 => twim::InterruptHandler<peripherals::TWISPI0>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
|
||||
let config = twim::Config::default();
|
||||
let mut i2c = Twim::new(p.TWISPI0, Irqs, p.P0_03, p.P0_04, config);
|
||||
|
||||
for addr in 1..=u8::MAX {
|
||||
if i2c.read(addr, &mut [0]).await.is_ok() {
|
||||
info!("i2c device at 0x{:02X}", addr)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue