Skip to content

Commit b824e41

Browse files
jakubtopicnashif
authored andcommitted
drivers: rtc: rv3028: adjust timing of EEPROM requests
Removes calling k_busy_wait() and uses k_msleep(). Updates polling rate of EEPROM busy status after read request to 1 ms, as recommended by the app note. Signed-off-by: Jakub Topic <[email protected]>
1 parent 7ff72ee commit b824e41

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/rtc/rtc_rv3028.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ LOG_MODULE_REGISTER(rv3028, CONFIG_RTC_LOG_LEVEL);
123123
/* The RV3028 enumerates months 1 to 12 */
124124
#define RV3028_MONTH_OFFSET 1
125125

126-
#define RV3028_EEBUSY_POLL_US 10000
126+
#define RV3028_EEBUSY_READ_POLL_MS 1
127+
#define RV3028_EEBUSY_WRITE_POLL_MS 10
127128
#define RV3028_EEBUSY_TIMEOUT_MS 100
128129

129130
/* RTC alarm time fields supported by the RV3028 */
@@ -240,7 +241,7 @@ static int rv3028_update_reg8(const struct device *dev, uint8_t addr, uint8_t ma
240241
return 0;
241242
}
242243

243-
static int rv3028_eeprom_wait_busy(const struct device *dev)
244+
static int rv3028_eeprom_wait_busy(const struct device *dev, int poll_ms)
244245
{
245246
uint8_t status = 0;
246247
int err;
@@ -261,7 +262,7 @@ static int rv3028_eeprom_wait_busy(const struct device *dev)
261262
return -ETIME;
262263
}
263264

264-
k_busy_wait(RV3028_EEBUSY_POLL_US);
265+
k_msleep(poll_ms);
265266
}
266267

267268
return 0;
@@ -291,7 +292,7 @@ static int rv3028_enter_eerd(const struct device *dev)
291292
ret = rv3028_update_reg8(dev, RV3028_REG_CONTROL1, RV3028_CONTROL1_EERD,
292293
RV3028_CONTROL1_EERD);
293294

294-
ret = rv3028_eeprom_wait_busy(dev);
295+
ret = rv3028_eeprom_wait_busy(dev, RV3028_EEBUSY_WRITE_POLL_MS);
295296
if (ret) {
296297
rv3028_exit_eerd(dev);
297298
return ret;
@@ -321,7 +322,7 @@ static int rv3028_update(const struct device *dev)
321322
goto exit_eerd;
322323
}
323324

324-
err = rv3028_eeprom_wait_busy(dev);
325+
err = rv3028_eeprom_wait_busy(dev, RV3028_EEBUSY_WRITE_POLL_MS);
325326

326327
exit_eerd:
327328
rv3028_exit_eerd(dev);
@@ -338,7 +339,7 @@ static int rv3028_refresh(const struct device *dev)
338339
goto exit_eerd;
339340
}
340341

341-
err = rv3028_eeprom_wait_busy(dev);
342+
err = rv3028_eeprom_wait_busy(dev, RV3028_EEBUSY_READ_POLL_MS);
342343

343344
exit_eerd:
344345
rv3028_exit_eerd(dev);
@@ -691,7 +692,7 @@ static int rv3028_alarm_set_callback(const struct device *dev, uint16_t id,
691692
#else
692693
const struct rv3028_config *config = dev->config;
693694
struct rv3028_data *data = dev->data;
694-
int err = 0;
695+
int err;
695696

696697
if (config->gpio_int.port == NULL) {
697698
return -ENOTSUP;

0 commit comments

Comments
 (0)