FreeRTOSHooks.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2015 Daniel Campora
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #include <stdint.h>
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include "py/mpconfig.h"
  30. #include "py/mphal.h"
  31. #include "py/obj.h"
  32. #include "inc/hw_memmap.h"
  33. #include "pybuart.h"
  34. #include "osi.h"
  35. #include "mperror.h"
  36. //*****************************************************************************
  37. //
  38. //! \brief Application defined idle task hook
  39. //!
  40. //! \param none
  41. //!
  42. //! \return none
  43. //!
  44. //*****************************************************************************
  45. void vApplicationIdleHook (void)
  46. {
  47. // signal that we are alive and kicking
  48. mperror_heartbeat_signal();
  49. // gate the processor's clock to save power
  50. __WFI();
  51. }
  52. //*****************************************************************************
  53. //
  54. //! \brief Application defined malloc failed hook
  55. //!
  56. //! \param none
  57. //!
  58. //! \return none
  59. //!
  60. //*****************************************************************************
  61. void vApplicationMallocFailedHook (void)
  62. {
  63. #ifdef DEBUG
  64. // break into the debugger
  65. __asm volatile ("bkpt #0 \n");
  66. #endif
  67. __fatal_error("FreeRTOS malloc failed!");
  68. }
  69. //*****************************************************************************
  70. //
  71. //! \brief Application defined stack overflow hook
  72. //!
  73. //! \param none
  74. //!
  75. //! \return none
  76. //!
  77. //*****************************************************************************
  78. void vApplicationStackOverflowHook (OsiTaskHandle *pxTask, signed char *pcTaskName)
  79. {
  80. #ifdef DEBUG
  81. // Break into the debugger
  82. __asm volatile ("bkpt #0 \n");
  83. #endif
  84. __fatal_error("Stack overflow!");
  85. }
  86. //*****************************************************************************
  87. //
  88. //! \brief Application defined tick hook
  89. //!
  90. //! \param none
  91. //!
  92. //! \return none
  93. //!
  94. //*****************************************************************************
  95. void vApplicationTickHook (void)
  96. {
  97. HAL_IncrementTick();
  98. }