1 /* 2 * FreeRTOS V202212.00 3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 * this software and associated documentation files (the "Software"), to deal in 7 * the Software without restriction, including without limitation the rights to 8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 * the Software, and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in all 13 * copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * https://www.FreeRTOS.org 23 * https://github.com/FreeRTOS 24 * 25 */ 26 27 /** 28 * @file iot_test_freertos.c 29 * @brief Common hooks file for platforms that have not implemented hooks. 30 */ 31 32 #include "FreeRTOS.h" 33 #include "task.h" 34 35 /* It is recommended to implement hooks that use platform specific APIs. This allows 36 * for better error messages and recovery. Should platform specific hooks be implemented, 37 * add this macro to iot_config.h to avoid compiling these symbols.*/ 38 #ifndef iotconfigUSE_PORT_SPECIFIC_HOOKS 39 40 /** 41 * @brief Warn user if pvPortMalloc fails. 42 * 43 * Called if a call to pvPortMalloc() fails because there is insufficient 44 * free memory available in the FreeRTOS heap. pvPortMalloc() is called 45 * internally by FreeRTOS API functions that create tasks, queues, software 46 * timers, and semaphores. The size of the FreeRTOS heap is set by the 47 * configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. 48 * 49 */ vApplicationMallocFailedHook()50 void vApplicationMallocFailedHook() 51 { 52 configPRINT_STRING( ( "ERROR: Malloc failed to allocate memory\r\n" ) ); 53 taskDISABLE_INTERRUPTS(); 54 55 /* Loop forever */ 56 for( ; ; ) 57 { 58 } 59 } 60 /*-----------------------------------------------------------*/ 61 62 /** 63 * @brief Loop forever if stack overflow is detected. 64 * 65 * If configCHECK_FOR_STACK_OVERFLOW is set to 1, 66 * this hook provides a location for applications to 67 * define a response to a stack overflow. 68 * 69 * Use this hook to help identify that a stack overflow 70 * has occurred. 71 * 72 */ vApplicationStackOverflowHook(TaskHandle_t xTask,char * pcTaskName)73 void vApplicationStackOverflowHook( TaskHandle_t xTask, 74 char * pcTaskName ) 75 { 76 /* Disable unused parameter warnings. */ 77 ( void ) xTask; 78 ( void ) pcTaskName; 79 80 configPRINT_STRING( ( "ERROR: stack overflow with task \r\n" ) ); 81 portDISABLE_INTERRUPTS(); 82 83 /* Loop forever */ 84 for( ; ; ) 85 { 86 } 87 } 88 #endif /* iotconfigUSE_PORT_SPECIFIC_HOOKS */ 89