fw-rust: Start to use the avr-eeprom crate
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Start to use the avr-eeprom crate to handle values residing inside the
EEPROM.
This commit is contained in:
finga 2022-03-08 19:05:40 +01:00
parent b34b2810db
commit 8b9d21a012
3 changed files with 14 additions and 9 deletions

View file

@ -9,6 +9,7 @@ use atmega_hal::{
Peripherals,
};
use avr_device::interrupt;
use avr_eeprom::eeprom;
use embedded_hal::{
blocking::delay::DelayMs,
spi::{FullDuplex, Mode, Phase, Polarity},
@ -16,13 +17,10 @@ use embedded_hal::{
use nb::block;
use panic_halt as _;
#[used]
#[link_section = ".eeprom"]
static CONTRAST: u8 = 8;
#[used]
#[link_section = ".eeprom"]
static BACKLIGHT: u8 = 1;
eeprom! {
static eeprom CONTRAST: u8 = 8;
static eeprom BACKLIGHT: u8 = 1;
}
// TODO: Use https://github.com/rust-lang/rust/issues/85077 when stabilized
static SACRED_CHAO: [[u8; 40]; 5] = [
@ -82,7 +80,7 @@ fn main() -> ! {
// Write address into eeprom address register
eeprom
.eear
.write(|w| unsafe { w.bits(&CONTRAST as *const u8 as u16) });
.write(|w| unsafe { w.bits(CONTRAST.ptr() as u16) });
// Start to read from eeprom by setting EERE
eeprom.eecr.write(|w| w.eere().set_bit());
// Return data from eeprom data register
@ -95,7 +93,7 @@ fn main() -> ! {
// Write address into eeprom address register
eeprom
.eear
.write(|w| unsafe { w.bits(&BACKLIGHT as *const u8 as u16) });
.write(|w| unsafe { w.bits(BACKLIGHT.ptr() as u16) });
// Start to read from eeprom by setting EERE
eeprom.eecr.write(|w| w.eere().set_bit());
// Return data from eeprom data register