Skip to content

Commit e3febf4

Browse files
Rename timers to physical_timer and virtual_timer.
More readable than pgt and vgt.
1 parent d484f97 commit e3febf4

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

examples/mps3-an536/src/bin/generic_timer.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ fn main() -> ! {
2525

2626
let delay_ticks = cntfrq / 2;
2727

28-
let pgt_ref: &mut dyn GenericTimer = &mut board.pgt;
29-
let vgt_ref: &mut dyn GenericTimer = &mut board.vgt;
28+
let physical_timer_ref: &mut dyn GenericTimer = &mut board.physical_timer;
29+
let virtual_timer_ref: &mut dyn GenericTimer = &mut board.virtual_timer;
3030

31-
for (timer, name) in [(pgt_ref, "physical"), (vgt_ref, "virtual")] {
31+
for (timer, name) in [
32+
(physical_timer_ref, "physical"),
33+
(virtual_timer_ref, "virtual"),
34+
] {
3235
println!("Using {} timer ************************", name);
3336

3437
println!("Print five, every 100ms...");

examples/mps3-an536/src/bin/generic_timer_irq.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ fn main() -> ! {
3737
.unwrap();
3838

3939
// Setup virtual timer
40-
board.vgt.enable(true);
41-
board.vgt.interrupt_mask(false);
42-
board.vgt.counter_compare_set(
40+
board.virtual_timer.enable(true);
41+
board.virtual_timer.interrupt_mask(false);
42+
board.virtual_timer.counter_compare_set(
4343
board
44-
.vgt
44+
.virtual_timer
4545
.counter()
46-
.wrapping_add(board.vgt.frequency_hz() as u64 / 5),
46+
.wrapping_add(board.virtual_timer.frequency_hz() as u64 / 5),
4747
);
4848

4949
println!("Enabling interrupts...");
@@ -88,11 +88,12 @@ fn irq_handler() {
8888
/// Run when the timer IRQ fires
8989
fn handle_timer_irq() {
9090
// SAFETY: We drop en other time handle in main, this is the only active handle.
91-
let mut vgt = unsafe { El1VirtualTimer::new() };
91+
let mut virtual_timer = unsafe { El1VirtualTimer::new() };
9292
// trigger a timer in 0.2 seconds
93-
vgt.counter_compare_set(
94-
vgt.counter_compare()
95-
.wrapping_add(vgt.frequency_hz() as u64 / 5),
93+
virtual_timer.counter_compare_set(
94+
virtual_timer
95+
.counter_compare()
96+
.wrapping_add(virtual_timer.frequency_hz() as u64 / 5),
9697
);
9798

9899
println!(" - Timer fired, resetting");

examples/mps3-an536/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ impl InterruptHandler {
107107
}
108108
}
109109

110-
/// Represents all the hardware we support in our MPS3-AN536 system
110+
/// Represents all the hardware we support in our MPS3-AN536 system
111111
pub struct Board {
112112
/// The Arm Generic Interrupt Controller (v3)
113113
#[cfg(feature = "gic")]
114114
pub gic: arm_gic::gicv3::GicV3<'static>,
115115
/// The Arm Virtual Generic Timer
116-
pub vgt: cortex_ar::generic_timer::El1VirtualTimer,
116+
pub virtual_timer: cortex_ar::generic_timer::El1VirtualTimer,
117117
/// The Arm Physical Generic Timer
118-
pub pgt: cortex_ar::generic_timer::El1PhysicalTimer,
118+
pub physical_timer: cortex_ar::generic_timer::El1PhysicalTimer,
119119
}
120120

121121
impl Board {
@@ -136,10 +136,10 @@ impl Board {
136136
gic: unsafe { make_gic() },
137137
// SAFETY: This is the first and only time we create the virtual timer instance
138138
// as guaranteed by the atomic flag check above, ensuring exclusive access.
139-
vgt: unsafe { cortex_ar::generic_timer::El1VirtualTimer::new() },
139+
virtual_timer: unsafe { cortex_ar::generic_timer::El1VirtualTimer::new() },
140140
// SAFETY: This is the first and only time we create the physical timer instance
141141
// as guaranteed by the atomic flag check above, ensuring exclusive access.
142-
pgt: unsafe { cortex_ar::generic_timer::El1PhysicalTimer::new() },
142+
physical_timer: unsafe { cortex_ar::generic_timer::El1PhysicalTimer::new() },
143143
})
144144
} else {
145145
None

0 commit comments

Comments
 (0)