mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
drivers/dsp0401: migrate to ztimer
This commit is contained in:
parent
68e1d29e90
commit
f47db6f2c2
@ -12,4 +12,5 @@ config MODULE_DSP0401
|
|||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
select MODULE_PERIPH_GPIO
|
select MODULE_PERIPH_GPIO
|
||||||
select MODULE_PERIPH_PWM
|
select MODULE_PERIPH_PWM
|
||||||
select MODULE_XTIMER
|
select MODULE_ZTIMER
|
||||||
|
select MODULE_ZTIMER_USEC
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
USEMODULE += xtimer
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_usec
|
||||||
FEATURES_REQUIRED += periph_gpio
|
FEATURES_REQUIRED += periph_gpio
|
||||||
FEATURES_REQUIRED += periph_pwm
|
FEATURES_REQUIRED += periph_pwm
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "dsp0401.h"
|
#include "dsp0401.h"
|
||||||
#include "xtimer.h"
|
#include "timex.h"
|
||||||
|
#include "ztimer.h"
|
||||||
#include "periph/gpio.h"
|
#include "periph/gpio.h"
|
||||||
#include "periph/pwm.h"
|
#include "periph/pwm.h"
|
||||||
|
|
||||||
@ -164,11 +165,11 @@ static void _shift_char(const dsp0401_t *dev, uint8_t c)
|
|||||||
|
|
||||||
static void _latch(const dsp0401_t *dev)
|
static void _latch(const dsp0401_t *dev)
|
||||||
{
|
{
|
||||||
xtimer_usleep(LATCH_DELAY);
|
ztimer_sleep(ZTIMER_USEC, LATCH_DELAY);
|
||||||
gpio_set(LAT);
|
gpio_set(LAT);
|
||||||
xtimer_usleep(LATCH_DELAY);
|
ztimer_sleep(ZTIMER_USEC, LATCH_DELAY);
|
||||||
gpio_clear(LAT);
|
gpio_clear(LAT);
|
||||||
xtimer_usleep(LATCH_DELAY);
|
ztimer_sleep(ZTIMER_USEC, LATCH_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dsp0401_init(dsp0401_t *dev, const dsp0401_params_t *params)
|
int dsp0401_init(dsp0401_t *dev, const dsp0401_params_t *params)
|
||||||
@ -238,12 +239,12 @@ void dsp0401_scroll_text(const dsp0401_t *dev, char *text, uint16_t delay)
|
|||||||
for (unsigned i = 0; i < strlen(text); ++i) {
|
for (unsigned i = 0; i < strlen(text); ++i) {
|
||||||
_shift_char(dev, text[i]);
|
_shift_char(dev, text[i]);
|
||||||
_latch(dev);
|
_latch(dev);
|
||||||
xtimer_msleep(delay);
|
ztimer_sleep(ZTIMER_USEC, delay * US_PER_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < MOD_COUNT * 4; ++i) {
|
for (unsigned i = 0; i < MOD_COUNT * 4; ++i) {
|
||||||
_shift_char(dev, ' ');
|
_shift_char(dev, ' ');
|
||||||
_latch(dev);
|
_latch(dev);
|
||||||
xtimer_msleep(delay);
|
ztimer_sleep(ZTIMER_USEC, delay * US_PER_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += dsp0401
|
USEMODULE += dsp0401
|
||||||
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_usec
|
||||||
|
|
||||||
LOOPS ?= 3
|
LOOPS ?= 3
|
||||||
CFLAGS += -DLOOPS=$(LOOPS)
|
CFLAGS += -DLOOPS=$(LOOPS)
|
||||||
|
@ -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_DSP0401=y
|
CONFIG_MODULE_DSP0401=y
|
||||||
|
CONFIG_MODULE_ZTIMER=y
|
||||||
|
CONFIG_MODULE_ZTIMER_USEC=y
|
||||||
|
@ -23,11 +23,12 @@
|
|||||||
|
|
||||||
#include "dsp0401_params.h"
|
#include "dsp0401_params.h"
|
||||||
#include "dsp0401.h"
|
#include "dsp0401.h"
|
||||||
#include "xtimer.h"
|
#include "timex.h"
|
||||||
|
#include "ztimer.h"
|
||||||
|
|
||||||
#define TEST_DELAY (2U) /* 2 seconds delay between each test */
|
#define TEST_DELAY_US (2U * US_PER_SEC) /* 2 seconds delay between each test */
|
||||||
#define WORD_DELAY (750U) /* 750 milliseconds delay between each word */
|
#define WORD_DELAY_US (750U * US_PER_MS) /* 750 milliseconds delay between each word */
|
||||||
#define SCROLL_DELAY (200U) /* 200 milliseconds delay between character shift */
|
#define SCROLL_DELAY_MS (200U) /* 200 milliseconds delay between character shift */
|
||||||
#ifndef LOOPS
|
#ifndef LOOPS
|
||||||
#define LOOPS (3U) /* Number of display loops before exit */
|
#define LOOPS (3U) /* Number of display loops before exit */
|
||||||
#endif
|
#endif
|
||||||
@ -49,19 +50,19 @@ int main(void)
|
|||||||
while (loop < LOOPS) {
|
while (loop < LOOPS) {
|
||||||
puts("[INFO] Displaying 'THIS IS RIOT'");
|
puts("[INFO] Displaying 'THIS IS RIOT'");
|
||||||
dsp0401_display_text(&dev, (char*)"THIS");
|
dsp0401_display_text(&dev, (char*)"THIS");
|
||||||
xtimer_msleep(WORD_DELAY);
|
ztimer_sleep(ZTIMER_USEC, WORD_DELAY_US);
|
||||||
dsp0401_display_text(&dev, (char*)" IS ");
|
dsp0401_display_text(&dev, (char*)" IS ");
|
||||||
xtimer_msleep(WORD_DELAY);
|
ztimer_sleep(ZTIMER_USEC, WORD_DELAY_US);
|
||||||
dsp0401_display_text(&dev, (char*)"RIOT");
|
dsp0401_display_text(&dev, (char*)"RIOT");
|
||||||
xtimer_sleep(TEST_DELAY);
|
ztimer_sleep(ZTIMER_USEC, TEST_DELAY_US);
|
||||||
|
|
||||||
puts("[INFO] Clearing text!");
|
puts("[INFO] Clearing text!");
|
||||||
dsp0401_clear_text(&dev);
|
dsp0401_clear_text(&dev);
|
||||||
xtimer_sleep(TEST_DELAY);
|
ztimer_sleep(ZTIMER_USEC, TEST_DELAY_US);
|
||||||
|
|
||||||
puts("[INFO] Scrolling 'THIS IS RIOT'");
|
puts("[INFO] Scrolling 'THIS IS RIOT'");
|
||||||
dsp0401_scroll_text(&dev, (char*)("THIS IS RIOT"), SCROLL_DELAY);
|
dsp0401_scroll_text(&dev, (char*)("THIS IS RIOT"), SCROLL_DELAY_MS);
|
||||||
xtimer_sleep(TEST_DELAY);
|
ztimer_sleep(ZTIMER_USEC, TEST_DELAY_US);
|
||||||
puts("[INFO] Done\n");
|
puts("[INFO] Done\n");
|
||||||
++loop;
|
++loop;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user