freertos_hook.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**************************************************************************/
  2. /*!
  3. @file freertos_hook.c
  4. @author hathach (tinyusb.org)
  5. @section LICENSE
  6. Software License Agreement (BSD License)
  7. Copyright (c) 2014, hathach (tinyusb.org)
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. 1. Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. 2. Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. 3. Neither the name of the copyright holders nor the
  17. names of its contributors may be used to endorse or promote products
  18. derived from this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
  20. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
  23. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. This file is part of the tinyusb stack.
  30. */
  31. /**************************************************************************/
  32. //--------------------------------------------------------------------+
  33. // INCLUDE
  34. //--------------------------------------------------------------------+
  35. #include "FreeRTOS.h"
  36. #include "task.h"
  37. #include "common/tusb_common.h"
  38. void vApplicationMallocFailedHook(void)
  39. {
  40. taskDISABLE_INTERRUPTS();
  41. TU_ASSERT(false, );
  42. }
  43. void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName)
  44. {
  45. (void) pxTask;
  46. taskDISABLE_INTERRUPTS();
  47. TU_ASSERT(false, );
  48. }
  49. /* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an
  50. * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
  51. * used by the Idle task. */
  52. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
  53. {
  54. /* If the buffers to be provided to the Idle task are declared inside this
  55. * function then they must be declared static - otherwise they will be allocated on
  56. * the stack and so not exists after this function exits. */
  57. static StaticTask_t xIdleTaskTCB;
  58. static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
  59. /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
  60. state will be stored. */
  61. *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
  62. /* Pass out the array that will be used as the Idle task's stack. */
  63. *ppxIdleTaskStackBuffer = uxIdleTaskStack;
  64. /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
  65. Note that, as the array is necessarily of type StackType_t,
  66. configMINIMAL_STACK_SIZE is specified in words, not bytes. */
  67. *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
  68. }
  69. /* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
  70. * application must provide an implementation of vApplicationGetTimerTaskMemory()
  71. * to provide the memory that is used by the Timer service task. */
  72. void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )
  73. {
  74. /* If the buffers to be provided to the Timer task are declared inside this
  75. * function then they must be declared static - otherwise they will be allocated on
  76. * the stack and so not exists after this function exits. */
  77. static StaticTask_t xTimerTaskTCB;
  78. static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
  79. /* Pass out a pointer to the StaticTask_t structure in which the Timer
  80. task's state will be stored. */
  81. *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
  82. /* Pass out the array that will be used as the Timer task's stack. */
  83. *ppxTimerTaskStackBuffer = uxTimerTaskStack;
  84. /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
  85. Note that, as the array is necessarily of type StackType_t,
  86. configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
  87. *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
  88. }
  89. // executes from within an ISR
  90. void vApplicationTickHook(void)
  91. {
  92. }