freertos_hook.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2018, hathach (tinyusb.org)
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. *
  24. * This file is part of the TinyUSB stack.
  25. */
  26. //--------------------------------------------------------------------+
  27. // INCLUDE
  28. //--------------------------------------------------------------------+
  29. #include "FreeRTOS.h"
  30. #include "task.h"
  31. #include "common/tusb_common.h"
  32. void vApplicationMallocFailedHook(void)
  33. {
  34. taskDISABLE_INTERRUPTS();
  35. TU_ASSERT(false, );
  36. }
  37. void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName)
  38. {
  39. (void) pxTask;
  40. (void) pcTaskName;
  41. taskDISABLE_INTERRUPTS();
  42. TU_ASSERT(false, );
  43. }
  44. /* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an
  45. * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
  46. * used by the Idle task. */
  47. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
  48. {
  49. /* If the buffers to be provided to the Idle task are declared inside this
  50. * function then they must be declared static - otherwise they will be allocated on
  51. * the stack and so not exists after this function exits. */
  52. static StaticTask_t xIdleTaskTCB;
  53. static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
  54. /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
  55. state will be stored. */
  56. *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
  57. /* Pass out the array that will be used as the Idle task's stack. */
  58. *ppxIdleTaskStackBuffer = uxIdleTaskStack;
  59. /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
  60. Note that, as the array is necessarily of type StackType_t,
  61. configMINIMAL_STACK_SIZE is specified in words, not bytes. */
  62. *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
  63. }
  64. /* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
  65. * application must provide an implementation of vApplicationGetTimerTaskMemory()
  66. * to provide the memory that is used by the Timer service task. */
  67. void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )
  68. {
  69. /* If the buffers to be provided to the Timer task are declared inside this
  70. * function then they must be declared static - otherwise they will be allocated on
  71. * the stack and so not exists after this function exits. */
  72. static StaticTask_t xTimerTaskTCB;
  73. static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
  74. /* Pass out a pointer to the StaticTask_t structure in which the Timer
  75. task's state will be stored. */
  76. *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
  77. /* Pass out the array that will be used as the Timer task's stack. */
  78. *ppxTimerTaskStackBuffer = uxTimerTaskStack;
  79. /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
  80. Note that, as the array is necessarily of type StackType_t,
  81. configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
  82. *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
  83. }
  84. // executes from within an ISR
  85. void vApplicationTickHook(void)
  86. {
  87. }