File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -21,18 +21,25 @@ static struct k_spinlock lock;
2121
2222uint8_t map_prescaler_to_bits (uint32_t val )
2323{
24+ uint8_t ret_val ;
2425 switch (val ) {
2526 case 1 :
26- return 0b00 ;
27+ ret_val = 0b00 ;
28+ break ;
2729 case 8 :
28- return 0b01 ;
30+ ret_val = 0b01 ;
31+ break ;
2932 case 64 :
30- return 0b10 ;
33+ ret_val = 0b10 ;
34+ break ;
3135 case 128 :
32- return 0b11 ;
36+ ret_val = 0b11 ;
37+ break ;
3338 default :
34- return 0b00 ;
39+ ret_val = 0b00 ;
40+ break ;
3541 }
42+ return ret_val ;
3643}
3744
3845static void configure_timer1 (void )
@@ -78,7 +85,9 @@ uint32_t sys_clock_elapsed(void)
7885 Since timer1 counter always starts from 0 when the sys_clock_announce
7986 Call is made, the ticks elapsed is current timer1 count divided by
8087 Number of cycles per tick */
81- ticks_elapsed = (uint32_t )TMR1 / (uint32_t )TIMER1_CYCLES_PER_TICK ;
88+ ticks_elapsed = (uint32_t )TMR1 < (uint32_t )TIMER1_CYCLES_PER_TICK
89+ ? 0
90+ : (uint32_t )TMR1 / (uint32_t )TIMER1_CYCLES_PER_TICK ;
8291 k_spin_unlock (& lock , key );
8392 } while (0 );
8493
Original file line number Diff line number Diff line change 6262 timer1: timer@1E00 {
6363 compatible = "microchip,dspic33-timer";
6464 reg = <0x1E00 0xC>;
65- clock-frequency = <8000000 >;
65+ clock-frequency = <4000000 >;
6666 prescalar = <8>;
6767 interrupt-parent = <&intc0>;
6868 interrupts = <48 1>;
You can’t perform that action at this time.
0 commit comments