Skip to content

Commit

Permalink
Added commentary on pulp_apb_timer
Browse files Browse the repository at this point in the history
  • Loading branch information
andstepan committed May 7, 2024
1 parent a90dc93 commit ab76548
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/headsail-bsp/src/apb_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const TIMER0_CTRL_REG_OFFSET: usize = 0x4;
const TIMER0_CMP_REG_OFFSET: usize = 0x8;
const TIMER0_ENABLE_BIT: u32 = 0b0;

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

/**
* Disables the timer (stops counting).
*/
#[inline]
pub fn timer0_disable() {
// Read register
Expand All @@ -36,8 +42,10 @@ pub fn timer0_disable() {
write_u32(TIMER0_ADDR + TIMER0_CTRL_REG_OFFSET, reg as u32);
}

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

0 comments on commit ab76548

Please sign in to comment.