-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added User Functions #240
base: master
Are you sure you want to change the base?
Added User Functions #240
Conversation
68c96b4
to
eae4cbe
Compare
#include <stddef.h> | ||
#include <errno.h> | ||
|
||
#if defined(CONFIG_USER_FUNCTIONS) && (CONFIG_USER_FUNCTIONS > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this guard is not needed, because:
- target-specific code using the user function system, will for sure need to define the
CONFIG_USER_FUNCTIONS
- all the function calls in the common code have to be guarded with
#ifdef
to avoid linker errors in case the target does not support the user functions (see threads.c) - functions not called anywhere and unused variables are garbage-collected at link time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove the guard if needed. But if user functions are expected to be used in common code then it is not really user functions anymore and we should also modify slightly the mechanism to account for functions added from common code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called them "user functions" following the terminology used in the code I used at work, but a more correct term should be "tasklet" or something like that. About adding periodic functions from common code, I see that the current gps_task
is a good candidate for this mechanism: if there is the GPS hardware, or if the GPS is enabled, add a periodic function which retrieves and parses the NMEA sentences.
98e83dd
to
05e8f35
Compare
This thread handles a set of user functions. Those user functions can be either periodic (with a frequency of 1Hz, 10Hz, 20Hz, 50Hz or 100Hz) or aperiodic (asynchronous). Periodic functions will be called periodically depending on their scheduling. Async functions need to be triggered usign user_functions_trigger(id). The maximum amount of user functions that can be handled have to be defined in hwconfig.h using the macro CONFIG_USER_FUNCTIONS. If this macro is not defined, the user functions thread will not be created.
This PR contains one commit that implements a user functions thread.
This thread handles a set of functions added by the user.
Those functions can be either periodic (with a frequency of 1Hz, 10Hz, 20Hz, 50Hz, 100Hz or 1kHhz) or aperiodic (asynchronous).
Periodic functions will be called periodically depending on their scheduling. Async functions need to be triggered using user_functions_trigger(id).
The maximum amount of user functions that can be handled have to be defined in hwconfig.h using the macro CONFIG_USER_FUNCTIONS. If this macro is not defined, the user functions thread will not be created.
For now, it is implemented by checking for async functions to call every 5ms. This is because the version of miosix used does not support
pthread_cond_timedwait()
.Some code (untested, commented-out) have been voluntarily left in the
user_functions.c
waiting for the miosix kernel to be updated.