main.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*----------------------------------------------------------------------------
  2. * Name: main.c
  3. *----------------------------------------------------------------------------*/
  4. /* Includes ------------------------------------------------------------------*/
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "RTE_Components.h"
  8. #include CMSIS_device_header
  9. #ifdef RTE_Compiler_EventRecorder
  10. #include "EventRecorder.h"
  11. #endif
  12. #include "cmsis_cv.h"
  13. #include "CV_Report.h"
  14. //lint -e970 allow using int for main
  15. /* Private functions ---------------------------------------------------------*/
  16. int main (void);
  17. /**
  18. * @brief Main program
  19. * @param None
  20. * @retval None
  21. */
  22. int main (void)
  23. {
  24. // System Initialization
  25. SystemCoreClockUpdate();
  26. #ifdef RTE_Compiler_EventRecorder
  27. // Initialize and start Event Recorder
  28. (void)EventRecorderInitialize(EventRecordError, 1U);
  29. (void)EventRecorderEnable (EventRecordAll, 0xFEU, 0xFEU);
  30. #endif
  31. cmsis_cv();
  32. #ifdef __MICROLIB
  33. for(;;) {}
  34. #else
  35. exit(0);
  36. #endif
  37. }
  38. #if defined(__CORTEX_A)
  39. #include "irq_ctrl.h"
  40. #if (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || \
  41. (defined ( __GNUC__ ))
  42. #define __IRQ __attribute__((interrupt("IRQ")))
  43. #elif defined ( __CC_ARM )
  44. #define __IRQ __irq
  45. #elif defined ( __ICCARM__ )
  46. #define __IRQ __irq __arm
  47. #else
  48. #error "Unsupported compiler!"
  49. #endif
  50. __IRQ
  51. void IRQ_Handler(void) {
  52. const IRQn_ID_t irqn = IRQ_GetActiveIRQ();
  53. IRQHandler_t const handler = IRQ_GetHandler(irqn);
  54. if (handler != NULL) {
  55. __enable_irq();
  56. handler();
  57. __disable_irq();
  58. }
  59. IRQ_EndOfInterrupt(irqn);
  60. }
  61. __IRQ
  62. void Undef_Handler (void) {
  63. cmsis_cv_abort(__FILENAME__, __LINE__, "Undefined Instruction!");
  64. exit(0);
  65. }
  66. __IRQ
  67. void SVC_Handler (void) {
  68. }
  69. __IRQ
  70. void PAbt_Handler (void) {
  71. cmsis_cv_abort(__FILENAME__, __LINE__, "Prefetch Abort!");
  72. exit(0);
  73. }
  74. __IRQ
  75. void DAbt_Handler (void) {
  76. cmsis_cv_abort(__FILENAME__, __LINE__, "Data Abort!");
  77. exit(0);
  78. }
  79. __IRQ
  80. void FIQ_Handler (void) {
  81. }
  82. #endif
  83. #if defined(__CORTEX_M)
  84. __NO_RETURN
  85. extern void HardFault_Handler(void);
  86. void HardFault_Handler(void) {
  87. cmsis_cv_abort(__FILENAME__, __LINE__, "HardFault!");
  88. #ifdef __MICROLIB
  89. for(;;) {}
  90. #else
  91. exit(0);
  92. #endif
  93. }
  94. #endif