timer.c 671 B

12345678910111213141516171819202122232425262728293031323334
  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. #include "wa-inc/timer_wasm_app.h"
  7. /* User global variable */
  8. static int num = 0;
  9. /* Timer callback */
  10. void
  11. timer1_update(user_timer_t timer)
  12. {
  13. printf("Timer update %d\n", num++);
  14. }
  15. void
  16. on_init()
  17. {
  18. user_timer_t timer;
  19. /* set up a timer */
  20. timer = api_timer_create(1000, true, false, timer1_update);
  21. api_timer_restart(timer, 1000);
  22. }
  23. void
  24. on_destroy()
  25. {
  26. /* real destroy work including killing timer and closing sensor is
  27. accomplished in wasm app library version of on_destroy() */
  28. }