11/*
2- * Copyright (C) 2017 Frits Kuipers
3- * 2018 HAW Hamburg
4- *
5- * This file is subject to the terms and conditions of the GNU Lesser
6- * General Public License v2.1. See the file LICENSE in the top level
7- * directory for more details.
2+ * SPDX-FileCopyrightText: 2017 Frits Kuipers
3+ * SPDX-FileCopyrightText: 2018 HAW Hamburg
4+ * SPDX-License-Identifier: LGPL-2.1-only
85 */
96
107/**
2522
2623#include "log.h"
2724#include "periph/gpio.h"
28- #include "xtimer .h"
25+ #include "ztimer .h"
2926
3027#define ENABLE_DEBUG 0
3128#include "debug.h"
@@ -54,9 +51,9 @@ static void ds18_write_bit(const ds18_t *dev, uint8_t bit)
5451 }
5552
5653 /* Wait for slot to end */
57- xtimer_usleep ( DS18_DELAY_SLOT );
54+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_SLOT );
5855 ds18_release (dev );
59- xtimer_usleep ( 1 );
56+ ztimer_sleep ( ZTIMER_USEC , 1 );
6057}
6158
6259static int ds18_read_bit (const ds18_t * dev , uint8_t * bit )
@@ -66,17 +63,17 @@ static int ds18_read_bit(const ds18_t *dev, uint8_t *bit)
6663 ds18_release (dev );
6764
6865#if defined(MODULE_DS18_OPTIMIZED )
69- xtimer_usleep ( DS18_SAMPLE_TIME );
66+ ztimer_sleep ( ZTIMER_USEC , DS18_SAMPLE_TIME );
7067 * bit = gpio_read (dev -> params .pin );
71- xtimer_usleep ( DS18_DELAY_R_RECOVER );
68+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_R_RECOVER );
7269 return DS18_OK ;
7370#else
7471 uint32_t start , measurement = 0 ;
7572
7673 /* Measure time low of device pin, timeout after slot time*/
77- start = xtimer_now_usec ( );
74+ start = ztimer_now ( ZTIMER_USEC );
7875 while (!gpio_read (dev -> params .pin ) && measurement < DS18_DELAY_SLOT ) {
79- measurement = xtimer_now_usec ( ) - start ;
76+ measurement = ztimer_now ( ZTIMER_USEC ) - start ;
8077 }
8178
8279 /* If there was a timeout return error */
@@ -88,7 +85,7 @@ static int ds18_read_bit(const ds18_t *dev, uint8_t *bit)
8885 * bit = measurement < DS18_SAMPLE_TIME ;
8986
9087 /* Wait for slot to end */
91- xtimer_usleep ( DS18_DELAY_SLOT - measurement );
88+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_SLOT - measurement );
9289
9390 return DS18_OK ;
9491#endif
@@ -124,17 +121,17 @@ static int ds18_reset(const ds18_t *dev)
124121
125122 /* Line low and sleep the reset delay */
126123 ds18_low (dev );
127- xtimer_usleep ( DS18_DELAY_RESET );
124+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_RESET );
128125
129126 /* Release and wait for the presence response */
130127 ds18_release (dev );
131- xtimer_usleep ( DS18_DELAY_PRESENCE );
128+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_PRESENCE );
132129
133130 /* Check device presence */
134131 res = gpio_read (dev -> params .pin );
135132
136133 /* Sleep for reset delay */
137- xtimer_usleep ( DS18_DELAY_RESET );
134+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_RESET );
138135
139136 return res ;
140137}
@@ -199,7 +196,7 @@ int ds18_get_temperature(const ds18_t *dev, int16_t *temperature)
199196 }
200197
201198 DEBUG ("[DS18] Wait for convert T\n" );
202- xtimer_usleep ( DS18_DELAY_CONVERT );
199+ ztimer_sleep ( ZTIMER_USEC , DS18_DELAY_CONVERT );
203200
204201 return ds18_read (dev , temperature );
205202}
0 commit comments