Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
Save temps issue fix, use modify instead of write for gpio set and cl…
Browse files Browse the repository at this point in the history
…ear registers
  • Loading branch information
MabezDev committed Jan 12, 2020
1 parent 02723bf commit b5f6531
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .cargo/config
Expand Up @@ -8,6 +8,6 @@ rustflags = [
"-C", "link-arg=-nostartfiles",
"-C", "debuginfo=0", # not 2
"-C", "link-arg=-Wl,-Tlink.x",
"-C", "save-temps"
"--emit", "llvm-bc,link", # see: https://github.com/MabezDev/xtensa-rust-quickstart/issues/1#issuecomment-481119695
]
target = "xtensa-esp32-none-elf"
8 changes: 4 additions & 4 deletions src/main.rs
Expand Up @@ -70,16 +70,16 @@ fn disable_timg_wdts(timg0: &mut esp32::TIMG0, timg1: &mut esp32::TIMG1) {

pub fn set_led(reg: &mut esp32::GPIO, idx: u32, val: bool) {
if val {
reg.out_w1ts.write(|w| unsafe { w.bits(0x1 << idx) });
reg.out_w1ts.modify(|_, w| unsafe { w.bits(0x1 << idx) });
} else {
reg.out_w1tc.write(|w| unsafe { w.bits(0x1 << idx) });
reg.out_w1tc.modify(|_, w| unsafe { w.bits(0x1 << idx) });
}
}

/// Configure the pin as an output
pub fn configure_pin_as_output(reg: &mut esp32::GPIO, gpio: u32){
reg.enable_w1ts.write(|w| unsafe { w.bits(0x1 << gpio) });
reg.func2_out_sel_cfg.write(|w| unsafe { w.bits(0x100) });
reg.enable_w1ts.modify(|_, w| unsafe { w.bits(0x1 << gpio) });
reg.func2_out_sel_cfg.modify(|_, w| unsafe { w.bits(0x100) });
}

/// rough delay - as a guess divide your cycles by 20 (results will differ on opt level)
Expand Down

0 comments on commit b5f6531

Please sign in to comment.