Skip to content
Permalink
Browse files

drivers: rtc: Adapt to new counter API

The counter API changed recently, and more specifically the
counter_set_top_value() now takes a configuration structure instead of
direct parameters. Adapt the rtc.h header so that it uses the new
signature correctly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
  • Loading branch information...
carlescufi authored and galak committed Jun 28, 2019
1 parent e5e45af commit ee040e9e5461286ec576a24123f7b6569366a89c
Showing with 15 additions and 4 deletions.
  1. +15 −4 include/drivers/rtc.h
@@ -92,14 +92,19 @@ static inline void rtc_counter_top_callback(struct device *dev,
__deprecated static inline int rtc_set_config(struct device *dev,
struct rtc_config *cfg)
{
struct counter_top_cfg top_cfg = {
.ticks = cfg->alarm_val,
.callback = rtc_counter_top_callback,
.user_data = cfg->cb_fn,
.flags = 0
};
int err;

if (cfg->init_val) {
return -ENOTSUP;
}

err = counter_set_top_value(dev, cfg->alarm_val,
rtc_counter_top_callback, cfg->cb_fn);
err = counter_set_top_value(dev, &top_cfg);

if (err == 0 && cfg->alarm_enable != 0U) {
err = counter_start(dev);
@@ -114,8 +119,14 @@ __deprecated __syscall int rtc_set_alarm(struct device *dev,
static inline int z_impl_rtc_set_alarm(struct device *dev,
const u32_t alarm_val)
{
return counter_set_top_value(dev, alarm_val, rtc_counter_top_callback,
counter_get_user_data(dev));
struct counter_top_cfg top_cfg = {
.ticks = alarm_val,
.callback = rtc_counter_top_callback,
.user_data = counter_get_user_data(dev),
.flags = 0
};

return counter_set_top_value(dev, &top_cfg);
}

/**

0 comments on commit ee040e9

Please sign in to comment.
You can’t perform that action at this time.