fw-rust: Handle data residing in the EEPROM
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
4bc3e84bdd
commit
b34b2810db
2 changed files with 46 additions and 2 deletions
|
@ -16,6 +16,14 @@ 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;
|
||||
|
||||
// TODO: Use https://github.com/rust-lang/rust/issues/85077 when stabilized
|
||||
static SACRED_CHAO: [[u8; 40]; 5] = [
|
||||
[
|
||||
|
@ -64,11 +72,35 @@ static ONDERS_ORG: [[u8; 48]; 2] = [
|
|||
#[atmega_hal::entry]
|
||||
fn main() -> ! {
|
||||
interrupt::free(|_cs| {
|
||||
// Get peripherals, pins and delay
|
||||
// Get peripherals, pins, eeprom and delay
|
||||
let dp = Peripherals::take().unwrap();
|
||||
let pins = pins!(dp);
|
||||
let eeprom = dp.EEPROM;
|
||||
let mut delay = Delay::<MHz8>::new();
|
||||
|
||||
// TODO: Wait for completion of previous write
|
||||
// Write address into eeprom address register
|
||||
eeprom
|
||||
.eear
|
||||
.write(|w| unsafe { w.bits(&CONTRAST as *const u8 as u16) });
|
||||
// Start to read from eeprom by setting EERE
|
||||
eeprom.eecr.write(|w| w.eere().set_bit());
|
||||
// Return data from eeprom data register
|
||||
let _contrast = eeprom.eedr.read().bits();
|
||||
|
||||
// TODO: Remove delay when waiting for completion of revious write is done
|
||||
delay.delay_ms(1_u8);
|
||||
|
||||
// TODO: Wait for completion of previous write
|
||||
// Write address into eeprom address register
|
||||
eeprom
|
||||
.eear
|
||||
.write(|w| unsafe { w.bits(&BACKLIGHT as *const u8 as u16) });
|
||||
// Start to read from eeprom by setting EERE
|
||||
eeprom.eecr.write(|w| w.eere().set_bit());
|
||||
// Return data from eeprom data register
|
||||
let _backlight = eeprom.eedr.read().bits();
|
||||
|
||||
// Init display backlight
|
||||
let tc0 = dp.TC0;
|
||||
tc0.tccr0a.write(|w| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue