Skip to content

Commit

Permalink
Fixed issues similar to these found on code review #20
Browse files Browse the repository at this point in the history
  • Loading branch information
andstepan committed May 10, 2024
1 parent 19fadae commit 83c995c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 5 additions & 6 deletions examples/headsail-bsp/src/apb_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
*/
use crate::{mmap::TIMER0_ADDR, read_u32, write_u32};

extern crate bit_field;
use bit_field::BitField;

const TIMER0_COUNTER_REG_OFFSET: usize = 0x0;
const TIMER0_CTRL_REG_OFFSET: usize = 0x4;
const TIMER0_CMP_REG_OFFSET: usize = 0x8;
const TIMER0_ENABLE_BIT: u32 = 0b0;
const TIMER0_ENABLE_BIT: usize = 0b0;

/**
* Enables the timer (starts counting).
Expand All @@ -24,9 +23,9 @@ pub fn timer0_enable() {
// Read register
let mut reg = read_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET);
// Make enable bit 1
reg.set_bit(TIMER0_ENABLE_BIT as usize, true);
reg.set_bit(TIMER0_ENABLE_BIT, true);
// Write register back
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg as u32);
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg);
}

/**
Expand All @@ -37,9 +36,9 @@ pub fn timer0_disable() {
// Read register
let mut reg = read_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET);
// Write 0 to bit 0 but leave all other bits untouched
reg.set_bit(TIMER0_ENABLE_BIT as usize, false);
reg.set_bit(TIMER0_ENABLE_BIT, false);
// Write register back
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg as u32);
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg);
}

/**
Expand Down
4 changes: 0 additions & 4 deletions examples/headsail-bsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

pub mod sprintln;
pub mod uart;
<<<<<<< HEAD
pub mod timer_unit;
=======
pub mod timer {
#[cfg(not(feature = "vp"))]
pub use crate::apb_timer::*;
Expand All @@ -15,7 +12,6 @@ pub mod timer {

mod apb_timer;
mod timer_unit;
>>>>>>> Fixes formatting

#[cfg(feature = "hpc")]
pub use hpc::*;
Expand Down

0 comments on commit 83c995c

Please sign in to comment.