main.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #include "ch.h"
  14. /*
  15. * This is a periodic thread that does absolutely nothing except sleeping.
  16. */
  17. static THD_WORKING_AREA(waThread1, 128);
  18. static THD_FUNCTION(Thread1, arg) {
  19. (void)arg;
  20. chRegSetThreadName("sleeper");
  21. while (true) {
  22. chThdSleepMilliseconds(1000);
  23. }
  24. }
  25. /*
  26. * Application entry point.
  27. */
  28. int main(void) {
  29. /*
  30. * System initializations.
  31. * - Kernel initialization, the main() function becomes a thread and the
  32. * RTOS is active.
  33. */
  34. chSysInit();
  35. /*
  36. * Creates the example thread.
  37. */
  38. (void) chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  39. /*
  40. * Normal main() thread activity, in this demo it just sleeps.
  41. */
  42. while (true) {
  43. chThdSleepMilliseconds(1000);
  44. }
  45. }