I'm a beginner in CC2540....In keyfob demo project, I can't find where the function "keyfobapp_HandleKeys" in keyfobdemo.c be executed.
I only see it is defined in keyfobdemo.c.
I use "ctrl+shift+F" to find "keyfobapp_HandleKeys", but I can't find in this project only in keyfobdemo.c.
Could someone tell me the program running sequence?
thanks.
Hehe, I also asked this in my first steps.
You can see in the code that the following line is called:
RegisterForKeys( keyfobapp_TaskID );
This makes your application to be "aware" of the key events that may come from lower layers.
In fact, in the keyfobapp_ProcessOSALMsg function, you have code to manage these kind of events that may come (KEY_CHANGE). As you have seen, this calls the function in keyfobdemo.c, which in fact contains the most important code.
The main() of the apps "only" contains init functions and several function calls and starts the state machine of the apps. If you need further info, we can give it to you. This is the basics to let you understand or even search on your own :)
PD: Search for halProcessKeyInterrupt for example! :) Bye!
Please click the Verify Answer button on a post if it answers your question! :)
Thanks for your answer .
After I research the code again, I still have some problems.
I can fine the function "keyfobapp_HandleKeys" was executed in function "keyfobapp_ProcessOSALMsg", and function "keyfobapp_ProcessOSALMsg" was executed in function "KeyFobApp_ProcessEvent". But I can't find any function execute or call function "KeyFobApp_ProcessEvent", why??
I'm sure the code in function "keyfobapp_HandleKeys" was executed, when I run the project "KeyFobDemo".
could somebody can teach me?? thanks :)
hello,
explaining the KeyFobApp_ProcessEvent execution: this function is not called in a direct manner ( like a normal fucntion called in a infinite main loop). instead you will see a function " osal_start_system()" in the main loop which is executed once. when osal_start_system() is called, its an infinite loop which repeatedly calls "osal_run_system". what "osal_run_system" does is, it looks for functions ( KeyFobApp_ProcessEvent bieng one of the many others in the list) which want to get executed according to thier priority, and here it executes the KeyFobApp_ProcessEvent function. if you study the code for "osal_run_system" you will see that it scans the functions ( based on their taskID ) and looks for a non-zero entery in the array TaskEvents( indicting that task has pending events).
hope that answers your question.
Azmat