Skip to content

Commit

Permalink
Added commentary on timer_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
andstepan committed May 7, 2024
1 parent 5dacda8 commit 3444a2a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/headsail-bsp/src/timer_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const TIMER0_CTRL_REG_OFFSET: usize = 0x0;
const TIMER0_COUNTER_REG_OFFSET: usize = 0x8;
const TIMER0_ENABLE_BIT: usize = 0b0;

/**
* Enables the timer (starts counting).
*/
#[inline]
pub fn timer0_enable() {
// Read register
Expand All @@ -25,6 +28,9 @@ pub fn timer0_enable() {
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg);
}

/**
* Disables the timer (stops counting).
*/
#[inline]
pub fn timer0_disable() {
// Read register
Expand All @@ -35,6 +41,9 @@ pub fn timer0_disable() {
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg);
}

/**
* Returns the timer counter (tick value).
*/
#[inline]
pub fn timer0_get_count() -> u32 {
return read_u32(TIMER0_ADDR + TIMER0_COUNTER_REG_OFFSET);
Expand Down

0 comments on commit 3444a2a

Please sign in to comment.