Skip to content

Commit

Permalink
Implement NFC reader
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Aug 22, 2024
1 parent 67af0d8 commit 96018b5
Show file tree
Hide file tree
Showing 5 changed files with 510 additions and 12 deletions.
12 changes: 12 additions & 0 deletions firmware/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions firmware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ esp-hal-embassy = { version = "0.2", features = ["esp32c3", "log"] }
esp-println = { version = "0.10", features = ["esp32c3", "log"] }
esp-wifi = { version = "0.7", features = ["esp32c3", "async", "log", "phy-enable-usb", "wifi"] }
log = { version = "0.4", features = ["release_max_level_info"] }
pn532 = "0.4"
static_cell = "2.1"
u8g2-fonts = "0.4"

Expand Down
20 changes: 19 additions & 1 deletion firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@
//! 1 2 3 4 5 6 7 8 9
//! nc Col2 Row1 Col1 Row4 Col3 Row3 Row2 nc
//!
//! Pinout PN532 NFC Module
//!
//! SCK MISO MOSI SS VCC GND IRQ RSTO
//! 1 2 3 4 5 6 7 8
//! GND - 1 |
//! VCC - 2 |
//! SDA - 3 |
//! SCL - 4 |
//!

#![no_std]
#![no_main]

mod display;
mod keypad;
mod nfc;
mod screen;
mod ui;
mod wifi;
Expand Down Expand Up @@ -144,6 +154,14 @@ async fn main(_spawner: Spawner) {
],
);

// Initialize NFC reader
let nfc_irq = AnyInput::new(io.pins.gpio20, Pull::Up);
let nfc = match nfc::Nfc::new(RefCellDevice::new(&i2c), nfc_irq).await {
Ok(nfc) => nfc,
// Panic on failure since an initialization error indicates a serious error
Err(err) => panic!("NFC reader initialization failed: {:?}", err),
};

// Initialize Wifi
let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks, None);
let wifi_timer = PeriodicTimer::new(timg0.timer0.into());
Expand All @@ -162,7 +180,7 @@ async fn main(_spawner: Spawner) {
};

// Create UI
let mut ui = ui::Ui::new(display, keypad);
let mut ui = ui::Ui::new(display, keypad, nfc);
let _ = ui.show_splash_screen().await;

loop {
Expand Down
Loading

0 comments on commit 96018b5

Please sign in to comment.