Merge pull request #17375 from aabadie/pr/drivers/ztimer_ter
drivers: several cleanups related to xtimer + some ztimer migration
This commit is contained in:
commit
7b2ab7d734
@ -10,5 +10,7 @@ config MODULE_AD7746
|
|||||||
depends on HAS_PERIPH_I2C
|
depends on HAS_PERIPH_I2C
|
||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
select MODULE_PERIPH_I2C
|
select MODULE_PERIPH_I2C
|
||||||
|
select MODULE_ZTIMER
|
||||||
|
select MODULE_ZTIMER_MSEC
|
||||||
help
|
help
|
||||||
AD7746 Capacitance-to-digital converter with temperature sensor driver.
|
AD7746 Capacitance-to-digital converter with temperature sensor driver.
|
||||||
|
|||||||
@ -1 +1,3 @@
|
|||||||
FEATURES_REQUIRED += periph_i2c
|
FEATURES_REQUIRED += periph_i2c
|
||||||
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "ztimer.h"
|
||||||
|
|
||||||
#include "ad7746.h"
|
#include "ad7746.h"
|
||||||
#include "ad7746_params.h"
|
#include "ad7746_params.h"
|
||||||
#include "ad7746_internal.h"
|
#include "ad7746_internal.h"
|
||||||
@ -30,8 +32,6 @@
|
|||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "xtimer.h"
|
|
||||||
|
|
||||||
#define DEV (dev->params.i2c)
|
#define DEV (dev->params.i2c)
|
||||||
#define ADDR (dev->params.addr)
|
#define ADDR (dev->params.addr)
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ static int _read_voltage_temp(ad7746_t *dev, int *value, ad7746_vt_mode_t mode)
|
|||||||
/* if a mode change is needed wait for a conversion cycle and flush
|
/* if a mode change is needed wait for a conversion cycle and flush
|
||||||
* the first sample in order to get a stable output. Took from the Linux
|
* the first sample in order to get a stable output. Took from the Linux
|
||||||
* driver implementation */
|
* driver implementation */
|
||||||
xtimer_msleep(_vt_sr_times[dev->params.vt_sample_rate]);
|
ztimer_sleep(ZTIMER_MSEC, _vt_sr_times[dev->params.vt_sample_rate]);
|
||||||
_read_raw_ch(dev, AD7746_READ_VT_CH, &raw);
|
_read_raw_ch(dev, AD7746_READ_VT_CH, &raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
#include "byteorder.h"
|
#include "byteorder.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "timex.h"
|
#include "timex.h"
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
|
|
||||||
#include "lis2dh12.h"
|
#include "lis2dh12.h"
|
||||||
#include "lis2dh12_internal.h"
|
#include "lis2dh12_internal.h"
|
||||||
@ -595,8 +595,8 @@ int lis2dh12_read_temperature(const lis2dh12_t *dev, int16_t *temp)
|
|||||||
if (!_read(dev, REG_TEMP_CFG_REG)) {
|
if (!_read(dev, REG_TEMP_CFG_REG)) {
|
||||||
uint8_t odr = _read(dev, REG_CTRL_REG1) >> 4;
|
uint8_t odr = _read(dev, REG_CTRL_REG1) >> 4;
|
||||||
_write(dev, REG_TEMP_CFG_REG, LIS2DH12_TEMP_CFG_REG_ENABLE);
|
_write(dev, REG_TEMP_CFG_REG, LIS2DH12_TEMP_CFG_REG_ENABLE);
|
||||||
if (IS_USED(MODULE_XTIMER)) {
|
if (IS_USED(MODULE_ZTIMER)) {
|
||||||
xtimer_msleep(MS_PER_SEC / hz_per_dr[odr]);
|
ztimer_sleep(ZTIMER_MSEC, MS_PER_SEC / hz_per_dr[odr]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ config MODULE_LIS3MDL
|
|||||||
depends on HAS_PERIPH_I2C
|
depends on HAS_PERIPH_I2C
|
||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
select MODULE_PERIPH_I2C
|
select MODULE_PERIPH_I2C
|
||||||
select MODULE_XTIMER
|
|
||||||
|
|
||||||
config HAVE_LIS3MDL
|
config HAVE_LIS3MDL
|
||||||
bool
|
bool
|
||||||
|
|||||||
@ -1,2 +1 @@
|
|||||||
FEATURES_REQUIRED += periph_i2c
|
FEATURES_REQUIRED += periph_i2c
|
||||||
USEMODULE += xtimer
|
|
||||||
|
|||||||
@ -26,6 +26,8 @@ config MODULE_PN532
|
|||||||
bool
|
bool
|
||||||
select MODULE_PERIPH_GPIO
|
select MODULE_PERIPH_GPIO
|
||||||
select MODULE_PERIPH_GPIO_IRQ
|
select MODULE_PERIPH_GPIO_IRQ
|
||||||
|
select MODULE_ZTIMER
|
||||||
|
select MODULE_ZTIMER_MSEC
|
||||||
|
|
||||||
endmenu # PN532 NFC reader
|
endmenu # PN532 NFC reader
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,5 @@
|
|||||||
FEATURES_REQUIRED += periph_gpio
|
FEATURES_REQUIRED += periph_gpio
|
||||||
FEATURES_REQUIRED += periph_gpio_irq
|
FEATURES_REQUIRED += periph_gpio_irq
|
||||||
|
|
||||||
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "kernel_defines.h"
|
#include "kernel_defines.h"
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "pn532.h"
|
#include "pn532.h"
|
||||||
#include "periph/gpio.h"
|
#include "periph/gpio.h"
|
||||||
@ -63,8 +63,8 @@
|
|||||||
|
|
||||||
/* Constants and magic numbers */
|
/* Constants and magic numbers */
|
||||||
#define MIFARE_CLASSIC_BLOCK_SIZE (16)
|
#define MIFARE_CLASSIC_BLOCK_SIZE (16)
|
||||||
#define RESET_TOGGLE_SLEEP (400000)
|
#define RESET_TOGGLE_SLEEP_MS (400)
|
||||||
#define RESET_BACKOFF (10000)
|
#define RESET_BACKOFF_MS (10)
|
||||||
#define HOST_TO_PN532 (0xD4)
|
#define HOST_TO_PN532 (0xD4)
|
||||||
#define PN532_TO_HOST (0xD5)
|
#define PN532_TO_HOST (0xD5)
|
||||||
#define SPI_DATA_WRITE (0x80)
|
#define SPI_DATA_WRITE (0x80)
|
||||||
@ -104,9 +104,9 @@ void pn532_reset(const pn532_t *dev)
|
|||||||
|
|
||||||
DEBUG("pn532: reset\n");
|
DEBUG("pn532: reset\n");
|
||||||
gpio_clear(dev->conf->reset);
|
gpio_clear(dev->conf->reset);
|
||||||
xtimer_usleep(RESET_TOGGLE_SLEEP);
|
ztimer_sleep(ZTIMER_MSEC, RESET_TOGGLE_SLEEP_MS);
|
||||||
gpio_set(dev->conf->reset);
|
gpio_set(dev->conf->reset);
|
||||||
xtimer_usleep(RESET_BACKOFF);
|
ztimer_sleep(ZTIMER_MSEC, RESET_BACKOFF_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pn532_init(pn532_t *dev, const pn532_params_t *params, pn532_mode_t mode)
|
int pn532_init(pn532_t *dev, const pn532_params_t *params, pn532_mode_t mode)
|
||||||
|
|||||||
@ -12,4 +12,3 @@ config MODULE_PULSE_COUNTER
|
|||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
select MODULE_PERIPH_GPIO
|
select MODULE_PERIPH_GPIO
|
||||||
select MODULE_PERIPH_GPIO_IRQ
|
select MODULE_PERIPH_GPIO_IRQ
|
||||||
select MODULE_XTIMER
|
|
||||||
|
|||||||
@ -1,2 +1 @@
|
|||||||
USEMODULE += xtimer
|
|
||||||
FEATURES_REQUIRED += periph_gpio_irq
|
FEATURES_REQUIRED += periph_gpio_irq
|
||||||
|
|||||||
@ -11,4 +11,3 @@ config MODULE_SHTC1
|
|||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
select MODULE_PERIPH_I2C
|
select MODULE_PERIPH_I2C
|
||||||
select MODULE_CHECKSUM
|
select MODULE_CHECKSUM
|
||||||
select MODULE_XTIMER
|
|
||||||
|
|||||||
@ -1,3 +1,2 @@
|
|||||||
FEATURES_REQUIRED += periph_i2c
|
FEATURES_REQUIRED += periph_i2c
|
||||||
USEMODULE += xtimer
|
|
||||||
USEMODULE += checksum
|
USEMODULE += checksum
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "checksum/crc8.h"
|
#include "checksum/crc8.h"
|
||||||
#include "sps30.h"
|
#include "sps30.h"
|
||||||
#include "xtimer.h"
|
|
||||||
#include "byteorder.h"
|
#include "byteorder.h"
|
||||||
#include "kernel_defines.h"
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
|
|||||||
@ -15,5 +15,3 @@ endif
|
|||||||
ifneq (,$(filter ws281x_atmega,$(USEMODULE)))
|
ifneq (,$(filter ws281x_atmega,$(USEMODULE)))
|
||||||
FEATURES_REQUIRED += cpu_core_atmega
|
FEATURES_REQUIRED += cpu_core_atmega
|
||||||
endif
|
endif
|
||||||
|
|
||||||
USEMODULE += xtimer
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += ad7746
|
USEMODULE += ad7746
|
||||||
USEMODULE += xtimer
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
# this file enables modules defined in Kconfig. Do not use this file for
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_AD7746=y
|
CONFIG_MODULE_AD7746=y
|
||||||
CONFIG_MODULE_XTIMER=y
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
|
|||||||
@ -20,12 +20,12 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
#include "timex.h"
|
#include "timex.h"
|
||||||
#include "ad7746.h"
|
#include "ad7746.h"
|
||||||
#include "ad7746_params.h"
|
#include "ad7746_params.h"
|
||||||
|
|
||||||
#define SLEEP_USEC (1000 * US_PER_MS)
|
#define SLEEP_MS (MS_PER_SEC)
|
||||||
|
|
||||||
static ad7746_t dev;
|
static ad7746_t dev;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ int main(void)
|
|||||||
printf("Error reading internal temperature\n");
|
printf("Error reading internal temperature\n");
|
||||||
}
|
}
|
||||||
puts("");
|
puts("");
|
||||||
xtimer_usleep(SLEEP_USEC);
|
ztimer_sleep(ZTIMER_MSEC, SLEEP_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -4,7 +4,8 @@ include ../Makefile.tests_common
|
|||||||
DRIVER ?= lis2dh12_spi
|
DRIVER ?= lis2dh12_spi
|
||||||
|
|
||||||
USEMODULE += fmt
|
USEMODULE += fmt
|
||||||
USEMODULE += xtimer
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
USEMODULE += shell
|
USEMODULE += shell
|
||||||
USEMODULE += shell_commands
|
USEMODULE += shell_commands
|
||||||
USEMODULE += $(DRIVER)
|
USEMODULE += $(DRIVER)
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
# this file enables modules defined in Kconfig. Do not use this file for
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_FMT=y
|
CONFIG_MODULE_FMT=y
|
||||||
CONFIG_MODULE_XTIMER=y
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
CONFIG_MODULE_SHELL=y
|
CONFIG_MODULE_SHELL=y
|
||||||
CONFIG_MODULE_SHELL_COMMANDS=y
|
CONFIG_MODULE_SHELL_COMMANDS=y
|
||||||
CONFIG_MODULE_LIS2DH12=y
|
CONFIG_MODULE_LIS2DH12=y
|
||||||
|
|||||||
@ -23,7 +23,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "xtimer.h"
|
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
|||||||
@ -2,6 +2,7 @@ BOARD ?= limifrog-v1
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += lis3mdl
|
USEMODULE += lis3mdl
|
||||||
USEMODULE += xtimer
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
# this file enables modules defined in Kconfig. Do not use this file for
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_LIS3MDL=y
|
CONFIG_MODULE_LIS3MDL=y
|
||||||
CONFIG_MODULE_XTIMER=y
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
|
|||||||
@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "xtimer.h"
|
#include "timex.h"
|
||||||
|
#include "ztimer.h"
|
||||||
#include "lis3mdl.h"
|
#include "lis3mdl.h"
|
||||||
#include "lis3mdl_params.h"
|
#include "lis3mdl_params.h"
|
||||||
|
|
||||||
#define SLEEP_USEC (800 * 800U)
|
#define SLEEP_MS (640U)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@ -54,7 +55,7 @@ int main(void)
|
|||||||
lis3mdl_read_temp(&dev, &temp_value);
|
lis3mdl_read_temp(&dev, &temp_value);
|
||||||
printf("Temperature:\t\t%i°C\n", temp_value);
|
printf("Temperature:\t\t%i°C\n", temp_value);
|
||||||
|
|
||||||
xtimer_usleep(SLEEP_USEC);
|
ztimer_sleep(ZTIMER_MSEC, SLEEP_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += xtimer
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
# select if you want to build the SPI or the I2C version of the driver:
|
# select if you want to build the SPI or the I2C version of the driver:
|
||||||
USEMODULE += pn532_i2c
|
USEMODULE += pn532_i2c
|
||||||
|
|||||||
3
tests/driver_pn532/Makefile.ci
Normal file
3
tests/driver_pn532/Makefile.ci
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
BOARD_INSUFFICIENT_MEMORY := \
|
||||||
|
nucleo-l011k4 \
|
||||||
|
#
|
||||||
@ -5,4 +5,5 @@
|
|||||||
CONFIG_MODULE_PN532_I2C=y
|
CONFIG_MODULE_PN532_I2C=y
|
||||||
# CONFIG_MODULE_PN532_SPI=y
|
# CONFIG_MODULE_PN532_SPI=y
|
||||||
|
|
||||||
CONFIG_MODULE_XTIMER=y
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "pn532.h"
|
#include "pn532.h"
|
||||||
#include "pn532_params.h"
|
#include "pn532_params.h"
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
|
|
||||||
#define LOG_LEVEL LOG_INFO
|
#define LOG_LEVEL LOG_INFO
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -53,7 +53,7 @@ int main(void)
|
|||||||
LOG_INFO("init error %d\n", ret);
|
LOG_INFO("init error %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
xtimer_usleep(200000);
|
ztimer_sleep(ZTIMER_MSEC, 200);
|
||||||
LOG_INFO("awake\n");
|
LOG_INFO("awake\n");
|
||||||
|
|
||||||
uint32_t fwver;
|
uint32_t fwver;
|
||||||
@ -65,7 +65,7 @@ int main(void)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Delay not to be always polling the interface */
|
/* Delay not to be always polling the interface */
|
||||||
xtimer_usleep(250000UL);
|
ztimer_sleep(ZTIMER_MSEC, 250);
|
||||||
|
|
||||||
ret = pn532_get_passive_iso14443a(&pn532, &card, 0x50);
|
ret = pn532_get_passive_iso14443a(&pn532, &card, 0x50);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|||||||
@ -4,4 +4,7 @@ BOARD_BLACKLIST := msb-430 msb-430h telosb z1
|
|||||||
|
|
||||||
USEMODULE += pulse_counter
|
USEMODULE += pulse_counter
|
||||||
|
|
||||||
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
# this file enables modules defined in Kconfig. Do not use this file for
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_PULSE_COUNTER=y
|
CONFIG_MODULE_PULSE_COUNTER=y
|
||||||
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
|
|||||||
@ -20,10 +20,11 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "xtimer.h"
|
#include "timex.h"
|
||||||
|
#include "ztimer.h"
|
||||||
#include "pulse_counter_params.h"
|
#include "pulse_counter_params.h"
|
||||||
|
|
||||||
#define SLEEP_USEC US_PER_SEC
|
#define SLEEP_MS MS_PER_SEC
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@ -45,7 +46,7 @@ int main(void)
|
|||||||
int16_t count = pulse_counter_read_with_reset(&dev);
|
int16_t count = pulse_counter_read_with_reset(&dev);
|
||||||
printf("pulse counter: %d\n", count);
|
printf("pulse counter: %d\n", count);
|
||||||
|
|
||||||
xtimer_usleep(SLEEP_USEC);
|
ztimer_sleep(ZTIMER_MSEC, SLEEP_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -3,6 +3,8 @@ include ../Makefile.tests_common
|
|||||||
DRIVER ?= shtc1
|
DRIVER ?= shtc1
|
||||||
|
|
||||||
USEMODULE += fmt
|
USEMODULE += fmt
|
||||||
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
USEMODULE += $(DRIVER)
|
USEMODULE += $(DRIVER)
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -2,3 +2,5 @@
|
|||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_FMT=y
|
CONFIG_MODULE_FMT=y
|
||||||
CONFIG_MODULE_SHTC1=y
|
CONFIG_MODULE_SHTC1=y
|
||||||
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
|
|||||||
@ -21,10 +21,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "timex.h"
|
||||||
|
#include "ztimer.h"
|
||||||
|
#include "fmt.h"
|
||||||
#include "shtc1.h"
|
#include "shtc1.h"
|
||||||
#include "shtc1_params.h"
|
#include "shtc1_params.h"
|
||||||
#include "xtimer.h"
|
|
||||||
#include "fmt.h"
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@ -55,7 +56,7 @@ int main(void)
|
|||||||
printf("Temperature [°C]: %s\n", str_temp);
|
printf("Temperature [°C]: %s\n", str_temp);
|
||||||
printf(" Humidity [%%rH]: %s\n", str_hum);
|
printf(" Humidity [%%rH]: %s\n", str_hum);
|
||||||
|
|
||||||
xtimer_sleep(2);
|
ztimer_sleep(ZTIMER_MSEC, 2 * MS_PER_SEC);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += sps30
|
USEMODULE += sps30
|
||||||
USEMODULE += xtimer
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
CFLAGS+=-DPARAM_SPS30_I2C=I2C_DEV\(0\)
|
CFLAGS+=-DPARAM_SPS30_I2C=I2C_DEV\(0\)
|
||||||
CFLAGS+=-DI2C0_SPEED=I2C_SPEED_NORMAL
|
CFLAGS+=-DI2C0_SPEED=I2C_SPEED_NORMAL
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
# this file enables modules defined in Kconfig. Do not use this file for
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_SPS30=y
|
CONFIG_MODULE_SPS30=y
|
||||||
CONFIG_MODULE_XTIMER=y
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||||
|
|||||||
@ -18,15 +18,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "xtimer.h"
|
#include "timex.h"
|
||||||
|
#include "ztimer.h"
|
||||||
#include "sps30.h"
|
#include "sps30.h"
|
||||||
#include "sps30_params.h"
|
#include "sps30_params.h"
|
||||||
|
|
||||||
#define TEST_START_DELAY_S (2U)
|
#define TEST_START_DELAY_MS (2 * MS_PER_SEC)
|
||||||
#define SENSOR_RESET_DELAY_S (10U)
|
#define SENSOR_RESET_DELAY_MS (10 * MS_PER_SEC)
|
||||||
#define SENSOR_STARTUP_DELAY_S (10U)
|
#define SENSOR_STARTUP_DELAY_MS (10 * MS_PER_SEC)
|
||||||
#define SENSOR_SLEEP_WAKE_DELAY_S (5U)
|
#define SENSOR_SLEEP_WAKE_DELAY_MS (5 * MS_PER_SEC)
|
||||||
#define POLL_FOR_READY_S (1U)
|
#define POLL_FOR_READY_MS (1 * MS_PER_SEC)
|
||||||
#define NUM_OF_MEASUREMENTS (10U)
|
#define NUM_OF_MEASUREMENTS (10U)
|
||||||
|
|
||||||
#define TYPE_MC_STR "MC PM"
|
#define TYPE_MC_STR "MC PM"
|
||||||
@ -62,7 +63,7 @@ int main(void)
|
|||||||
bool error = false;
|
bool error = false;
|
||||||
unsigned cnt = NUM_OF_MEASUREMENTS;
|
unsigned cnt = NUM_OF_MEASUREMENTS;
|
||||||
|
|
||||||
xtimer_sleep(TEST_START_DELAY_S);
|
ztimer_sleep(ZTIMER_MSEC, TEST_START_DELAY_MS);
|
||||||
|
|
||||||
puts("SPS30 test application\n");
|
puts("SPS30 test application\n");
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ int main(void)
|
|||||||
error |= _print_error("start_fan_clean", ec);
|
error |= _print_error("start_fan_clean", ec);
|
||||||
|
|
||||||
/* wait long enough for the fan clean to be done and the fan to settle */
|
/* wait long enough for the fan clean to be done and the fan to settle */
|
||||||
xtimer_sleep(2 * SPS30_FAN_CLEAN_S);
|
ztimer_sleep(ZTIMER_MSEC, 2 * SPS30_FAN_CLEAN_S);
|
||||||
|
|
||||||
/* read the currently set value from the sensor */
|
/* read the currently set value from the sensor */
|
||||||
ec = sps30_read_ac_interval(&dev, &ci);
|
ec = sps30_read_ac_interval(&dev, &ci);
|
||||||
@ -101,23 +102,23 @@ int main(void)
|
|||||||
ec = sps30_reset(&dev);
|
ec = sps30_reset(&dev);
|
||||||
error |= _print_error("reset", ec);
|
error |= _print_error("reset", ec);
|
||||||
|
|
||||||
xtimer_sleep(SENSOR_RESET_DELAY_S);
|
ztimer_sleep(ZTIMER_MSEC, SENSOR_RESET_DELAY_MS);
|
||||||
|
|
||||||
/* Put the sensor in sleep */
|
/* Put the sensor in sleep */
|
||||||
ec = sps30_sleep(&dev);
|
ec = sps30_sleep(&dev);
|
||||||
error |= _print_error("sleep", ec);
|
error |= _print_error("sleep", ec);
|
||||||
xtimer_sleep(SENSOR_SLEEP_WAKE_DELAY_S);
|
ztimer_sleep(ZTIMER_MSEC, SENSOR_SLEEP_WAKE_DELAY_MS);
|
||||||
|
|
||||||
/* Wake-up the sensor */
|
/* Wake-up the sensor */
|
||||||
ec = sps30_wakeup(&dev);
|
ec = sps30_wakeup(&dev);
|
||||||
error |= _print_error("wake-up", ec);
|
error |= _print_error("wake-up", ec);
|
||||||
xtimer_sleep(SENSOR_SLEEP_WAKE_DELAY_S);
|
ztimer_sleep(ZTIMER_MSEC, SENSOR_SLEEP_WAKE_DELAY_MS);
|
||||||
|
|
||||||
/* start the sensor again again... */
|
/* start the sensor again again... */
|
||||||
ec = sps30_start_measurement(&dev);
|
ec = sps30_start_measurement(&dev);
|
||||||
error |= _print_error("start_measurement", ec);
|
error |= _print_error("start_measurement", ec);
|
||||||
|
|
||||||
xtimer_sleep(SENSOR_STARTUP_DELAY_S);
|
ztimer_sleep(ZTIMER_MSEC, SENSOR_STARTUP_DELAY_MS);
|
||||||
|
|
||||||
ec = sps30_read_ac_interval(&dev, &ci);
|
ec = sps30_read_ac_interval(&dev, &ci);
|
||||||
error |= _print_error("read_ac_interval", ec);
|
error |= _print_error("read_ac_interval", ec);
|
||||||
@ -141,7 +142,7 @@ int main(void)
|
|||||||
cnt--; /* if errors happen, stop after NUM_OF_MEASUREMENTS */
|
cnt--; /* if errors happen, stop after NUM_OF_MEASUREMENTS */
|
||||||
}
|
}
|
||||||
/* try again after some time */
|
/* try again after some time */
|
||||||
xtimer_sleep(POLL_FOR_READY_S);
|
ztimer_sleep(ZTIMER_MSEC, POLL_FOR_READY_MS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ PIN ?= GPIO_PIN(0, 0)
|
|||||||
N ?= 8
|
N ?= 8
|
||||||
|
|
||||||
USEMODULE += ws281x
|
USEMODULE += ws281x
|
||||||
|
USEMODULE += xtimer
|
||||||
|
|
||||||
# Only AVR boards CPU clocked at 8MHz or 16 MHz are supported. The Waspmote Pro
|
# Only AVR boards CPU clocked at 8MHz or 16 MHz are supported. The Waspmote Pro
|
||||||
# is clocked at 14.7456 MHz :-/
|
# is clocked at 14.7456 MHz :-/
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
# this file enables modules defined in Kconfig. Do not use this file for
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
# application configuration. This is only needed during migration.
|
# application configuration. This is only needed during migration.
|
||||||
CONFIG_MODULE_WS281X=y
|
CONFIG_MODULE_WS281X=y
|
||||||
|
CONFIG_MODULE_XTIMER=y
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user