timer.c 636 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "wasm_app.h"
  6. /* User global variable */
  7. static int num = 0;
  8. /* Timer callback */
  9. void timer1_update(user_timer_t timer)
  10. {
  11. printf("Timer update %d\n", num++);
  12. }
  13. void on_init()
  14. {
  15. user_timer_t timer;
  16. /* set up a timer */
  17. timer = api_timer_create(1000, true, false, timer1_update);
  18. api_timer_restart(timer, 1000);
  19. }
  20. void on_destroy()
  21. {
  22. /* real destroy work including killing timer and closing sensor is
  23. accomplished in wasm app library version of on_destroy() */
  24. }