main.c 1.4 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. #include "hal.h"
  15. /*
  16. * Watchdog deadline set to more than one second (LSI=40000 / (64 * 1000)).
  17. */
  18. static const WDGConfig wdgcfg = {
  19. STM32_IWDG_PR_64,
  20. STM32_IWDG_RL(1000)
  21. };
  22. /*
  23. * Application entry point.
  24. */
  25. int main(void) {
  26. /*
  27. * System initializations.
  28. * - HAL initialization, this also initializes the configured device drivers
  29. * and performs the board-specific initializations.
  30. * - Kernel initialization, the main() function becomes a thread and the
  31. * RTOS is active.
  32. */
  33. halInit();
  34. chSysInit();
  35. /*
  36. * Starting the watchdog driver.
  37. */
  38. wdgStart(&WDGD1, &wdgcfg);
  39. /*
  40. * Normal main() thread activity, it resets the watchdog.
  41. */
  42. while (true) {
  43. wdgReset(&WDGD1);
  44. palToggleLine(LINE_LED4);
  45. chThdSleepMilliseconds(500);
  46. }
  47. return 0;
  48. }