mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
!nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats
Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed. Drop them to keep the timekeeping math readable and
consistent with the previous sclock_t/time_t cleanup.
In the same spirit, this commit also:
* Normalises the printf-style format specifiers and casts used to
print tv_sec / tv_nsec / tv_usec values across arch/, drivers/,
fs/, sched/ and libs/. The prior code was a mix of
"%d"/"%u"/"%ld"/"%lu"/"%lld"/PRIu32/PRIu64 with matching
(int)/(unsigned long)/(long long)/PRIu* casts; some formats
truncated time_t on 32-bit hosts, others mismatched signedness or
width. Replace all such cases with the portable POSIX-recommended
forms:
- tv_sec (time_t, signed, impl-defined width) -> %jd + (intmax_t)
- tv_nsec (long, signed) -> %ld (no cast)
- tv_usec (suseconds_t / long) -> %ld (no cast)
Add #include <stdint.h> where required.
* Drops a few stale `(FAR const time_t *)&ts.tv_sec` casts and
related `(FAR struct tm *)` / `(const time_t *)` casts in
gmtime_r() / localtime_r() / gmtime() callers; ts.tv_sec is plain
time_t now and the casts only obscured the type.
* Fixes one overflow in fs/procfs/fs_procfscritmon.c where
all_time.tv_sec * 1000000 could overflow on 32-bit time_t before
being multiplied again; cast to uint64_t at the start.
No behavioural change.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
/* convert seconds to 64bit counter value running at 32kHz */
|
/* convert seconds to 64bit counter value running at 32kHz */
|
||||||
|
|
||||||
#define SEC_TO_CNT(sec) ((uint64_t)(((uint64_t)(sec)) << 15))
|
#define SEC_TO_CNT(sec) (((uint64_t)(sec)) << 15)
|
||||||
|
|
||||||
/* convert nano-seconds to 32kHz counter less than 1 second */
|
/* convert nano-seconds to 32kHz counter less than 1 second */
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ static void rtc_dumptime(const struct timespec *tp, const char *msg)
|
|||||||
gmtime_r(&tp->tv_sec, &tm);
|
gmtime_r(&tp->tv_sec, &tm);
|
||||||
|
|
||||||
rtcinfo("%s:\n", msg);
|
rtcinfo("%s:\n", msg);
|
||||||
rtcinfo("RTC %u.%09u\n", tp->tv_sec, tp->tv_nsec);
|
rtcinfo("RTC %jd.%09ld\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
|
||||||
rtcinfo("%4d/%02d/%02d %02d:%02d:%02d\n",
|
rtcinfo("%4d/%02d/%02d %02d:%02d:%02d\n",
|
||||||
tm.tm_year, tm.tm_mon, tm.tm_mday,
|
tm.tm_year, tm.tm_mon, tm.tm_mday,
|
||||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ static int cxd56_getstatus(struct timer_lowerhalf_s *lower,
|
|||||||
|
|
||||||
/* Get the time remaining until the timer expires (in microseconds). */
|
/* Get the time remaining until the timer expires (in microseconds). */
|
||||||
|
|
||||||
remaining = (uint64_t)getreg32(priv->base + CXD56_TIMER_VALUE);
|
remaining = getreg32(priv->base + CXD56_TIMER_VALUE);
|
||||||
status->timeleft =
|
status->timeleft =
|
||||||
(uint32_t)(remaining * 1000000ULL * TIMER_DIVIDER / priv->clkticks);
|
(uint32_t)(remaining * 1000000ULL * TIMER_DIVIDER / priv->clkticks);
|
||||||
|
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ static int cxd56_getstatus(struct watchdog_lowerhalf_s *lower,
|
|||||||
|
|
||||||
/* Get the time remaining until the watchdog expires (in milliseconds) */
|
/* Get the time remaining until the watchdog expires (in milliseconds) */
|
||||||
|
|
||||||
remain = (uint64_t)cxd56_getreg(CXD56_WDT_WDOGVALUE);
|
remain = cxd56_getreg(CXD56_WDT_WDOGVALUE);
|
||||||
status->timeleft = (uint32_t)(remain * 1000 / cxd56_get_cpu_baseclk());
|
status->timeleft = (uint32_t)(remain * 1000 / cxd56_get_cpu_baseclk());
|
||||||
if (cxd56_getreg(CXD56_WDT_WDOGRIS) != WDOGRIS_RAWINT)
|
if (cxd56_getreg(CXD56_WDT_WDOGRIS) != WDOGRIS_RAWINT)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ int up_rtc_gettime(struct timespec *tp)
|
|||||||
tp->tv_nsec = (val % CONFIG_RTC_FREQUENCY) *
|
tp->tv_nsec = (val % CONFIG_RTC_FREQUENCY) *
|
||||||
(NSEC_PER_SEC / CONFIG_RTC_FREQUENCY);
|
(NSEC_PER_SEC / CONFIG_RTC_FREQUENCY);
|
||||||
|
|
||||||
rtcinfo("Get RTC %u.%09u\n", tp->tv_sec, tp->tv_nsec);
|
rtcinfo("Get RTC %jd.%09ld\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -481,8 +481,8 @@ int up_rtc_settime(const struct timespec *tp)
|
|||||||
cnt_carry = val / __CNT_TOP;
|
cnt_carry = val / __CNT_TOP;
|
||||||
cnt = val % __CNT_TOP;
|
cnt = val % __CNT_TOP;
|
||||||
|
|
||||||
rtcinfo("Set RTC %u.%09u carry %u zero %u reg %u\n",
|
rtcinfo("Set RTC %jd.%09ld carry %u zero %u reg %u\n",
|
||||||
tp->tv_sec, tp->tv_nsec, cnt_carry, cnt, cnt_reg);
|
(intmax_t)tp->tv_sec, tp->tv_nsec, cnt_carry, cnt, cnt_reg);
|
||||||
|
|
||||||
putreg32(cnt_carry, __CNT_CARRY_REG);
|
putreg32(cnt_carry, __CNT_CARRY_REG);
|
||||||
putreg32(cnt , __CNT_ZERO_REG);
|
putreg32(cnt , __CNT_ZERO_REG);
|
||||||
|
|||||||
@@ -515,8 +515,7 @@ static int kinetis_rdalarm(struct rtc_lowerhalf_s *lower,
|
|||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
ret = kinetis_rtc_rdalarm(&ts);
|
ret = kinetis_rtc_rdalarm(&ts);
|
||||||
|
|
||||||
localtime_r((const time_t *)&ts.tv_sec,
|
localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time);
|
||||||
(struct tm *)alarminfo->time);
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -727,6 +727,6 @@ int up_rtc_gettime(struct timespec *tp)
|
|||||||
tp->tv_sec = secs;
|
tp->tv_sec = secs;
|
||||||
tp->tv_nsec = nsecs;
|
tp->tv_nsec = nsecs;
|
||||||
|
|
||||||
tmrinfo("Returning tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec);
|
tmrinfo("Returning tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void up_timer_initialize(void)
|
|||||||
* of the timer0 module clock (in the AHB0APB1_BASE domain (2)).
|
* of the timer0 module clock (in the AHB0APB1_BASE domain (2)).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
freq = (uint64_t)lpc31_clkfreq(CLKID_TIMER0PCLK, DOMAINID_AHB0APB1);
|
freq = lpc31_clkfreq(CLKID_TIMER0PCLK, DOMAINID_AHB0APB1);
|
||||||
|
|
||||||
/* If the clock is >1MHz, use pre-dividers */
|
/* If the clock is >1MHz, use pre-dividers */
|
||||||
|
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ static int nrf52_settimeout(struct watchdog_lowerhalf_s *lower,
|
|||||||
|
|
||||||
nrf52_wdt_behaviour_set(priv->mode);
|
nrf52_wdt_behaviour_set(priv->mode);
|
||||||
|
|
||||||
nrf52_wdt_reload_value_set(((uint64_t) timeout * 32768) / 1000);
|
nrf52_wdt_reload_value_set(((uint64_t)timeout * 32768) / 1000);
|
||||||
|
|
||||||
up_enable_irq(NRF52_IRQ_WDT);
|
up_enable_irq(NRF52_IRQ_WDT);
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ bool rp2040_clock_configure(int clk_index,
|
|||||||
* (left shift by 8)
|
* (left shift by 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
div = (uint32_t) (((uint64_t) src_freq << 8) / freq);
|
div = (uint32_t)(((uint64_t)src_freq << 8) / freq);
|
||||||
|
|
||||||
/* If increasing divisor, set divisor before source. Otherwise set source
|
/* If increasing divisor, set divisor before source. Otherwise set source
|
||||||
* before divisor. This avoids a momentary overspeed when e.g. switching
|
* before divisor. This avoids a momentary overspeed when e.g. switching
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ bool rp23xx_clock_configure(int clk_index,
|
|||||||
* (left shift by 16)
|
* (left shift by 16)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
div = (uint32_t) (((uint64_t) src_freq << 16) / freq);
|
div = (uint32_t)(((uint64_t)src_freq << 16) / freq);
|
||||||
|
|
||||||
/* If increasing divisor, set divisor before source. Otherwise set source
|
/* If increasing divisor, set divisor before source. Otherwise set source
|
||||||
* before divisor. This avoids a momentary overspeed when e.g. switching
|
* before divisor. This avoids a momentary overspeed when e.g. switching
|
||||||
|
|||||||
@@ -518,7 +518,7 @@ static unsigned int __div64_32(uint64_t *n, unsigned int base)
|
|||||||
if (high >= base)
|
if (high >= base)
|
||||||
{
|
{
|
||||||
high /= base;
|
high /= base;
|
||||||
res = (uint64_t) high << 32;
|
res = (uint64_t)high << 32;
|
||||||
rem -= (uint64_t)(high * base) << 32;
|
rem -= (uint64_t)(high * base) << 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ static int s32k3xx_wkpuinterrupt(int irq, void *context, void *arg)
|
|||||||
wisr_64 = getreg32(S32K3XX_WKPU_WISR_64);
|
wisr_64 = getreg32(S32K3XX_WKPU_WISR_64);
|
||||||
irer_64 = getreg32(S32K3XX_WKPU_IRER_64);
|
irer_64 = getreg32(S32K3XX_WKPU_IRER_64);
|
||||||
|
|
||||||
eif = (wisr & irer) | (((uint64_t) (wisr_64 & irer_64)) << 32);
|
eif = (wisr & irer) | (((uint64_t)(wisr_64 & irer_64)) << 32);
|
||||||
|
|
||||||
/* Examine each WKPU source */
|
/* Examine each WKPU source */
|
||||||
|
|
||||||
|
|||||||
@@ -276,8 +276,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
|
|||||||
{
|
{
|
||||||
DEBUGASSERT(oneshot && usec);
|
DEBUGASSERT(oneshot && usec);
|
||||||
*usec = (0xffffull * USEC_PER_SEC) /
|
*usec = (0xffffull * USEC_PER_SEC) /
|
||||||
(uint64_t)sam_tc_divfreq(oneshot->tch);
|
sam_tc_divfreq(oneshot->tch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,9 +266,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
|
|||||||
uint64_t regval;
|
uint64_t regval;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
|
|
||||||
/* Was the oneshot already running? */
|
/* Was the oneshot already running? */
|
||||||
@@ -500,8 +499,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
|
|||||||
{
|
{
|
||||||
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
||||||
*usec = (0xffffull * USEC_PER_SEC) /
|
*usec = (0xffffull * USEC_PER_SEC) /
|
||||||
(uint64_t)sam_tc_divfreq(oneshot->tch);
|
sam_tc_divfreq(oneshot->tch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +276,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
|
|||||||
uint64_t regval;
|
uint64_t regval;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
|
|
||||||
/* Was the oneshot already running? */
|
/* Was the oneshot already running? */
|
||||||
@@ -511,8 +510,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ void up_timer_initialize(void)
|
|||||||
/* Convert this to configured clock ticks for use by the OS timer logic */
|
/* Convert this to configured clock ticks for use by the OS timer logic */
|
||||||
|
|
||||||
max_delay /= CONFIG_USEC_PER_TICK;
|
max_delay /= CONFIG_USEC_PER_TICK;
|
||||||
if (max_delay > (uint64_t)UINT32_MAX)
|
if (max_delay > UINT32_MAX)
|
||||||
{
|
{
|
||||||
g_oneshot_maxticks = UINT32_MAX;
|
g_oneshot_maxticks = UINT32_MAX;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,8 +213,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
|
|||||||
{
|
{
|
||||||
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
||||||
*usec = (0xffffull * USEC_PER_SEC) /
|
*usec = (0xffffull * USEC_PER_SEC) /
|
||||||
(uint64_t)sam_tc_divfreq(oneshot->tch);
|
sam_tc_divfreq(oneshot->tch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,8 +211,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
|
|||||||
uint64_t regval;
|
uint64_t regval;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
|
|
||||||
/* Was the oneshot already running? */
|
/* Was the oneshot already running? */
|
||||||
@@ -445,8 +445,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ void up_timer_initialize(void)
|
|||||||
/* Convert this to configured clock ticks for use by the OS timer logic */
|
/* Convert this to configured clock ticks for use by the OS timer logic */
|
||||||
|
|
||||||
max_delay /= CONFIG_USEC_PER_TICK;
|
max_delay /= CONFIG_USEC_PER_TICK;
|
||||||
if (max_delay > (uint64_t)UINT32_MAX)
|
if (max_delay > UINT32_MAX)
|
||||||
{
|
{
|
||||||
g_oneshot_maxticks = UINT32_MAX;
|
g_oneshot_maxticks = UINT32_MAX;
|
||||||
}
|
}
|
||||||
@@ -398,8 +398,7 @@ int up_timer_cancel(struct timespec *ts)
|
|||||||
|
|
||||||
int up_timer_start(const struct timespec *ts)
|
int up_timer_start(const struct timespec *ts)
|
||||||
{
|
{
|
||||||
tmrinfo("ts=(%lu, %lu)\n", (unsigned long)ts->tv_sec,
|
tmrinfo("ts=(%jd, %ld)\n", (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
|
||||||
sam_oneshot_start(&g_tickless.oneshot, &g_tickless.freerun,
|
sam_oneshot_start(&g_tickless.oneshot, &g_tickless.freerun,
|
||||||
sam_oneshot_handler, NULL, ts) :
|
sam_oneshot_handler, NULL, ts) :
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
|
|||||||
{
|
{
|
||||||
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
||||||
*usec = (0xffffull * USEC_PER_SEC) /
|
*usec = (0xffffull * USEC_PER_SEC) /
|
||||||
(uint64_t)sam_tc_divfreq(oneshot->tch);
|
sam_tc_divfreq(oneshot->tch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,9 +277,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
|
|||||||
uint64_t regval;
|
uint64_t regval;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
|
|
||||||
/* Was the oneshot already running? */
|
/* Was the oneshot already running? */
|
||||||
@@ -510,8 +509,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -177,7 +178,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op)
|
|||||||
_info(" fileno:%d\n", (int) bbf->fileno);
|
_info(" fileno:%d\n", (int) bbf->fileno);
|
||||||
_info(" dirty:%d\n", (int) bbf->dirty);
|
_info(" dirty:%d\n", (int) bbf->dirty);
|
||||||
_info(" length:%d\n", (int) bbf->len);
|
_info(" length:%d\n", (int) bbf->len);
|
||||||
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
|
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
|
||||||
|
bbf->lastwrite.tv_nsec);
|
||||||
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
||||||
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3582,7 +3582,7 @@ static int stm32_eth_ptp_adjust(long ppb)
|
|||||||
|
|
||||||
if (ppb != 0)
|
if (ppb != 0)
|
||||||
{
|
{
|
||||||
addend += (int64_t)addend * ppb / NSEC_PER_SEC;
|
addend += addend * ppb / NSEC_PER_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for overflows */
|
/* Check for overflows */
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun,
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%ju, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -257,7 +257,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun,
|
|||||||
|
|
||||||
int stm32_freerun_counter(struct stm32_freerun_s *freerun, uint64_t *counter)
|
int stm32_freerun_counter(struct stm32_freerun_s *freerun, uint64_t *counter)
|
||||||
{
|
{
|
||||||
*counter = (uint64_t)STM32_TIM_GETCOUNTER(freerun->tch);
|
*counter = STM32_TIM_GETCOUNTER(freerun->tch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -259,9 +259,8 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
|
|||||||
uint64_t period;
|
uint64_t period;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
DEBUGASSERT(oneshot->tch);
|
DEBUGASSERT(oneshot->tch);
|
||||||
|
|
||||||
@@ -449,8 +448,8 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -832,8 +832,8 @@ int stm32_rtc_rdalarm(FAR struct alm_rdalarm_s *alminfo)
|
|||||||
regvals.cnth = getreg16(STM32_RTC_ALRH);
|
regvals.cnth = getreg16(STM32_RTC_ALRH);
|
||||||
regvals.cntl = getreg16(STM32_RTC_ALRL);
|
regvals.cntl = getreg16(STM32_RTC_ALRL);
|
||||||
tp.tv_sec = regvals.cnth << 16 | regvals.cntl;
|
tp.tv_sec = regvals.cnth << 16 | regvals.cntl;
|
||||||
memcpy(alminfo->ar_time, (FAR struct tm *)gmtime(&tp.tv_sec),
|
memcpy(alminfo->ar_time, gmtime(&tp.tv_sec),
|
||||||
sizeof(FAR struct tm));
|
sizeof(struct tm));
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -686,8 +686,8 @@ int up_timer_gettime(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -872,8 +872,8 @@ int up_timer_cancel(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -911,8 +911,8 @@ int up_timer_start(const struct timespec *ts)
|
|||||||
uint32_t count;
|
uint32_t count;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("ts=(%lu, %lu)\n",
|
tmrinfo("ts=(%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(ts);
|
DEBUGASSERT(ts);
|
||||||
DEBUGASSERT(g_tickless.tch);
|
DEBUGASSERT(g_tickless.tch);
|
||||||
|
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ static int stm32_getstatus(struct timer_lowerhalf_s *lower,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeout = ((uint64_t) period * 1000000) / clock;
|
timeout = ((uint64_t)period * 1000000) / clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
status->timeout = timeout;
|
status->timeout = timeout;
|
||||||
@@ -425,7 +425,7 @@ static int stm32_getstatus(struct timer_lowerhalf_s *lower,
|
|||||||
/* Get the time remaining until the timer expires (in microseconds) */
|
/* Get the time remaining until the timer expires (in microseconds) */
|
||||||
|
|
||||||
counter = STM32_TIM_GETCOUNTER(priv->tim);
|
counter = STM32_TIM_GETCOUNTER(priv->tim);
|
||||||
status->timeleft = ((uint64_t) (timeout - counter) * clock) / 1000000;
|
status->timeleft = ((uint64_t)(timeout - counter) * clock) / 1000000;
|
||||||
tmrinfo("timeout=%" PRIu32 " counter=%" PRIu32 "\n", timeout, counter);
|
tmrinfo("timeout=%" PRIu32 " counter=%" PRIu32 "\n", timeout, counter);
|
||||||
tmrinfo("timeleft=%" PRIu32 "\n", status->timeleft);
|
tmrinfo("timeleft=%" PRIu32 "\n", status->timeleft);
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -177,7 +178,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op)
|
|||||||
_info(" fileno:%d\n", (int) bbf->fileno);
|
_info(" fileno:%d\n", (int) bbf->fileno);
|
||||||
_info(" dirty:%d\n", (int) bbf->dirty);
|
_info(" dirty:%d\n", (int) bbf->dirty);
|
||||||
_info(" length:%d\n", (int) bbf->len);
|
_info(" length:%d\n", (int) bbf->len);
|
||||||
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
|
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
|
||||||
|
bbf->lastwrite.tv_nsec);
|
||||||
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
||||||
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -727,8 +727,8 @@ int up_timer_gettime(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -914,8 +914,8 @@ int up_timer_cancel(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -955,8 +955,8 @@ int up_timer_start(const struct timespec *ts)
|
|||||||
uint32_t count;
|
uint32_t count;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("ts=(%lu, %lu)\n",
|
tmrinfo("ts=(%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(ts);
|
DEBUGASSERT(ts);
|
||||||
DEBUGASSERT(g_tickless.tch);
|
DEBUGASSERT(g_tickless.tch);
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -198,7 +199,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op)
|
|||||||
_info(" fileno:%d\n", (int) bbf->fileno);
|
_info(" fileno:%d\n", (int) bbf->fileno);
|
||||||
_info(" dirty:%d\n", (int) bbf->dirty);
|
_info(" dirty:%d\n", (int) bbf->dirty);
|
||||||
_info(" length:%d\n", (int) bbf->len);
|
_info(" length:%d\n", (int) bbf->len);
|
||||||
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
|
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
|
||||||
|
bbf->lastwrite.tv_nsec);
|
||||||
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
||||||
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,8 +263,8 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
|
|||||||
uint64_t period;
|
uint64_t period;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", handler, arg,
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", handler, arg,
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
DEBUGASSERT(oneshot->tch);
|
DEBUGASSERT(oneshot->tch);
|
||||||
|
|
||||||
|
|||||||
@@ -701,8 +701,8 @@ int up_timer_gettime(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -888,8 +888,8 @@ int up_timer_cancel(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -929,8 +929,8 @@ int up_timer_start(const struct timespec *ts)
|
|||||||
uint32_t count;
|
uint32_t count;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("ts=(%lu, %lu)\n",
|
tmrinfo("ts=(%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(ts);
|
DEBUGASSERT(ts);
|
||||||
DEBUGASSERT(g_tickless.tch);
|
DEBUGASSERT(g_tickless.tch);
|
||||||
|
|
||||||
|
|||||||
@@ -231,8 +231,8 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%u, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,9 +260,8 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
|
|||||||
uint64_t period;
|
uint64_t period;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
DEBUGASSERT(oneshot->tch);
|
DEBUGASSERT(oneshot->tch);
|
||||||
|
|
||||||
@@ -451,8 +450,8 @@ int stm32l4_oneshot_cancel(struct stm32l4_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%ju, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -256,7 +256,7 @@ int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
|
|||||||
int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
|
int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
|
||||||
uint64_t *counter)
|
uint64_t *counter)
|
||||||
{
|
{
|
||||||
*counter = (uint64_t)STM32WB_TIM_GETCOUNTER(freerun->tch);
|
*counter = STM32WB_TIM_GETCOUNTER(freerun->tch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,9 +260,8 @@ int stm32wb_oneshot_start(struct stm32wb_oneshot_s *oneshot,
|
|||||||
uint64_t period;
|
uint64_t period;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
DEBUGASSERT(oneshot->tch);
|
DEBUGASSERT(oneshot->tch);
|
||||||
|
|
||||||
@@ -450,8 +449,8 @@ int stm32wb_oneshot_cancel(struct stm32wb_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -552,8 +552,8 @@ int up_timer_gettime(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -738,8 +738,8 @@ int up_timer_cancel(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -777,8 +777,8 @@ int up_timer_start(const struct timespec *ts)
|
|||||||
uint32_t count;
|
uint32_t count;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("ts=(%lu, %lu)\n",
|
tmrinfo("ts=(%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(ts);
|
DEBUGASSERT(ts);
|
||||||
DEBUGASSERT(g_tickless.tch);
|
DEBUGASSERT(g_tickless.tch);
|
||||||
|
|
||||||
|
|||||||
@@ -375,8 +375,8 @@ int up_timer_gettime(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -412,8 +412,8 @@ int up_timer_start(const struct timespec *ts)
|
|||||||
uint64_t period;
|
uint64_t period;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("ts=(%lu, %lu)\n",
|
tmrinfo("ts=(%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
DEBUGASSERT(ts);
|
DEBUGASSERT(ts);
|
||||||
|
|
||||||
/* Was an interval already running? */
|
/* Was an interval already running? */
|
||||||
@@ -566,8 +566,8 @@ int up_timer_cancel(struct timespec *ts)
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
|
|
||||||
tmrinfo("remaining count : %lu (%lu, %lu)\n", count,
|
tmrinfo("remaining count : %lu (%jd, %ld)\n", count,
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -666,7 +666,7 @@ uint64_t *arm64_fatal_handler(uint64_t *regs)
|
|||||||
|
|
||||||
tcb->flags |= TCB_FLAG_FORCED_CANCEL;
|
tcb->flags |= TCB_FLAG_FORCED_CANCEL;
|
||||||
|
|
||||||
regs[REG_ELR] = (uint64_t) _exit;
|
regs[REG_ELR] = (uint64_t)_exit;
|
||||||
regs[REG_X0] = SIGSEGV;
|
regs[REG_X0] = SIGSEGV;
|
||||||
regs[REG_SPSR] &= ~SPSR_MODE_MASK;
|
regs[REG_SPSR] &= ~SPSR_MODE_MASK;
|
||||||
regs[REG_SPSR] |= SPSR_MODE_EL1H;
|
regs[REG_SPSR] |= SPSR_MODE_EL1H;
|
||||||
|
|||||||
@@ -2441,7 +2441,7 @@ static int imx9_recvsetup(struct sdio_dev_s *dev, uint8_t *buffer,
|
|||||||
{
|
{
|
||||||
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
|
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
|
||||||
DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0);
|
DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0);
|
||||||
DEBUGASSERT(((uint64_t) buffer & 3) == 0);
|
DEBUGASSERT(((uint64_t)buffer & 3) == 0);
|
||||||
|
|
||||||
/* Reset the DPSM configuration */
|
/* Reset the DPSM configuration */
|
||||||
|
|
||||||
@@ -2492,7 +2492,7 @@ static int imx9_sendsetup(struct sdio_dev_s *dev,
|
|||||||
{
|
{
|
||||||
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
|
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
|
||||||
DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0);
|
DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0);
|
||||||
DEBUGASSERT(((uint64_t) buffer & 3) == 0);
|
DEBUGASSERT(((uint64_t)buffer & 3) == 0);
|
||||||
|
|
||||||
/* Reset the DPSM configuration */
|
/* Reset the DPSM configuration */
|
||||||
|
|
||||||
@@ -3230,12 +3230,12 @@ static int imx9_dmarecvsetup(struct sdio_dev_s *dev,
|
|||||||
imx9_configxfrints(priv, USDHC_DMADONE_INTS);
|
imx9_configxfrints(priv, USDHC_DMADONE_INTS);
|
||||||
if (priv->unaligned_rx)
|
if (priv->unaligned_rx)
|
||||||
{
|
{
|
||||||
putreg32((uint64_t) priv->rxbuffer,
|
putreg32((uint64_t)priv->rxbuffer,
|
||||||
priv->addr + IMX9_USDHC_DSADDR_OFFSET);
|
priv->addr + IMX9_USDHC_DSADDR_OFFSET);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
putreg32((uint64_t) priv->buffer,
|
putreg32((uint64_t)priv->buffer,
|
||||||
priv->addr + IMX9_USDHC_DSADDR_OFFSET);
|
priv->addr + IMX9_USDHC_DSADDR_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3271,7 +3271,7 @@ static int imx9_dmasendsetup(struct sdio_dev_s *dev,
|
|||||||
{
|
{
|
||||||
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
|
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
|
||||||
DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
|
DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
|
||||||
DEBUGASSERT(((uint64_t) buffer & 3) == 0);
|
DEBUGASSERT(((uint64_t)buffer & 3) == 0);
|
||||||
|
|
||||||
/* Begin sampling register values */
|
/* Begin sampling register values */
|
||||||
|
|
||||||
@@ -3297,7 +3297,7 @@ static int imx9_dmasendsetup(struct sdio_dev_s *dev,
|
|||||||
|
|
||||||
/* Configure the TX DMA */
|
/* Configure the TX DMA */
|
||||||
|
|
||||||
putreg32((uint64_t) buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET);
|
putreg32((uint64_t)buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET);
|
||||||
|
|
||||||
/* Sample the register state */
|
/* Sample the register state */
|
||||||
|
|
||||||
|
|||||||
@@ -260,8 +260,8 @@ int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo("usec=%llu ts=(%u, %lu)\n",
|
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -271,8 +271,8 @@ int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
|
|||||||
int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
|
int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
|
||||||
uint64_t *counter)
|
uint64_t *counter)
|
||||||
{
|
{
|
||||||
*counter = (uint64_t)PIC32MZ_TIMER_GETCOUNTER(freerun->timer) &
|
*counter = PIC32MZ_TIMER_GETCOUNTER(freerun->timer) &
|
||||||
freerun->counter_mask;
|
freerun->counter_mask;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -277,9 +277,8 @@ int pic32mz_oneshot_start(struct pic32mz_oneshot_s *oneshot,
|
|||||||
uint64_t period;
|
uint64_t period;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
|
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
|
||||||
handler, arg, (unsigned long)ts->tv_sec,
|
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
(unsigned long)ts->tv_nsec);
|
|
||||||
DEBUGASSERT(oneshot && handler && ts);
|
DEBUGASSERT(oneshot && handler && ts);
|
||||||
DEBUGASSERT(oneshot->timer);
|
DEBUGASSERT(oneshot->timer);
|
||||||
|
|
||||||
@@ -437,8 +436,8 @@ int pic32mz_oneshot_cancel(struct pic32mz_oneshot_s *oneshot,
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrinfo("remaining (%lu, %lu)\n",
|
tmrinfo("remaining (%jd, %ld)\n",
|
||||||
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -170,7 +171,8 @@ static void rx65n_sbram_dump(struct sbramfh_s *bbf, char *op)
|
|||||||
_info(" fileno:%d\n", (int) bbf->fileno);
|
_info(" fileno:%d\n", (int) bbf->fileno);
|
||||||
_info(" dirty:%d\n", (int) bbf->dirty);
|
_info(" dirty:%d\n", (int) bbf->dirty);
|
||||||
_info(" length:%d\n", (int) bbf->len);
|
_info(" length:%d\n", (int) bbf->len);
|
||||||
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
|
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
|
||||||
|
bbf->lastwrite.tv_nsec);
|
||||||
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
|
||||||
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ void IRAM_ATTR ets_timer_arm(ets_timer *ptimer,
|
|||||||
uint32_t time_ms,
|
uint32_t time_ms,
|
||||||
bool repeat_flag)
|
bool repeat_flag)
|
||||||
{
|
{
|
||||||
uint64_t time_us = 1000LL * (uint64_t) time_ms;
|
uint64_t time_us = 1000LL * (uint64_t)time_ms;
|
||||||
|
|
||||||
assert(timer_initialized(ptimer));
|
assert(timer_initialized(ptimer));
|
||||||
|
|
||||||
|
|||||||
@@ -630,8 +630,7 @@ static int esp_rtc_rdalarm(struct rtc_lowerhalf_s *lower,
|
|||||||
ts.tv_nsec = ((esp_hr_timer_time_us() + g_rtc_save->offset +
|
ts.tv_nsec = ((esp_hr_timer_time_us() + g_rtc_save->offset +
|
||||||
cbinfo->deadline_us) % USEC_PER_SEC) * NSEC_PER_USEC;
|
cbinfo->deadline_us) % USEC_PER_SEC) * NSEC_PER_USEC;
|
||||||
|
|
||||||
localtime_r((const time_t *)&ts.tv_sec,
|
localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time);
|
||||||
(struct tm *)alarminfo->time);
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
spin_unlock_irqrestore(&priv->lock, flags);
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ uint64_t riscv_sbi_get_time(void)
|
|||||||
}
|
}
|
||||||
while (hi != READ_CSR(CSR_TIMEH));
|
while (hi != READ_CSR(CSR_TIMEH));
|
||||||
|
|
||||||
return (((uint64_t) hi) << 32) | lo;
|
return (((uint64_t)hi) << 32) | lo;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1399,7 +1399,7 @@ static uint32_t IRAM_ATTR btdm_lpcycles_2_hus(uint32_t cycles,
|
|||||||
static uint32_t IRAM_ATTR btdm_hus_2_lpcycles(uint32_t us)
|
static uint32_t IRAM_ATTR btdm_hus_2_lpcycles(uint32_t us)
|
||||||
{
|
{
|
||||||
uint64_t cycles;
|
uint64_t cycles;
|
||||||
cycles = ((uint64_t)(us) << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us;
|
cycles = ((uint64_t)us << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us;
|
||||||
return (uint32_t)cycles;
|
return (uint32_t)cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,8 +301,8 @@ int esp32c3_freerun_counter(struct esp32c3_freerun_s *freerun,
|
|||||||
ts->tv_sec = sec;
|
ts->tv_sec = sec;
|
||||||
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
|
||||||
|
|
||||||
tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n",
|
tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n",
|
||||||
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
|
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user