timer.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "wasm_app.h"
  17. /* User global variable */
  18. static int num = 0;
  19. /* Timer callback */
  20. void timer1_update(user_timer_t timer)
  21. {
  22. printf("Timer update %d\n", num++);
  23. }
  24. void on_init()
  25. {
  26. user_timer_t timer;
  27. /* set up a timer */
  28. timer = api_timer_create(1000, true, false, timer1_update);
  29. api_timer_restart(timer, 1000);
  30. }
  31. void on_destroy()
  32. {
  33. /* real destroy work including killing timer and closing sensor is
  34. accomplished in wasm app library version of on_destroy() */
  35. }