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

examples/twr_aloha: use ZTIMER_MSEC

This commit is contained in:
Francisco Molina 2021-07-05 14:31:52 +02:00
parent 701891e7e3
commit 3d2deacddb
No known key found for this signature in database
GPG Key ID: 3E94EAC3DBDEEDA8
3 changed files with 9 additions and 9 deletions

View File

@ -28,6 +28,7 @@ USEMODULE += uwb-core_twr_ds_ext
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
USEMODULE += ztimer_usec
# Set the device role: 0x0 for tag, 0x4 for an anchor
DW1000_ROLE ?= 0x00

View File

@ -29,7 +29,6 @@
#include "shell_commands.h"
#include "shell.h"
#include "xtimer.h"
static struct dpl_callout _rng_req_callout;
static uint8_t _ranging_enabled_flag;
@ -46,7 +45,7 @@ static int _range_cli_cmd(int argc, char **argv)
if (!strcmp(argv[1], "start")) {
printf("Start ranging\n");
dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_US);
dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_MS);
_ranging_enabled_flag = 1;
}
else if (!strcmp(argv[1], "stop")) {
@ -150,12 +149,12 @@ static void _slot_complete_cb(struct dpl_event *ev)
}
/**
* @brief An event callback to send range request every RANGE_REQUEST_T_US.
* @brief An event callback to send range request every RANGE_REQUEST_T_MS.
* On every request it will switch the used ranging algorithm.
*/
static void uwb_ev_cb(struct dpl_event *ev)
{
struct uwb_rng_instance *rng = (struct uwb_rng_instance *)ev->arg;
struct uwb_rng_instance *rng = (struct uwb_rng_instance *)ev->ev.arg;
struct uwb_dev *inst = rng->dev_inst;
if (inst->role & UWB_ROLE_ANCHOR) {
@ -195,7 +194,7 @@ static void uwb_ev_cb(struct dpl_event *ev)
/* reset the callback if ranging is enabled */
if (_ranging_enabled_flag) {
dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_US);
dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_MS);
}
}
@ -211,7 +210,7 @@ void init_ranging(void)
_uwb_mac_cbs.inst_ptr = rng;
uwb_mac_append_interface(udev, &_uwb_mac_cbs);
uint32_t utime = xtimer_now_usec();
uint32_t utime = ztimer_now(ZTIMER_USEC);
printf("{\"utime\": %" PRIu32 ",\"exec\": \"%s\"}\n", utime, __FILE__);
printf("{\"device_id\"=\"%" PRIx32 "\"", udev->device_id);
@ -235,7 +234,7 @@ void init_ranging(void)
dpl_callout_init(&_rng_req_callout, dpl_eventq_dflt_get(),
uwb_ev_cb, rng);
dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_US);
dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_MS);
dpl_event_init(&_slot_event, _slot_complete_cb, rng);
/* Apply config */

View File

@ -37,8 +37,8 @@ extern "C" {
/**
* @brief Range request period
*/
#ifndef RANGE_REQUEST_T_US
#define RANGE_REQUEST_T_US (40 * US_PER_MS)
#ifndef RANGE_REQUEST_T_MS
#define RANGE_REQUEST_T_MS (40)
#endif
/**