File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,11 @@ uint64_t port_get_raw_ticks(uint8_t *subticks) {
143143 }
144144 COMPLETE_MEMORY_READS ;
145145 uint64_t microseconds = hi << 32 | lo ;
146- return 1024 * (microseconds / 1000000 ) + (microseconds % 1000000 ) / 977 ;
146+ int64_t all_subticks = microseconds * 512 / 15625 ;
147+ if (subticks != NULL ) {
148+ * subticks = all_subticks % 32 ;
149+ }
150+ return all_subticks / 32 ;
147151}
148152
149153void TIMER_1_IRQHandler (void ) {
Original file line number Diff line number Diff line change @@ -124,7 +124,9 @@ void board_timerhook(void) {
124124
125125uint64_t port_get_raw_ticks (uint8_t * subticks ) {
126126 uint64_t count = cxd56_rtc_count ();
127- * subticks = count % 32 ;
127+ if (subticks != NULL ) {
128+ * subticks = count % 32 ;
129+ }
128130
129131 return count / 32 ;
130132}
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ uint64_t port_get_raw_ticks(uint8_t *subticks) {
114114 common_hal_mcu_disable_interrupts ();
115115 uint64_t raw_tick_snapshot = raw_ticks ;
116116 common_hal_mcu_enable_interrupts ();
117+ if (subticks != NULL ) {
118+ * subticks = 0 ;
119+ }
117120 return raw_tick_snapshot ;
118121}
119122
Original file line number Diff line number Diff line change @@ -491,11 +491,11 @@ static volatile bool ticks_enabled;
491491static volatile bool _woken_up ;
492492
493493uint64_t port_get_raw_ticks (uint8_t * subticks ) {
494- uint64_t microseconds = time_us_64 ();
494+ int64_t all_subticks = time_us_64 () * 512 / 15625 ;
495495 if (subticks != NULL ) {
496- * subticks = ( uint8_t )((( microseconds % 1000000 ) % 977 ) / 31 ) ;
496+ * subticks = all_subticks % 32 ;
497497 }
498- return 1024 * ( microseconds / 1000000 ) + ( microseconds % 1000000 ) / 977 ;
498+ return all_subticks / 32 ;
499499}
500500
501501static void _tick_callback (uint alarm_num ) {
You can’t perform that action at this time.
0 commit comments