1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

xtimer: Update xtimer usage to match API changes

This commit is contained in:
Joakim Nohlgård 2016-07-05 21:32:44 +02:00
parent 24b41dc633
commit 7c48c891a0
43 changed files with 113 additions and 118 deletions

View File

@ -401,7 +401,7 @@ uint8_t writeRingBuff(int16_t *value)
/* measuring temperature dependent internal sample rate of SMB380 */
if (smb380_mode == SMB380_CONTINOUS) {
tickLastSample = xtimer_now();
tickLastSample = xtimer_now_usec();
tickCurrentSamples++;
}
@ -1030,7 +1030,7 @@ void SMB380_enableNewDataInt(void)
SMB380_ssp_read();
SMB380_Unprepare();
// measuring temperature dependent internal sample rate of SMB380
tickStart = xtimer_now();
tickStart = xtimer_now_usec();
tickCurrentSamples = 0;
irq_restore(cpsr);
}

View File

@ -163,10 +163,10 @@ interrupt(PORT1_VECTOR) __attribute__((naked)) port1_isr(void)
/* check interrupt source */
if (debounce_flags[0] & p1ifg) {
/* check if bouncing */
diff = xtimer_now() - debounce_time[0][ifg_num];
diff = xtimer_now_usec() - debounce_time[0][ifg_num];
if (diff > DEBOUNCE_TIMEOUT) {
debounce_time[0][ifg_num] = xtimer_now();
debounce_time[0][ifg_num] = xtimer_now_usec();
if (cb[0][ifg_num] != NULL) {
cb[0][ifg_num]();
@ -208,10 +208,10 @@ interrupt(PORT2_VECTOR) __attribute__((naked)) port2_isr(void)
/* check interrupt source */
if (debounce_flags[1] & p2ifg) {
/* check if bouncing */
diff = xtimer_now() - debounce_time[1][ifg_num];
diff = xtimer_now_usec() - debounce_time[1][ifg_num];
if (diff > DEBOUNCE_TIMEOUT) {
debounce_time[1][ifg_num] = xtimer_now();
debounce_time[1][ifg_num] = xtimer_now_usec();
c1++;
if (cb[1][ifg_num] != NULL) {

View File

@ -109,12 +109,12 @@ uint16_t adc_read(uint8_t channel)
/* switch channel, start A/D convert */
AD0CR &= 0xFFFFFF00;
#if ENABLE_DEBUG
t1 = xtimer_now();
t1 = _xtimer_now();
#endif
AD0CR |= (1 << 24) | (1 << channel);
#if ENABLE_DEBUG
t2 = xtimer_now();
t2 = _xtimer_now();
#endif
while (1) {

View File

@ -21,8 +21,6 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
extern unsigned long xtimer_now(void);
/* --- MCI configurations --- */
#define N_BUF 4 /* Block transfer FIFO depth (>= 2) */
#define USE_4BIT 1 /* Use wide bus mode if SDC is detected */
@ -415,12 +413,12 @@ static int send_cmd(unsigned int idx, unsigned long arg, unsigned int rt, unsign
MCI_COMMAND = mc; /* Initiate command transaction */
//Timer[1] = 100;
uint32_t timerstart = xtimer_now();
uint32_t timerstart = xtimer_now_usec();
while (1) { /* Wait for end of the cmd/resp transaction */
//if (!Timer[1]) return 0;
if (xtimer_now() - timerstart > 10000) {
if ((xtimer_now_usec() - timerstart) > 10000) {
return 0;
}
@ -477,10 +475,10 @@ static int wait_ready(unsigned short tmr)
{
unsigned long rc;
uint32_t stoppoll = xtimer_now() + tmr * MS_IN_USEC;
uint32_t stoppoll = xtimer_now_usec() + tmr * MS_IN_USEC;
bool bBreak = false;
while (xtimer_now() < stoppoll/*Timer[0]*/) {
while (xtimer_now_usec() < stoppoll/*Timer[0]*/) {
if (send_cmd(CMD13, (unsigned long) CardRCA << 16, 1, &rc) && ((rc & 0x01E00) == 0x00800)) {
bBreak = true;
break;
@ -492,9 +490,6 @@ static int wait_ready(unsigned short tmr)
return bBreak;//Timer[0] ? 1 : 0;
}
/*-----------------------------------------------------------------------*/
/* Swap byte order */
/*-----------------------------------------------------------------------*/
@ -510,16 +505,12 @@ static void bswap_cp(unsigned char *dst, const unsigned long *src)
*dst++ = (unsigned char)(d >> 0);
}
/*--------------------------------------------------------------------------
Public Functions
---------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* Initialize Disk Drive */
/*-----------------------------------------------------------------------*/
@ -548,7 +539,7 @@ diskio_sta_t mci_initialize(void)
/*---- Card is 'idle' state ----*/
/* Initialization timeout of 1000 msec */
uint32_t start = xtimer_now();
uint32_t start = xtimer_now_usec();
/* SDC Ver2 */
if (send_cmd(CMD8, 0x1AA, 1, resp) && (resp[0] & 0xFFF) == 0x1AA) {
@ -558,7 +549,7 @@ diskio_sta_t mci_initialize(void)
do {
/* Wait while card is busy state (use ACMD41 with HCS bit) */
/* This loop will take a time. Insert wai_tsk(1) here for multitask envilonment. */
if (xtimer_now() > start + 1000000/* !Timer[0] */) {
if (xtimer_now_usec() > (start + 1000000/* !Timer[0] */)) {
DEBUG("%s, %d: Timeout #1\n", RIOT_FILE_RELATIVE, __LINE__);
goto di_fail;
}
@ -584,8 +575,8 @@ diskio_sta_t mci_initialize(void)
DEBUG("%s, %d: %lX\n", RIOT_FILE_RELATIVE, __LINE__, resp[0]);
/* This loop will take a time. Insert wai_tsk(1) here for multitask envilonment. */
if (xtimer_now() > start + 1000000/* !Timer[0] */) {
DEBUG("now: %lu, started at: %lu\n", xtimer_now(), start);
if (xtimer_now_usec() > (start + 1000000/* !Timer[0] */)) {
DEBUG("now: %lu, started at: %lu\n", xtimer_now_usec(), start);
DEBUG("%s, %d: Timeout #2\n", RIOT_FILE_RELATIVE, __LINE__);
goto di_fail;
}

View File

@ -22,6 +22,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#define AT30TSE75X_BUS_FREE_TIME_TICKS (xtimer_ticks_from_usec(AT30TSE75X_BUS_FREE_TIME_US))
static inline float temperature_to_float(uint16_t temp)
{
/* Integer part is 8-bit signed */
@ -37,7 +38,7 @@ static inline float temperature_to_float(uint16_t temp)
static int at30tse75x_get_register(at30tse75x_t* dev, uint8_t reg, uint16_t* data)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if (i2c_read_regs(dev->i2c, dev->addr, reg, data, 2) <= 0) {
DEBUG("[at30tse75x] Can't read register 0x%x\n", reg);
i2c_release(dev->i2c);
@ -51,7 +52,7 @@ static int at30tse75x_get_register(at30tse75x_t* dev, uint8_t reg, uint16_t* dat
static int at30tse75x_set_register(at30tse75x_t* dev, uint8_t reg, uint16_t* data)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if (i2c_write_regs(dev->i2c, dev->addr, reg, data, 2) <= 0) {
DEBUG("[at30tse75x] Can't write to register 0x%x\n", reg);
i2c_release(dev->i2c);
@ -65,8 +66,8 @@ static int at30tse75x_set_register(at30tse75x_t* dev, uint8_t reg, uint16_t* dat
static int at30tse75x_reset(at30tse75x_t* dev)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
if(i2c_write_byte(dev->i2c, 0x00, AT30TSE75X_CMD__GENERAL_CALL_RESET) != 1) {
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if (i2c_write_byte(dev->i2c, 0x00, AT30TSE75X_CMD__GENERAL_CALL_RESET) != 1) {
i2c_release(dev->i2c);
return -1;
}
@ -79,7 +80,7 @@ static int at30tse75x_reset(at30tse75x_t* dev)
int at30tse75x_get_config(at30tse75x_t* dev, uint8_t* data)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if (i2c_read_reg(dev->i2c, dev->addr, AT30TSE75X_REG__CONFIG, data) <= 0) {
DEBUG("[at30tse75x] Can't read CONFIG register\n");
i2c_release(dev->i2c);
@ -93,7 +94,7 @@ int at30tse75x_get_config(at30tse75x_t* dev, uint8_t* data)
int at30tse75x_set_config(at30tse75x_t* dev, uint8_t data)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if (i2c_write_reg(dev->i2c, dev->addr, AT30TSE75X_REG__CONFIG, data) <= 0) {
DEBUG("[at30tse75x] Can't write to CONFIG register\n");
i2c_release(dev->i2c);
@ -220,7 +221,7 @@ int at30tse75x_set_limit_high(at30tse75x_t* dev, int8_t t_high)
int at30tse75x_save_config(at30tse75x_t* dev)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if(i2c_write_byte(dev->i2c, dev->addr, AT30TSE75X_CMD__SAVE_TO_NVRAM) != 1) {
i2c_release(dev->i2c);
return -1;
@ -234,7 +235,7 @@ int at30tse75x_save_config(at30tse75x_t* dev)
int at30tse75x_restore_config(at30tse75x_t* dev)
{
i2c_acquire(dev->i2c);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_US);
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
if(i2c_write_byte(dev->i2c, dev->addr, AT30TSE75X_CMD__RESTORE_FROM_NVRAM) != 1) {
i2c_release(dev->i2c);
return -1;

View File

@ -54,9 +54,9 @@ static uint16_t read(gpio_t pin, int bits)
/* measure the length between the next rising and falling flanks (the
* time the pin is high - smoke up :-) */
while (!gpio_read(pin));
start = xtimer_now();
start = xtimer_now_usec();
while (gpio_read(pin));
end = xtimer_now();
end = xtimer_now_usec();
/* if the high phase was more than 40us, we got a 1 */
if ((end - start) > PULSE_WIDTH_THRESHOLD) {
res |= 0x0001;

View File

@ -40,7 +40,7 @@ static uint32_t last = 0;
static int check_and_read(void *dev, phydat_t *res, int16_t *val, uint8_t unit)
{
dht_t *d = (dht_t *)dev;
uint32_t now = xtimer_now();
uint32_t now = xtimer_now_usec();
if ((now - last) > DHT_SAUL_HOLD_TIME) {
dht_read(d, &temp, &hum);

View File

@ -86,7 +86,7 @@ void ltc4150_start(void)
{
ltc4150_disable_int();
int_count = 0;
uint32_t now = xtimer_now();
uint32_t now = xtimer_now_usec();
ltc4150_sync_blocking();
start_time = now;
last_int_time = now;
@ -100,7 +100,7 @@ void ltc4150_stop(void)
void __attribute__((__no_instrument_function__)) ltc4150_interrupt(void)
{
uint32_t now = xtimer_now();
uint32_t now = xtimer_now_usec();
if (now >= last_int_time) {
last_int_duration = now - last_int_time;

View File

@ -33,8 +33,8 @@ extern "C" {
#endif
#define INITIAL_RX_POWER_0dB 0
#define DELAY_CS_TOGGLE_TICKS 2
#define DELAY_AFTER_FUNC_TICKS 2
#define DELAY_CS_TOGGLE_US 2
#define DELAY_AFTER_FUNC_US 2
#define DELAY_CE_HIGH_US (20)
#define DELAY_CHANGE_PWR_MODE_US (1500)
#define DELAY_CHANGE_TXRX_US (130)

View File

@ -27,6 +27,9 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#define DELAY_CS_TOGGLE_TICKS (xtimer_ticks_from_usec(DELAY_CS_TOGGLE_US))
#define DELAY_AFTER_FUNC_TICKS (xtimer_ticks_from_usec(DELAY_AFTER_FUNC_US))
#define DELAY_CHANGE_TXRX_TICKS (xtimer_ticks_from_usec(DELAY_CHANGE_TXRX_US))
int nrf24l01p_read_reg(nrf24l01p_t *dev, char reg, char *answer)
{
@ -229,7 +232,7 @@ void nrf24l01p_transmit(nrf24l01p_t *dev)
xtimer_usleep(DELAY_CE_HIGH_US); /* at least 10 us high */
gpio_clear(dev->ce);
xtimer_spin(DELAY_CHANGE_TXRX_US);
xtimer_spin(DELAY_CHANGE_TXRX_TICKS);
}
int nrf24l01p_read_payload(nrf24l01p_t *dev, char *answer, unsigned int size)

View File

@ -138,7 +138,7 @@ static void _api_at_cmd(xbee_t *dev, uint8_t *cmd, uint8_t size, resp_t *resp)
/* start send data */
uart_write(dev->uart, dev->tx_buf, size + 6);
uint64_t sent_time = xtimer_now64();
xtimer_ticks64_t sent_time = xtimer_now64();
xtimer_t resp_timer;
@ -149,7 +149,9 @@ static void _api_at_cmd(xbee_t *dev, uint8_t *cmd, uint8_t size, resp_t *resp)
/* wait for results */
while ((dev->resp_limit != dev->resp_count) &&
(xtimer_now64() - sent_time < RESP_TIMEOUT_USEC)) {
(xtimer_less(
xtimer_diff32_64(xtimer_now64(), sent_time),
xtimer_ticks_from_usec(RESP_TIMEOUT_USEC)))) {
mutex_lock(&(dev->resp_lock));
}

View File

@ -27,11 +27,11 @@
int main(void)
{
uint32_t last_wakeup = xtimer_now();
xtimer_ticks32_t last_wakeup = xtimer_now();
while(1) {
xtimer_periodic_wakeup(&last_wakeup, INTERVAL);
printf("slept until %" PRIu32 "\n", xtimer_now());
printf("slept until %" PRIu32 "\n", xtimer_usec_from_ticks(xtimer_now()));
}
return 0;

View File

@ -196,12 +196,12 @@ void hal_watchdogStop(void)
clock_time_t hal_getTick(void)
{
return (clock_time_t)xtimer_now();
return (clock_time_t)xtimer_now_usec();
}
clock_time_t hal_getSec(void)
{
return (clock_time_t)xtimer_now() / SEC_IN_USEC;
return (clock_time_t)xtimer_now_usec() / SEC_IN_USEC;
}

View File

@ -81,9 +81,9 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t count)
LWIP_ASSERT("invalid semaphor", sys_sem_valid(sem));
if (count != 0) {
uint64_t stop, start;
start = xtimer_now64();
start = xtimer_now_usec64();
int res = sema_wait_timed((sema_t *)sem, count * MS_IN_USEC);
stop = xtimer_now64() - start;
stop = xtimer_now_usec64() - start;
if (res == -ETIMEDOUT) {
return SYS_ARCH_TIMEOUT;
}
@ -140,13 +140,13 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
xtimer_t timer = { .callback = _mbox_timeout, .arg = &mbox->mbox };
uint64_t start, stop;
start = xtimer_now64();
start = xtimer_now_usec64();
if (timeout > 0) {
uint64_t u_timeout = (timeout * MS_IN_USEC);
_xtimer_set64(&timer, (uint32_t)u_timeout, (uint32_t)(u_timeout >> 32));
}
mbox_get(&mbox->mbox, &m);
stop = xtimer_now64();
stop = xtimer_now_usec64();
xtimer_remove(&timer); /* in case timer did not time out */
switch (m.type) {
case _MSG_SUCCESS:

View File

@ -39,7 +39,7 @@
* (void)vector;
* (void)count;
*
* sum += (xtimer_now() - last_start);
* sum += (xtimer_now_usec() - last_start);
* mutex_unlock(&wait);
* }
*
@ -52,7 +52,7 @@
* // ...
* mutex_lock(&wait);
* for (int i = 0; i < PKT_NUMBER; i++) {
* last_start = xtimer_now();
* last_start = xtimer_now_usec();
* conn_udp_sendto("abcd", sizeof("abcd"), NULL, 0, &dst, sizeof(dst),
* AF_INET6, 0xcafe, 0xcafe);
* mutex_lock(&wait);

View File

@ -133,7 +133,7 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p
static uint32_t _current_minute(void)
{
return xtimer_now() / (SEC_IN_USEC * 60);
return xtimer_now_usec() / (SEC_IN_USEC * 60);
}
static void _update_lifetime(uint8_t id)

View File

@ -250,7 +250,7 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size)
static void _rbuf_gc(void)
{
uint32_t now_usec = xtimer_now();
uint32_t now_usec = xtimer_now_usec();
unsigned int i;
for (i = 0; i < RBUF_SIZE; i++) {
@ -275,7 +275,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
size_t size, uint16_t tag)
{
rbuf_t *res = NULL, *oldest = NULL;
uint32_t now_usec = xtimer_now();
uint32_t now_usec = xtimer_now_usec();
for (unsigned int i = 0; i < RBUF_SIZE; i++) {
/* check first if entry already available */

View File

@ -252,7 +252,7 @@ static void *_event_loop(void *args)
void _update_lifetime(void)
{
uint32_t now = xtimer_now();
uint32_t now = xtimer_now_usec();
uint16_t now_sec = now / SEC_IN_USEC;
gnrc_rpl_parent_t *parent;

View File

@ -225,7 +225,7 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
/* set the default route to the next parent for now */
if (parent->next) {
uint32_t now = xtimer_now() / SEC_IN_USEC;
uint32_t now = xtimer_now_usec() / SEC_IN_USEC;
fib_add_entry(&gnrc_ipv6_fib_table,
dodag->iface,
(uint8_t *) ipv6_addr_unspecified.u8,
@ -266,7 +266,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
{
/* update Parent lifetime */
if (parent != NULL) {
uint32_t now = xtimer_now();
uint32_t now = xtimer_now_usec();
parent->lifetime = (now / SEC_IN_USEC) + (dodag->default_lifetime * dodag->lifetime_unit);
#ifdef MODULE_GNRC_RPL_P2P
if (dodag->instance->mop != GNRC_RPL_P2P_MOP) {

View File

@ -158,7 +158,7 @@ int csma_sender_csma_ca_send(netdev2_t *dev, struct iovec *vector,
/* if we arrive here, then we must perform the CSMA/CA procedure
ourselves by software */
random_init(xtimer_now());
random_init(_xtimer_now());
DEBUG("csma: Starting software CSMA/CA....\n");
int nb = 0, be = conf->min_be;

View File

@ -28,6 +28,7 @@
#include "mutex.h"
#include "msg.h"
#include "xtimer.h"
#include "timex.h"
#include "utlist.h"
#define ENABLE_DEBUG (0)
@ -61,7 +62,7 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN];
*/
static void fib_lifetime_to_absolute(uint32_t ms, uint64_t *target)
{
*target = xtimer_now64() + (ms * 1000);
*target = xtimer_now_usec64() + (ms * MS_IN_USEC);
}
/**
@ -80,7 +81,7 @@ static void fib_lifetime_to_absolute(uint32_t ms, uint64_t *target)
*/
static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
fib_entry_t **entry_arr, size_t *entry_arr_size) {
uint64_t now = xtimer_now64();
uint64_t now = xtimer_now_usec64();
size_t count = 0;
size_t prefix_size = 0;
@ -703,7 +704,7 @@ int fib_sr_create(fib_table_t *table, fib_sr_t **fib_sr, kernel_pid_t sr_iface_i
*/
static int fib_sr_check_lifetime(fib_sr_t *fib_sr)
{
uint64_t tm = fib_sr->sr_lifetime - xtimer_now64();
uint64_t tm = fib_sr->sr_lifetime - xtimer_now_usec64();
/* check if the lifetime expired */
if ((int64_t)tm < 0) {
/* remove this sr if its lifetime expired */
@ -777,7 +778,7 @@ int fib_sr_read_head(fib_table_t *table, fib_sr_t *fib_sr, kernel_pid_t *iface_i
*iface_id = fib_sr->sr_iface_id;
*sr_flags = fib_sr->sr_flags;
*sr_lifetime = fib_sr->sr_lifetime - xtimer_now64();
*sr_lifetime = fib_sr->sr_lifetime - xtimer_now_usec64();
mutex_unlock(&(table->mtx_access));
return 0;
@ -1530,7 +1531,7 @@ static void fib_print_address(universal_address_container_t *entry)
void fib_print_routes(fib_table_t *table)
{
mutex_lock(&(table->mtx_access));
uint64_t now = xtimer_now64();
uint64_t now = xtimer_now_usec64();
if (table->table_type == FIB_TABLE_TYPE_SH) {
printf("%-" FIB_ADDR_PRINT_LENS "s %-17s %-" FIB_ADDR_PRINT_LENS "s %-10s %-16s"

View File

@ -340,7 +340,7 @@ int _gettimeofday_r(struct _reent *r, struct timeval *restrict tp, void *restric
{
(void)tzp;
(void) r;
uint64_t now = xtimer_usec_from_ticks64(xtimer_now64());
uint64_t now = xtimer_now_usec64();
tp->tv_sec = div_u64_by_1000000(now);
tp->tv_usec = now - (tp->tv_sec * SEC_IN_USEC);
return 0;

View File

@ -33,16 +33,15 @@
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
{
uint64_t now, timeout = (((uint64_t)abstime->tv_sec) * SEC_IN_USEC) +
uint64_t timeout = (((uint64_t)abstime->tv_sec) * SEC_IN_USEC) +
(abstime->tv_nsec / USEC_IN_NS);
int res;
now = xtimer_now64();
uint64_t now = xtimer_now_usec64();
if (now > timeout) {
errno = ETIMEDOUT;
return -1;
}
timeout = timeout - now;
res = sema_wait_timed((sema_t *)sem, timeout);
int res = sema_wait_timed((sema_t *)sem, timeout);
if (res < 0) {
errno = -res;
return -1;

View File

@ -260,7 +260,7 @@ int _gnrc_rpl_dodag_show(void)
gnrc_rpl_dodag_t *dodag = NULL;
char addr_str[IPV6_ADDR_MAX_STR_LEN];
int8_t cleanup;
uint64_t tc, ti, xnow = xtimer_now64();
uint64_t tc, ti, xnow = xtimer_now_usec64();
for (uint8_t i = 0; i < GNRC_RPL_INSTANCES_NUMOF; ++i) {
if (gnrc_rpl_instances[i].state == 0) {

View File

@ -233,7 +233,7 @@ int _icmpv6_ping(int argc, char **argv)
remaining = count;
ping_start = xtimer_now64();
ping_start = xtimer_now_usec64();
while ((remaining--) > 0) {
gnrc_pktsnip_t *pkt;
@ -269,7 +269,7 @@ int _icmpv6_ping(int argc, char **argv)
((gnrc_netif_hdr_t *)pkt->data)->if_pid = src_iface;
}
start = xtimer_now();
start = xtimer_now_usec();
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) {
puts("error: unable to send ICMPv6 echo request\n");
gnrc_pktbuf_release(pkt);
@ -281,7 +281,7 @@ int _icmpv6_ping(int argc, char **argv)
uint32_t stop;
switch (msg.type) {
case GNRC_NETAPI_MSG_TYPE_RCV:
stop = xtimer_now() - start;
stop = xtimer_now_usec() - start;
gnrc_pktsnip_t *pkt = msg.content.ptr;
success += _handle_reply(pkt, stop);
@ -321,7 +321,7 @@ int _icmpv6_ping(int argc, char **argv)
xtimer_usleep64(delay * MS_IN_USEC);
}
if ((++stat_counter == stat_interval) || (remaining == 0)) {
uint64_t total_time = xtimer_now64() - ping_start;
uint64_t total_time = xtimer_now_usec64() - ping_start;
_print_stats(addr_str, success, (count - remaining), total_time, sum_rtt, min_rtt,
max_rtt);
stat_counter = 0;

View File

@ -36,7 +36,7 @@ int _random_init(int argc, char **argv)
if (argc == 1) {
#ifdef MODULE_XTIMER
initval = xtimer_now();
initval = _xtimer_now();
printf("PRNG initialized to current time: %d\n", initval);
#else
(void)initval;

View File

@ -68,7 +68,7 @@ int main(void)
random_init(myseed);
unsigned long t1 = xtimer_now();
unsigned long t1 = xtimer_now_usec();
for (int i = 0; i < lenB; i++) {
buf_fill(buf, BUF_SIZE);
@ -78,14 +78,14 @@ int main(void)
BUF_SIZE * sizeof(uint32_t) / sizeof(uint8_t));
}
unsigned long t2 = xtimer_now();
unsigned long t2 = xtimer_now_usec();
printf("adding %d elements took %" PRIu32 "ms\n", lenB,
(uint32_t) (t2 - t1) / 1000);
int in = 0;
int not_in = 0;
unsigned long t3 = xtimer_now();
unsigned long t3 = xtimer_now_usec();
for (int i = 0; i < lenA; i++) {
buf_fill(buf, BUF_SIZE);
@ -101,7 +101,7 @@ int main(void)
}
}
unsigned long t4 = xtimer_now();
unsigned long t4 = xtimer_now_usec();
printf("checking %d elements took %" PRIu32 "ms\n", lenA,
(uint32_t) (t4 - t3) / 1000);

View File

@ -30,7 +30,7 @@ int main(void)
{
int res;
bh1750fvi_t dev;
uint32_t last = xtimer_now();
xtimer_ticks32_t last = xtimer_now();
puts("BH1750FVI ambient light sensor test\n");

View File

@ -46,7 +46,7 @@ static color_rgb_t leds[LPD8808_PARAM_LED_CNT];
int main(void)
{
uint32_t now = xtimer_now();
xtimer_ticks32_t now = xtimer_now();
int pos = 0;
int step = 1;
color_hsv_t col = { 0.0, 1.0, 1.0 };

View File

@ -75,7 +75,7 @@ static int cmd_sample(int argc, char **argv)
{
(void)argc;
(void)argv;
uint32_t wakeup = xtimer_now();
xtimer_ticks32_t wakeup = xtimer_now();
while(1) {
sample();

View File

@ -31,7 +31,7 @@
int main(void)
{
uint32_t last = xtimer_now();
xtimer_ticks32_t last = xtimer_now();
int sample = 0;
puts("\nRIOT ADC peripheral driver test\n");

View File

@ -30,7 +30,7 @@
int main(void)
{
uint32_t last = xtimer_now();
xtimer_ticks32_t last = xtimer_now();
uint16_t val = 0;
uint16_t step = 0xffff / STEPS;

View File

@ -42,7 +42,7 @@ int main(void)
{
int state = 0;
int step = STEP;
uint32_t last_wakeup = xtimer_now();
xtimer_ticks32_t last_wakeup = xtimer_now();
puts("\nRIOT PWM test");
puts("Connect an LED or scope to PWM pins to see something\n");

View File

@ -242,14 +242,14 @@ void test4(void)
struct timespec abs;
uint64_t now, start, stop;
const uint64_t exp = 1000000;
now = xtimer_now64();
now = xtimer_now_usec64();
abs.tv_sec = (time_t)((now / SEC_IN_USEC) + 1);
abs.tv_nsec = (long)((now % SEC_IN_USEC) * 1000);
puts("first: sem_init s1");
if (sem_init(&s1, 0, 0) < 0) {
puts("first: sem_init FAILED");
}
start = xtimer_now64();
start = xtimer_now_usec64();
puts("first: wait 1 sec for s1");
if (sem_timedwait(&s1, &abs) != 0) {
if (errno != ETIMEDOUT) {
@ -260,7 +260,7 @@ void test4(void)
puts("first: timed out");
}
}
stop = xtimer_now64() - start;
stop = xtimer_now_usec64() - start;
if ((stop < (exp - 100)) || (stop > (exp + 100))) {
fmt_u64_dec(uint64_str, stop);
printf("first: waited only %s usec => FAILED\n", uint64_str);

View File

@ -32,7 +32,7 @@
int main(void)
{
phydat_t res;
uint32_t last = xtimer_now();
xtimer_ticks32_t last_wakeup = xtimer_now();
puts("SAUL test application");
@ -50,7 +50,7 @@ int main(void)
dev = dev->next;
}
xtimer_periodic_wakeup(&last, INTERVAL);
xtimer_periodic_wakeup(&last_wakeup, INTERVAL);
}
return 0;

View File

@ -604,7 +604,7 @@ static void test_fib_15_get_lifetime(void)
add_buf_size - 1));
/* assuming some ms passed during these operations... */
now = xtimer_now64();
now = xtimer_now_usec64();
uint64_t cmp_lifetime = now + 900000lU;
uint64_t cmp_max_lifetime = now + 1100000lU;

View File

@ -79,7 +79,7 @@ void *slacker_thread(void *arg)
tmsg->msg.type = 12345;
tmsg->msg.content.ptr = tmsg;
xtimer_set_msg(&tmsg->timer, xtimer_ticks_from_usec(tmsg->interval), &tmsg->msg, thread_getpid());
xtimer_set_msg(&tmsg->timer, tmsg->interval, &tmsg->msg, thread_getpid());
}
}
@ -96,7 +96,8 @@ void *worker_thread(void *arg)
while (1) {
msg_t m;
msg_receive(&m);
uint32_t now = xtimer_usec_from_ticks(xtimer_now());
xtimer_ticks32_t ticks = xtimer_now();
uint32_t now = xtimer_usec_from_ticks(ticks);
if (start == 0) {
start = now;
last = start;
@ -105,18 +106,15 @@ void *worker_thread(void *arg)
}
uint32_t us, sec;
uint32_t min, hr;
us = now % SEC_IN_USEC;
sec = now / SEC_IN_USEC;
min = (sec / 60) % 60;
hr = sec / 3600;
if ((loop_counter % TEST_HZ) == 0) {
uint32_t expected = start + loop_counter * TEST_INTERVAL;
int32_t drift = now - expected;
expected = last + TEST_HZ * TEST_INTERVAL;
int32_t jitter = now - expected;
printf("now=%" PRIu32 ".%06" PRIu32 " (%" PRIu32 " hours %" PRIu32 " min), ",
sec, us, hr, min);
printf("now=%" PRIu32 ".%06" PRIu32 " (0x%08" PRIx32 " ticks), ",
sec, us, ticks.ticks32);
printf("drift=%" PRId32 " us, jitter=%" PRId32 " us\n", drift, jitter);
last = now;
}
@ -192,7 +190,7 @@ int main(void)
xtimer_ticks32_t last_wakeup = xtimer_now();
while (1) {
xtimer_periodic_wakeup(&last_wakeup, xtimer_ticks_from_usec(TEST_INTERVAL));
xtimer_periodic_wakeup(&last_wakeup, TEST_INTERVAL);
msg_try_send(&m, pid3);
}
}

View File

@ -76,8 +76,9 @@ int main(void)
NULL,
"timer2");
uint32_t end = xtimer_now() + TEST_TIME;
while(xtimer_now() < end)
xtimer_ticks32_t end = xtimer_now();
end.ticks32 += _xtimer_ticks_from_usec(TEST_TIME);
while(_xtimer_now() < end.ticks32)
{
count++;
xtimer_usleep(100LU * 1000);

View File

@ -96,7 +96,7 @@ void *mid_sleep(void *arg)
void *ticker(void *arg)
{
(void)arg;
uint32_t base = xtimer_now();
xtimer_ticks32_t base = xtimer_now();
while (1) {
++short_ticks;

View File

@ -82,11 +82,10 @@ void *timer_thread_local(void *arg)
msg_t m;
msg_receive(&m);
uint32_t now = xtimer_now();
int sec, min, hr;
sec = now/1000000;
min = sec/60;
hr = sec/3600;
uint32_t now = xtimer_now_usec();
int sec = now / 1000000;
int min = sec / 60;
int hr = sec / 3600;
printf("sec=%d min=%d hour=%d\n", sec, min, hr);
}
}

View File

@ -29,10 +29,10 @@
int main(void)
{
uint32_t n = ITERATIONS;
uint64_t before = xtimer_now64();
uint64_t before = _xtimer_now64();
while(--n) {
uint64_t now = xtimer_now64();
uint64_t now = _xtimer_now64();
if ((now-before) > MAXDIFF) {
puts("TEST FAILED.");
break;

View File

@ -37,13 +37,13 @@ int main(void)
int32_t min_diff = INT32_MAX;
for (int i = 0; i < NUMOF; i++) {
uint32_t now = xtimer_now();
printf("Testing interval %" PRIu32 "... (now=%" PRIu32 ")\n", interval, now);
uint32_t last_wakeup = xtimer_now();
uint32_t before = last_wakeup;
xtimer_ticks32_t now = xtimer_now();
printf("Testing interval %" PRIu32 "... (now=%" PRIu32 ")\n", interval, xtimer_usec_from_ticks(now));
xtimer_ticks32_t last_wakeup = xtimer_now();
xtimer_ticks32_t before = last_wakeup;
xtimer_periodic_wakeup(&last_wakeup, interval);
now = xtimer_now();
res[i] = (now - before) - interval;
res[i] = (xtimer_usec_from_ticks(now) - xtimer_usec_from_ticks(before)) - interval;
interval -= 1;
}

View File

@ -48,11 +48,11 @@ int main(void)
xtimer_set_wakeup(&xtimer, 200000, me);
xtimer_set_wakeup(&xtimer2, 100000, me);
printf("now=%" PRIu32 "\n", xtimer_now());
printf("now=%" PRIu32 "\n", xtimer_now_usec());
thread_sleep();
printf("now=%" PRIu32 "\n", xtimer_now());
printf("now=%" PRIu32 "\n", xtimer_now_usec());
thread_sleep();
printf("now=%" PRIu32 "\n", xtimer_now());
printf("now=%" PRIu32 "\n", xtimer_now_usec());
printf("Test completed!\n");