mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/pn532: migrate to ztimer
This commit is contained in:
parent
d9fe3a74e5
commit
38c2ea57aa
@ -26,6 +26,8 @@ config MODULE_PN532
|
||||
bool
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
endmenu # PN532 NFC reader
|
||||
|
||||
|
@ -1,2 +1,5 @@
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "assert.h"
|
||||
#include "kernel_defines.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
#include "mutex.h"
|
||||
#include "pn532.h"
|
||||
#include "periph/gpio.h"
|
||||
@ -63,8 +63,8 @@
|
||||
|
||||
/* Constants and magic numbers */
|
||||
#define MIFARE_CLASSIC_BLOCK_SIZE (16)
|
||||
#define RESET_TOGGLE_SLEEP (400000)
|
||||
#define RESET_BACKOFF (10000)
|
||||
#define RESET_TOGGLE_SLEEP_MS (400)
|
||||
#define RESET_BACKOFF_MS (10)
|
||||
#define HOST_TO_PN532 (0xD4)
|
||||
#define PN532_TO_HOST (0xD5)
|
||||
#define SPI_DATA_WRITE (0x80)
|
||||
@ -104,9 +104,9 @@ void pn532_reset(const pn532_t *dev)
|
||||
|
||||
DEBUG("pn532: reset\n");
|
||||
gpio_clear(dev->conf->reset);
|
||||
xtimer_usleep(RESET_TOGGLE_SLEEP);
|
||||
ztimer_sleep(ZTIMER_MSEC, RESET_TOGGLE_SLEEP_MS);
|
||||
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)
|
||||
|
@ -1,6 +1,7 @@
|
||||
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:
|
||||
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_SPI=y
|
||||
|
||||
CONFIG_MODULE_XTIMER=y
|
||||
CONFIG_MODULE_ZTIMER=y
|
||||
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "pn532.h"
|
||||
#include "pn532_params.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#define LOG_LEVEL LOG_INFO
|
||||
#include "log.h"
|
||||
@ -53,7 +53,7 @@ int main(void)
|
||||
LOG_INFO("init error %d\n", ret);
|
||||
}
|
||||
|
||||
xtimer_usleep(200000);
|
||||
ztimer_sleep(ZTIMER_MSEC, 200);
|
||||
LOG_INFO("awake\n");
|
||||
|
||||
uint32_t fwver;
|
||||
@ -65,7 +65,7 @@ int main(void)
|
||||
|
||||
while (1) {
|
||||
/* Delay not to be always polling the interface */
|
||||
xtimer_usleep(250000UL);
|
||||
ztimer_sleep(ZTIMER_MSEC, 250);
|
||||
|
||||
ret = pn532_get_passive_iso14443a(&pn532, &card, 0x50);
|
||||
if (ret < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user