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) {
143
143
}
144
144
COMPLETE_MEMORY_READS ;
145
145
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 ;
147
151
}
148
152
149
153
void TIMER_1_IRQHandler (void ) {
Original file line number Diff line number Diff line change @@ -124,7 +124,9 @@ void board_timerhook(void) {
124
124
125
125
uint64_t port_get_raw_ticks (uint8_t * subticks ) {
126
126
uint64_t count = cxd56_rtc_count ();
127
- * subticks = count % 32 ;
127
+ if (subticks != NULL ) {
128
+ * subticks = count % 32 ;
129
+ }
128
130
129
131
return count / 32 ;
130
132
}
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ uint64_t port_get_raw_ticks(uint8_t *subticks) {
114
114
common_hal_mcu_disable_interrupts ();
115
115
uint64_t raw_tick_snapshot = raw_ticks ;
116
116
common_hal_mcu_enable_interrupts ();
117
+ if (subticks != NULL ) {
118
+ * subticks = 0 ;
119
+ }
117
120
return raw_tick_snapshot ;
118
121
}
119
122
Original file line number Diff line number Diff line change @@ -491,11 +491,11 @@ static volatile bool ticks_enabled;
491
491
static volatile bool _woken_up ;
492
492
493
493
uint64_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 ;
495
495
if (subticks != NULL ) {
496
- * subticks = ( uint8_t )((( microseconds % 1000000 ) % 977 ) / 31 ) ;
496
+ * subticks = all_subticks % 32 ;
497
497
}
498
- return 1024 * ( microseconds / 1000000 ) + ( microseconds % 1000000 ) / 977 ;
498
+ return all_subticks / 32 ;
499
499
}
500
500
501
501
static void _tick_callback (uint alarm_num ) {
You can’t perform that action at this time.
0 commit comments