main.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. //lint -e970 allow using int for main
  14. /* Private functions ---------------------------------------------------------*/
  15. int main (void);
  16. /**
  17. * @brief Main program
  18. * @param None
  19. * @retval None
  20. */
  21. int main (void)
  22. {
  23. // System Initialization
  24. SystemCoreClockUpdate();
  25. #ifdef RTE_Compiler_EventRecorder
  26. // Initialize and start Event Recorder
  27. (void)EventRecorderInitialize(EventRecordError, 1U);
  28. (void)EventRecorderEnable (EventRecordAll, 0xFEU, 0xFEU);
  29. #endif
  30. cmsis_cv();
  31. #ifdef __MICROLIB
  32. for(;;) {}
  33. #else
  34. exit(0);
  35. #endif
  36. }
  37. #if defined(__CORTEX_A)
  38. #include "irq_ctrl.h"
  39. #if (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || \
  40. (defined ( __GNUC__ ))
  41. __attribute__((interrupt("IRQ")))
  42. #elif defined ( __CC_ARM )
  43. __irq
  44. #elif defined ( __ICCARM__ )
  45. __irq __arm
  46. #else
  47. #error "Unsupported compiler!"
  48. #endif
  49. void IRQ_Handler(void) {
  50. const IRQn_ID_t irqn = IRQ_GetActiveIRQ();
  51. IRQHandler_t const handler = IRQ_GetHandler(irqn);
  52. if (handler != NULL) {
  53. __enable_irq();
  54. handler();
  55. __disable_irq();
  56. }
  57. IRQ_EndOfInterrupt(irqn);
  58. }
  59. #endif
  60. #if defined(__CORTEX_M)
  61. __NO_RETURN
  62. extern void HardFault_Handler(void);
  63. void HardFault_Handler(void) {
  64. #ifdef __MICROLIB
  65. for(;;) {}
  66. #else
  67. exit(0);
  68. #endif
  69. }
  70. #endif