main.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "rt_test_root.h"
  16. /*
  17. * LED blinker thread, times are in milliseconds.
  18. */
  19. static THD_WORKING_AREA(waThread1, 32);
  20. static THD_FUNCTION(Thread1, arg) {
  21. (void)arg;
  22. chRegSetThreadName("Blinker");
  23. while (true) {
  24. palTogglePad(IOPORT2, PORTB_LED1);
  25. chThdSleepMilliseconds(1000);
  26. }
  27. }
  28. /*
  29. * Application entry point.
  30. */
  31. int main(void) {
  32. /*
  33. * System initializations.
  34. * - HAL initialization, this also initializes the configured device drivers
  35. * and performs the board-specific initializations.
  36. * - Kernel initialization, the main() function becomes a thread and the
  37. * RTOS is active.
  38. */
  39. halInit();
  40. chSysInit();
  41. /*
  42. * Activates the serial driver 1 using the driver default configuration.
  43. */
  44. sdStart(&SD1, NULL);
  45. /*
  46. * Starts the LED blinker thread.
  47. */
  48. chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  49. /*
  50. * Start the RT test suite.
  51. */
  52. test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
  53. while (true) {
  54. chThdSleepMilliseconds(1000);
  55. }
  56. }