timer.c 671 B

12345678910111213141516171819202122232425262728293031
  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 timer1_update(user_timer_t timer)
  11. {
  12. printf("Timer update %d\n", num++);
  13. }
  14. void on_init()
  15. {
  16. user_timer_t timer;
  17. /* set up a timer */
  18. timer = api_timer_create(1000, true, false, timer1_update);
  19. api_timer_restart(timer, 1000);
  20. }
  21. void on_destroy()
  22. {
  23. /* real destroy work including killing timer and closing sensor is
  24. accomplished in wasm app library version of on_destroy() */
  25. }