Skip to content

Commit

Permalink
samples: boards: nrf: clock_skew: update k_work API
Browse files Browse the repository at this point in the history
Trivial transformation for a periodic task.

Signed-off-by: Peter Bigot <[email protected]>
  • Loading branch information
pabigot authored and galak committed Apr 19, 2021
1 parent e3a25b3 commit 50cf28a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions samples/boards/nrf/clock_skew/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static const struct device *timer0;
static struct timeutil_sync_config sync_config;
static uint64_t counter_ref;
static struct timeutil_sync_state sync_state;
static struct k_delayed_work sync_work;
static struct k_work_delayable sync_work;

/* Convert local time in ticks to microseconds. */
uint64_t local_to_us(uint64_t local)
Expand Down Expand Up @@ -192,7 +192,8 @@ static void sync_work_handler(struct k_work *work)
printf("Sync update error: %d\n", rc);
}
}
k_delayed_work_submit(&sync_work, K_SECONDS(UPDATE_INTERVAL_S));
(void)k_work_schedule(k_work_delayable_from_work(work),
K_SECONDS(UPDATE_INTERVAL_S));
}

void main(void)
Expand Down Expand Up @@ -253,8 +254,8 @@ void main(void)
printf("Timer wraps every %u s\n",
(uint32_t)(BIT64(32) / sync_config.ref_Hz));

k_delayed_work_init(&sync_work, sync_work_handler);
rc = k_delayed_work_submit(&sync_work, K_NO_WAIT);
k_work_init_delayable(&sync_work, sync_work_handler);
rc = k_work_schedule(&sync_work, K_NO_WAIT);

printk("Started sync: %d\n", rc);
}

0 comments on commit 50cf28a

Please sign in to comment.