main.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <cstdio>
  2. #include <cstdint>
  3. #if defined(COMMAND_LINE)
  4. #include <cstdlib>
  5. #endif
  6. #include "scheduler.h"
  7. #include "RTE_Components.h"
  8. #include CMSIS_device_header
  9. #include "cmsis_os2.h"
  10. #if defined(RTE_Compiler_EventRecorder)
  11. #include "EventRecorder.h"
  12. #endif
  13. void app_main (void *argument)
  14. {
  15. int error;
  16. uint32_t res=1;
  17. uint32_t nbSched = 0;
  18. (void)argument;
  19. printf("Start\n\r");
  20. #if defined(RTE_Compiler_EventRecorder)
  21. res = EventRecorderEnable (EventRecordAll, EvtSched, EvtSched);
  22. if (!res)
  23. {
  24. printf("Error enabling event recorder for scheduler\n");
  25. goto endThread;
  26. }
  27. #endif
  28. nbSched=scheduler(&error);
  29. printf("Number of schedule iterations = %d\n\r",nbSched);
  30. printf("Error code = %d\n\r",error);
  31. #if defined(RTE_Compiler_EventRecorder)
  32. res = EventRecorderDisable (EventRecordAll, EvtSched, EvtSched);
  33. if (!res)
  34. {
  35. printf("Error disabling event recorder\n");
  36. }
  37. #endif
  38. endThread:
  39. #if defined(COMMAND_LINE)
  40. exit(0);
  41. #else
  42. osThreadExit();
  43. #endif
  44. }
  45. int main(void)
  46. {
  47. // System Initialization
  48. SystemCoreClockUpdate();
  49. osKernelInitialize(); // Initialize CMSIS-RTOS
  50. osThreadNew(app_main, NULL, NULL); // Create application main thread
  51. osKernelStart(); // Start thread execution
  52. for (;;) {}
  53. }