Currently this uses the same mechanism used by the rtos to conditionally
include the network-socket API. Perhaps this should be builtin to the
config system?
Note: this does require that the bug-compatible inclusion of mbed.h
be removed to avoid include-order issues.
per @sg-
Before, the following results in a compilation error:
const struct Object *obj;
void obj_doit(const Object *obj);
Callback<void()> cb(obj, obj_doit);
This is especially noticable when migrating from the old Thread
constructor, which previously _required_ const.
Short term fix for all cv qualifiers through a C cast:
void *_obj = (void*)obj;
FunctionPointer/FunctionPointerArg0/FunctionPointerArg1 has been
replaced by the more flexible Callback template class.
For the motivation behind adopting the Callback class:
https://github.com/mbedmicro/mbed/pull/1783
Create the wrapper class SingletonPtr. This provides a safe way to
declare and use singletons. This class allows both the lazy
initialization of a singleton, and allows the singleton to be
garbage collected by the linker if it is never referenced.
This patch also updates the HAL to use SingletonPtr when declaring
singleton mutexes.
and update the using functions accordingly.
Usage:
bool interrupts_enabled = are_interrupts_enabled()
Remove superfluos shift in are_interrupts_enabled().
than an integer. This removes the need for all users to mask the returned
value with 0x1 to determine interrupt status.
Expose this function externally to allow other users to check interrupt
status in a manner which will work for both cortex-A and cortex-M .
Usage:
bool disabled = get_interrupts_disabled();
Add a virtual destructor to classes which have a virtual lock and
unlock. Remove the virtual qualifier from functions in
InterruptManager since this class cannot be extended.
This includes a generic critical section implementation. This
implementation also allow a user to start a critical section while
interrupts are already disabled.
per @c1728p9
Update the Callback class to handle a NULL thunk by returning 0
rather than trying to call the thunk. This fixes a crash that occurs
on some targets when the TX uart handler is not attached.
Background:
The K64F HAL uart implementation calls the TX interrupt handler
every time a uart interrupt occurs while the TX register is empty.
It does not check to see if the TX interrupt has been enabled.
This means that the TX interrupt can and typically does get
run on RX events. This causes a crash with the newer callback
code which did not (prior to this patch) support a NULL thunk.
- Adopt C++11 style template arguments, requires rename to Callback
- Add constructor for C style callback functions
- Add constructor for Callbacks
- Add static function for passing to C style callbacks
This was causing errors at my machine (for programs like MBED_10, RTOS_1):
Error[Li005]: no definition for "__semihost" [referenced from
semihost_api.o(mbed.a)]
[ERROR] Error[Li005]: no definition for "__semihost" [referenced from
semihost_api.o(mbed.a)]