main.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "hal.h"
  14. #include "nasa_osal_test_root.h"
  15. #include "osapi.h"
  16. /*
  17. * This is a periodic thread that does absolutely nothing except flashing
  18. * a LED.
  19. * Note, the working area is created using ChibiOS/RT macro because alignment
  20. * constraints.
  21. */
  22. static THD_WORKING_AREA(wa_blinker, 128);
  23. static void blinker(void) {
  24. OS_TaskRegister();
  25. while (true) {
  26. palSetLine(LINE_ARD_D13);
  27. OS_TaskDelay(500);
  28. palClearLine(LINE_ARD_D13);
  29. OS_TaskDelay(500);
  30. }
  31. }
  32. /*
  33. * Application entry point.
  34. */
  35. int main(void) {
  36. uint32 blinker_id;
  37. /* HAL initialization, this also initializes the configured device drivers
  38. and performs the board-specific initializations.*/
  39. halInit();
  40. /* OS initialization.*/
  41. (void) OS_API_Init();
  42. /* Activates the serial driver 1 using the driver default configuration.*/
  43. sdStart(&SD1, NULL);
  44. /* ARD_D13 is programmed as output (board LED).*/
  45. palClearLine(LINE_ARD_D13);
  46. palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL);
  47. /* Starting the blinker thread.*/
  48. (void) OS_TaskCreate(&blinker_id, "blinker", blinker,
  49. (uint32 *)wa_blinker, sizeof wa_blinker,
  50. 128, 0);
  51. /* In the ChibiOS/RT OSAL implementation the main() function is an
  52. usable thread with priority 128 (NORMALPRIO), here we just sleep
  53. waiting for a button event, then the test suite is executed.*/
  54. while (true) {
  55. if (palReadLine(LINE_BUTTON_USER))
  56. test_execute((BaseSequentialStream *)&SD1, &nasa_osal_test_suite);
  57. OS_TaskDelay(500);
  58. }
  59. }