loading

Enjoy a whole new level of driving experience with our carefully selected premium auto parts and accessories to keep your car running at its best.

FreeRTOS_ 005_ Freertosconfig. H Configuration File (II) Hook Function

Hook introductionMany beginners (including me) are completely ignorant of the hook function when they first learn it. They don't know what it is. If you need to understand the hook function related configuration described in this article, you need to understand what a hook function is.

FreeRTOS_ 005_ Freertosconfig. H Configuration File (II) Hook Function 1

Hook function: hook translates to hook and hook, so it is also called "hook function", which can be understood as hooking what you want.Hook function is actually a program segment of the message processing mechanism of the operating system. It is hung into the system through system call.Hook function can be said to be a necessary function of the operating system, such as windows, Linux and the ucos embedded real-time operating system I mentioned earlier.

Hook function is a function provided to developers to realize what they want to achieve. For example, idle tasks in RTOS provide a hook function. I want to count them. When I count them to 1W, I print them (that is, I realize what I want to achieve).In short, beginners do not have to fully master and master everything in the operating system, but they must understand it.It's like I share articles in WeChat official account, you don't have to analyze or understand thoroughly. But it is necessary to understand that don't wait for a problem, and then ask the questions I shared before!

Hook configurationThe above describes so much about hook. I believe you have a certain understanding of hook. Let's talk about the configuration related to hook in "freertosconfig. H".

1.configUSE_ IDLE_ HOOKDefine idle task hook functionConfiguration is 0: not defined

FreeRTOS_ 005_ Freertosconfig. H Configuration File (II) Hook Function 2

Configuration as 1: definitionconfigUSE_ IDLE_ Hook exists at the beginning of system design and must be defined in "freertosconfig. H". Unlike some macro definitions, they can not be defined in "freertosconfig. H", because they judge whether they are defined in "FreeRTOS. H". If they are not defined, there will be a default definition.For example, "configure_mutexes" mentioned in the previous article can not be defined in "freertosconfig. H", but the following code can be seen in "FreeRTOS. H":

#ifndef configUSE_ MUTEXES#define configUSE_ MUTEXES 0#endif

In other words, if there is no definition, it will default to you.Come back to configure_ IDLE_ Hook, in the task. C file, there is the following code:#if (configUSE_IDLE_HOOK == 1)

extern void vApplicationIdleHook(void);vApplicationIdleHook();

#endifIf you configure configure configure_ IDLE_ If hook is 1, you must implement the "vapplicationidlehook()" function, otherwise the compilation will make an error. Beginners do not define this function by default.

2.configUSE_ TICK_ HOOKWhether to define tick hook functionConfiguration is 0: not defined

Configuration as 1: definitionThe following code can be seen under the xtask incrementtick function in the task. C file:#if (configUSE_TICK_HOOK == 1)

if(uxPendedTicks == (UBaseType_t) 0U)

vApplicationTickHook();else

mtCOVERAGE_TEST_MARKER();

#endifTip: the xtask incrementtick function is in pendsv_ Handler is called in the interrupt function. Therefore, the execution time of the vapplicationtickehook() function must be very short.

3.configCHECK_ FOR_ STACK_ OVERFLOWDefine stack overflow hook functionConfiguration is 0: not defined

Configuration as 1: definitionThis configuration is critical and important, especially for complex system design projects with a large amount of code. Using this function can help you analyze whether there is memory out of bounds.4.configUSE_ MALLOC_ FAILED_ HOOK

Whether to define the hook function of memory allocation failureConfiguration is 0: not definedConfiguration as 1: definition

Creating tasks, semaphores, queues, etc. requires a system stack. If we do not allocate enough stacks to the system in total, it is easy to fail to allocate when creating multiple tasks or queues. This will serve as a reminder.5.configUSE_ DAEMON_ TASK_ STARTUP_ HOOKDefine daemon hook function

Configuration is 0: not definedConfiguration as 1: definitionBy analyzing the software source code, it can be found that this hook function is implemented under the timer task, so configure is required_ Timers is 1.

GET IN TOUCH WITH Us
recommended articles
no data
Logo-white 1616138042732
We are committed to the R&D and production of automotive metal parts processing, focusing on professional automotive electronics companies serving car factories.
Contact Us

If you have a question, please contact at contact

US Phone:  +1 (929) 633-0706

Chinese Phone: +86 18928700849

Email:sales@carcuu.com

Address:

(US) 1942 Broadway St.,STE 314C Boulder CO 80302 United States

(Chinese)316 Nanfang Yongfu International, 35 Yongfu Road, Yuexiu District, Guangzhou City, Guangdong Province

Copyright © 2024 CARCUU.COM |Sitemap
Customer service
detect