Page 1 of 1
Kernel state?
Posted: Sun Mar 30, 2014 11:58 am
by avrhack
I've got a function that calls a number of APIs and I want it to be usable from I-State as well as normal-state, by checking what state it has been called from and invoking the appropriate I-class or normal API.
However I can't find an API that gives me the current kernel state! I've looked in the documentation, searched this forum, nada.
Sure it's there and just me being stupid, so could anyone point me to it please?
Thanks.
Re: Kernel state?
Posted: Sun Mar 30, 2014 1:42 pm
by Giovanni
There isn't one, usually you know in what context runs your code.
The kernel 3.0 has support for "universal" functions, you may switch to that one.
Giovanni
Re: Kernel state?
Posted: Sun Mar 30, 2014 7:47 pm
by avrhack
Giovanni wrote:There isn't one, usually you know in what context runs your code.
The kernel 3.0 has support for "universal" functions, you may switch to that one.
Giovanni
Yeah I've ended up adding another parameter to the function I want to 'share' and it invokes the appropriate I-class or normal API accordingly. All working now.
As an aside, as an enhancement suggestion, is it worth considering a new class of API that can be called from either context and figures things out itself? Would make things a lot easier than the current API situation? It could be done with a naming convention to sit alongside the current API to make migration easy?
Re: Kernel state?
Posted: Sun Mar 30, 2014 8:51 pm
by Giovanni
Hi,
3.0 has a convention for universal APIs, the "X" suffix. Any I-Class function can be turned in X-Class by putting it in between: chSysGetStatusAndLockX() and chSysRestoreStatusX().
Giovanni