main.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. STM32_IWDG_WIN_DISABLED
  22. };
  23. /*
  24. * Application entry point.
  25. */
  26. int main(void) {
  27. /*
  28. * System initializations.
  29. * - HAL initialization, this also initializes the configured device drivers
  30. * and performs the board-specific initializations.
  31. * - Kernel initialization, the main() function becomes a thread and the
  32. * RTOS is active.
  33. */
  34. halInit();
  35. chSysInit();
  36. /*
  37. * Starting the watchdog driver.
  38. */
  39. wdgStart(&WDGD1, &wdgcfg);
  40. /*
  41. * Normal main() thread activity, it resets the watchdog.
  42. */
  43. while (true) {
  44. wdgReset(&WDGD1);
  45. palToggleLine(LINE_LED4);
  46. chThdSleepMilliseconds(500);
  47. }
  48. return 0;
  49. }