Skip to content

Commit

Permalink
Merge pull request #17361 from fjmolinas/pr_sdcard_ztimer
Browse files Browse the repository at this point in the history
drivers/sdcard_spi: convert to ztimer_usec
  • Loading branch information
bergzand authored Dec 9, 2021
2 parents eba1f09 + 9747204 commit d0eb8e2
Show file tree
Hide file tree
Showing 7 changed files with 367 additions and 327 deletions.
2 changes: 1 addition & 1 deletion drivers/sdcard_spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ config MODULE_SDCARD_SPI
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_SPI
select MODULE_PERIPH_SPI_RECONFIGURE if HAS_PERIPH_SPI_RECONFIGURE
select MODULE_XTIMER
select MODULE_CHECKSUM
select ZTIMER_USEC
3 changes: 2 additions & 1 deletion drivers/sdcard_spi/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FEATURES_REQUIRED += periph_gpio
FEATURES_REQUIRED += periph_spi
FEATURES_OPTIONAL += periph_spi_reconfigure
USEMODULE += checksum
USEMODULE += xtimer
USEMODULE += ztimer
USEMODULE += ztimer_usec
1 change: 1 addition & 0 deletions drivers/sdcard_spi/include/sdcard_spi_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern "C" {
#include "periph/gpio.h"
#include "stdbool.h"
#include "sdcard_spi.h"
#include "timex.h"

/* number of clocks that should be applied to the card on init
before taking further actions (see sd spec. 6.4.1.1 Power Up Time of Card) */
Expand Down
665 changes: 350 additions & 315 deletions drivers/sdcard_spi/sdcard_spi.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/driver_io1_xplained/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../Makefile.tests_common

USEMODULE += io1_xplained
USEMODULE += xtimer
USEMODULE += ztimer_msec

include $(RIOTBASE)/Makefile.include
2 changes: 2 additions & 0 deletions tests/driver_io1_xplained/app.config.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
CONFIG_MODULE_IO1_XPLAINED=y
CONFIG_MODULE_AT30TSE75X=y
CONFIG_MODULE_SDCARD_SPI=y
CONFIG_MODULE_ZTIMER=y
CONFIG_MODULE_ZTIMER_MSEC=y
19 changes: 10 additions & 9 deletions tests/driver_io1_xplained/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include <stdio.h>
#include <inttypes.h>

#include "xtimer.h"
#include "timex.h"
#include "ztimer.h"
#include "board.h"

#include "periph/gpio.h"
Expand All @@ -31,7 +32,7 @@
#include "io1_xplained.h"
#include "io1_xplained_params.h"

#define DELAY_1S (1U) /* 1 seconds delay between each test */
#define DELAY_1S (1U * MS_PER_SEC) /* 1 seconds delay between each test */

static io1_xplained_t dev;

Expand Down Expand Up @@ -71,36 +72,36 @@ int main(void)
"+-------------------------------------+\n",
(int)temperature,
(unsigned)((temperature - (int)temperature) * 1000));
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);

/* Card detect pin is inverted */
if (!gpio_read(IO1_SDCARD_SPI_PARAM_DETECT)) {
_sd_card_cid();
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);
}

uint16_t light;
io1_xplained_read_light_level(&light);
printf("Light level: %i\n"
"+-------------------------------------+\n",
light);
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);

/* set led */
gpio_set(IO1_LED_PIN);
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);

/* clear led */
gpio_clear(IO1_LED_PIN);
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);

/* toggle led */
gpio_toggle(IO1_LED_PIN);
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);

/* toggle led again */
gpio_toggle(IO1_LED_PIN);
xtimer_sleep(DELAY_1S);
ztimer_sleep(ZTIMER_MSEC, DELAY_1S);
}

return 0;
Expand Down

0 comments on commit d0eb8e2

Please sign in to comment.