File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822 Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -228,9 +228,12 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
228
228
* additional 32 bits. RTC_UNITS_TO_MICROSECONDS() converts this into
229
229
* microsecond units (in 64-bits).
230
230
*/
231
- const uint64_t currentTime64 = RTC_UNITS_TO_MICROSECONDS (rtc1_getCounter64 ());
232
- const uint64_t timestamp64 = currentTime64 + (timestamp_t )(timestamp - (timestamp_t )currentTime64 );
233
- uint32_t newCallbackTime = MICROSECONDS_TO_RTC_UNITS (timestamp64 );
231
+ const uint64_t currentTime64 = RTC_UNITS_TO_MICROSECONDS (rtc1_getCounter64 ());
232
+ uint64_t timestamp64 = (currentTime64 & ~(uint64_t )0xFFFFFFFFULL ) + timestamp ;
233
+ if (((uint32_t )currentTime64 > 0x80000000 ) && (timestamp < 0x80000000 )) {
234
+ timestamp64 += (uint64_t )0x100000000ULL ;
235
+ }
236
+ uint32_t newCallbackTime = MICROSECONDS_TO_RTC_UNITS (timestamp64 );
234
237
235
238
/* Check for repeat setup of an existing callback. This is actually not
236
239
* important; the following code should work even without this check. */
You can’t perform that action at this time.
0 commit comments