Browse Source

Minor refactoring to clarify names

Kevin Lee 2 years ago
parent
commit
c06b62a1b9
1 changed files with 14 additions and 13 deletions
  1. 14 13
      Nixie_Firmware_Rust/src/main.rs

+ 14 - 13
Nixie_Firmware_Rust/src/main.rs

@@ -47,7 +47,7 @@ static RTC_INT: Mutex<RefCell<Option<RtcInt>>> = Mutex::new(RefCell::new(None));
 static FAULT_INT: Mutex<RefCell<Option<FaultInt>>> = Mutex::new(RefCell::new(None));
 static FAULT_LED: Mutex<RefCell<Option<FaultLed>>> = Mutex::new(RefCell::new(None));
 static I2C: Mutex<RefCell<Option<I2c1>>> = Mutex::new(RefCell::new(None));
-static FPS_TIMER: Mutex<RefCell<Option<FpsTimer>>> = Mutex::new(RefCell::new(None));
+static REFRESH_TIMER: Mutex<RefCell<Option<FpsTimer>>> = Mutex::new(RefCell::new(None));
 static CYCLE_TIMER: Mutex<RefCell<Option<CycleTimer>>> = Mutex::new(RefCell::new(None));
 static CLOCK: Mutex<RefCell<Clock>> = Mutex::new(RefCell::new(Clock::default()));
 
@@ -177,14 +177,14 @@ fn main() -> ! {
     let mut pwm_enable = gpioa.pa7.into_push_pull_output_with_state(&mut gpioa.moder, &mut gpioa.otyper, State::High);
 
     // Initialize the PCA9685 display refresh timer
-    let fps_timer = Timer::tim2(dp.TIM2, nixie::DISPLAY_REFRESH_FPS.hz(), clocks, &mut rcc.apb1r1);
+    let refresh_timer = Timer::tim2(dp.TIM2, nixie::DISPLAY_REFRESH_FPS.hz(), clocks, &mut rcc.apb1r1);
 
     // Configure NVIC mask to enable interrupt for the display refresh timer
     unsafe { NVIC::unmask(Interrupt::TIM2) };
 
     // Save display refresh timer in static singleton so that interrupt has access to it
     free(|cs| {
-        FPS_TIMER.borrow(cs).replace(Some(fps_timer));
+        REFRESH_TIMER.borrow(cs).replace(Some(refresh_timer));
     });
 
     // Initiaize display cycle timer
@@ -244,6 +244,7 @@ fn set_fault_led(state: State) {
     });
 }
 
+// Trigger the start of a new cycle sequence
 fn trigger_cycle(tube: usize) {
     free(|cs| {
         let mut cycle_timer_ref = CYCLE_TIMER.borrow(cs).borrow_mut();
@@ -264,11 +265,11 @@ fn EXTI9_5() {
     free(|cs| {
         let mut rtc_int_ref = RTC_INT.borrow(cs).borrow_mut();
         let mut i2c_int_ref = I2C.borrow(cs).borrow_mut();
-        let mut fps_timer_ref = FPS_TIMER.borrow(cs).borrow_mut();
+        let mut refresh_timer_ref = REFRESH_TIMER.borrow(cs).borrow_mut();
         let mut clock_ref = CLOCK.borrow(cs).borrow_mut();
         if let Some(ref mut rtc_int) = rtc_int_ref.deref_mut() {
             if let Some(ref mut i2c) = i2c_int_ref.deref_mut() {
-                if let Some(ref mut fps_timer) = fps_timer_ref.deref_mut() {
+                if let Some(ref mut refresh_timer) = refresh_timer_ref.deref_mut() {
                     if rtc_int.check_interrupt() {
                         // Read new time from DS3231
                         let (second, minute, hour) = ds3231::get_time(DS3231_ADDR, i2c);
@@ -282,7 +283,7 @@ fn EXTI9_5() {
                         clock_ref.deref_mut().rtc_tick(second, minute, hour);
 
                         // Start the refresh timer to update the display
-                        fps_timer.listen(Event::TimeOut);
+                        refresh_timer.listen(Event::TimeOut);
                         
                         // Clear the interrupt flag for the timer
                         rtc_int.clear_interrupt_pending_bit();
@@ -312,19 +313,19 @@ fn EXTI3() {
 fn TIM2() {
     free(|cs| {
         let mut i2c_int_ref = I2C.borrow(cs).borrow_mut();
-        let mut fps_timer_ref = FPS_TIMER.borrow(cs).borrow_mut();
+        let mut refresh_timer_ref = REFRESH_TIMER.borrow(cs).borrow_mut();
         let mut clock_ref = CLOCK.borrow(cs).borrow_mut();
         if let Some(ref mut i2c) = i2c_int_ref.deref_mut() {
-            if let Some(ref mut fps_timer) = fps_timer_ref.deref_mut() {
+            if let Some(ref mut refresh_timer) = refresh_timer_ref.deref_mut() {
                 // Compute updates for non-static digits
                 let updated = clock_ref.deref_mut().fps_tick();
 
                 // Write new values if values have changed, otherwise disable the refresh timer
                 if updated {
                     clock_ref.deref_mut().write_i2c(i2c);
-                    fps_timer.clear_interrupt(Event::TimeOut);
+                    refresh_timer.clear_interrupt(Event::TimeOut);
                 } else {
-                    fps_timer.unlisten(Event::TimeOut);
+                    refresh_timer.unlisten(Event::TimeOut);
                 }
             }
         }
@@ -336,10 +337,10 @@ fn TIM2() {
 fn TIM7() {
     free(|cs| {
         let mut cycle_timer_ref = CYCLE_TIMER.borrow(cs).borrow_mut();
-        let mut fps_timer_ref = FPS_TIMER.borrow(cs).borrow_mut();
+        let mut refresh_timer_ref = REFRESH_TIMER.borrow(cs).borrow_mut();
         let mut clock_ref = CLOCK.borrow(cs).borrow_mut();
         if let Some(ref mut cycle_timer) = cycle_timer_ref.deref_mut() {
-            if let Some(ref mut fps_timer) = fps_timer_ref.deref_mut() {
+            if let Some(ref mut refresh_timer) = refresh_timer_ref.deref_mut() {
                 // Trigger the next step in the cycling sequence
                 if clock_ref.deref_mut().cycle_tick() {
                     cycle_timer.unlisten(Event::TimeOut);
@@ -348,7 +349,7 @@ fn TIM7() {
                 }
 
                 // Start the refresh timer to update the display
-                fps_timer.listen(Event::TimeOut);
+                refresh_timer.listen(Event::TimeOut);
             }
         }
     });