Commit Graph

53 Commits (cde5e6edd4b2cc3af4f19f268f46e76abf76172a)

Author SHA1 Message Date
Martin Kojtal 8b379703d4 events: astyle fix 2018-08-03 13:23:38 +01:00
Kimmo Vaisanen 990da085d9 Introduce API to query how much time is left for delayed event
If user has initiated a delayed event (either with call_in or call_every),
user might need to know how much time is left until the event is
due to be dispatched.

Added time_left() function can be used to get the remaining time.
2018-05-18 12:55:06 +03:00
Kevin Bracey d979c59118 Make event queue use RTOS tick count
Event queue was using its own Timer or LowPowerTimer objects to derive
millisecond tick counts. This is unnecessary in RTOS builds, where the
RTOS is maintaining a tick count.

It also makes more sense to use the actual RTOS tick count, as the
values are being used to compute tick timeouts for RTOS calls. Computing
these RTOS tick delays with a separate timer could conceivably lead to
rounding errors.

Fixes: #5378
2018-04-20 11:44:36 +03:00
Cruz Monrreal 15807744de
Merge pull request #6238 from pauluap/break_dispatch_flag
Remove windup behavior from break_dispatch
2018-03-15 10:59:36 -05:00
Cruz Monrreal 9cac3b2f6b
Merge pull request #6149 from bmcdonnell-ionx/typos
Fix typos in the files
2018-03-15 10:53:03 -05:00
Cruz Monrreal b97c7d8263
Merge pull request #6274 from geky/events-doc-periodic
events: Added note about immediate firing of periodic events
2018-03-15 10:48:22 -05:00
Martin Kojtal 87b37c0e2a
Merge pull request #6286 from delftswa2018/feature-typo-fixes
Small typo fixes in readme.md files
2018-03-08 17:36:23 +01:00
Jasper de Winkel 2c7a25a949 Small typo fixes in readme.md files 2018-03-06 19:07:03 +01:00
Paul Thompson 210f50d5c6 Flip order of comparison 2018-03-05 09:40:41 -08:00
Christopher Haster 30392acae3 events: Added note about immediate firing of periodic events 2018-03-05 11:07:28 -06:00
Paul Thompson 712b47f3c1 Clarify intention between comparison to zero and the shift operation
Building with (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 gives this warning

../events/equeue/equeue.c: In function 'equeue_incid':
../events/equeue/equeue.c:40:17: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
     if (!(e->id << q->npw2)) {
2018-03-04 12:44:21 -08:00
Paul Thompson dc430ef2d0 style fixups 2018-03-02 13:10:27 -08:00
Paul Thompson bb0d54023f Add test to cover break_dispatch windup 2018-03-02 12:44:13 -08:00
Paul Thompson 31f581c425 Clear the break requested flag if the dispatch loop is being broken due to a timeout condition 2018-03-02 12:37:53 -08:00
Paul Thompson 5d98d22614 Remove windup behavior from break_dispatch 2018-03-02 11:00:35 -08:00
Brendan McDonnell c4f10aafee typos 2018-02-20 20:11:19 -05:00
Cruz Monrreal 7411b31eb4
Merge pull request #6118 from ARMmbed/g-note-global-equeue-irq
equeue: Add note about using global event queues in irq
2018-02-16 19:48:36 -06:00
Christopher Haster 6e4e62b8a0
equeue: Added note about using global event queues in irq 2018-02-16 10:33:32 -06:00
Christopher Haster c39ce94b09 equeue: Removed RTOS dependencies when RTOS not present 2018-02-15 10:20:12 -06:00
Michael Kaplan 23f2199e47 equeue: some refactoring to meet coding rules 2017-10-30 13:56:11 +01:00
Michael Kaplan 6406ab05c6 equeue: added help text for new config option use-lowpower-timer-ticker 2017-10-18 11:13:39 +02:00
Michael Kaplan eacc27659d equeue: added config option which tells equeue_mbed.cpp if it shall use LowPowerTimer, LowPowerTimeout and LowPowerTicker instead of Timer/Timeout/Ticker.
This way, on SiLabs boards the low power sleep states will be used when using event queue.
2017-10-17 15:28:00 +02:00
Russ Butler b2384b1629 Remove use of internal RTX types
Make calls to cmsis-os to get thread state, stack size, and max stack
usage rather than accessing internal RTX data directly. Wrap RTX5
specific code in OS_BACKEND_RTX5.

Also refactor the code to use mbed types rather than RTX types:
os_timer_t -> mbed_rtos_storage_timer_t
os_event_flags_t -> mbed_rtos_storage_event_flags_t
osRtxMutex_t -> mbed_rtos_storage_thread_t
2017-09-04 11:26:38 -05:00
Kevin Bracey eb80c25398 Add ability to request a shared event queue
To allow components with a simple need to schedule a few events to not
have to create their own threads, with all the associated memory
overhead, add 2 central calls to get shared normal and an
interrupt-deferral event queues, each dispatched on their own shared
threads.

For non-RTOS systems, just the normal event queue is provided, and the
application would have to dispatch this itself. This
application-dispatch is also available via a config option, to
potentially save memory by reusing the main thread.

Possible future improvement: the ability for separate components to
request a minimum stack size, and have the JSON combine these requests.
(Analogous tooling has already been mooted for mbed TLS config options
like key size).
2017-09-01 13:26:08 +03:00
Jimmy Brisson fecb99140d Merge pull request #4571 from geky/events-use-rtx-event-flags
events: Adopt osEventFlags from RTX 5
2017-06-29 11:06:42 -05:00
Vincent Coubard f57cc80ecc event: Make the event queue non copyable. 2017-06-20 16:23:45 +01:00
Christopher Haster 3934b30b58 events: Adopt osEventFlags from RTX 5
This provides the correct binary semaphore behaviour that was expected
by the equeue layer, removes concerns around semaphore overflow, and
reduces the number of spurious wakeups which may save a bit of power.

This also fixes some issues we were seeing around the RTX 5 changes
to semaphore behaviour.
2017-06-15 15:47:15 -05:00
Kevin Gilbert fcc780890c EventQueue.h Doxygen doc fixed up. Moved overloaded callback arguments documentation to overloaded functions to fix warnings. B0..B4 were not documentated additionally, only bulk docs for a0..a4 and c0..c4 were moved around. 2017-06-07 11:50:33 -05:00
Kevin Gilbert 1d450f82fb Removed Doxygen errors from Event.h
- Removed Makefile from branch
- Moved a0..a4/c0..c4 parameter documentation from top level overloaded functions to each function to appease Doxygen.
- Removed @see Event::Event from overloaded functions as the link did not work and the argument parameter documentation was moved down to each function
- TODO: Cleanup EventQueue.h
2017-06-07 11:50:33 -05:00
Bartek Szatkowski b793a3fb89 Update codebase for CMSIS5/RTX5
Update all of mbed-os to use RTX5.
2017-05-30 18:55:52 +01:00
Anna Bridge 47b1a9eeec Merge pull request #4111 from sg-/fix-the-docs
[drivers] Update doxygen errors
2017-04-21 14:10:17 +01:00
Anna Bridge 2ae34c45d0 Merge pull request #4184 from geky/events-strict-alias-warning
events: Remove strict-aliasing warning
2017-04-20 16:43:13 +01:00
Christopher Haster 4459e6d5a0 events: Remove strict-aliasing warning
Several opaque buffers are used to to wrap c++ classes to pass
to the c layer. The reinterpret cast to c++ classes is fine as long
as the underlying buffer is not interpreted as different incompatible
types, or else the behaviour is undefined.

In the equeue_tick_init function, placement new is used to initialize
the buffers. However, this interprets the buffer as a simple array
of bytes, not the actual class type. Later the buffer is casted to
the class type. From the point of view of the compiler, these two
types are incompatible, and the compiler is free to reorder the
operations under the assumption that they can't affect each other.

Reinterpet casting the buffer to a class pointer before using
placement new insures that the buffer is only interpreted as a single
type. Or simple using the return value from placement new will handle
the aliasing appropriately.
2017-04-13 12:15:50 -05:00
Christopher Haster 2bcb09560b events: Fixed zero wait condition in non-rtos semaphore
Before, if the semaphore recieved a wait of zero, the semaphore
would erronously drop the ticker event to wake up the device,
causing the device to go to sleep without any mechanism to wake
itself up.

During a dispatch operation, the event queue dispatches all events
that have expired, so the call to equeue_sema_wait very rarely
has a wait of zero. But this can happen when an event is posted
just after a dispatch has occured.
2017-04-05 17:21:51 -05:00
Jimmy Brisson f945d71319 Update class documentation tags
stop using scope for \addtogroup. It was placing class methods into the
group documentation instead of the class documentation. The new style is
to explicitly tag the class as @ingroup. This new method will allow the
class to be linked in the group page, and the class page will contain
the detailed documentation of the class methods.
2017-04-04 14:21:53 -05:00
Sam Grove 4103842b2b Merge pull request #3782 from geky/events-callback-inference
events: Add support for infering event type from Callback objects
2017-02-21 10:53:14 -06:00
Christopher Haster 3531a1579e events: Added better documentation for binding types to events 2017-02-17 14:33:09 -06:00
Christopher Haster 99ca88a66a events: Added support for infering event type from Callback objects
While limitations in type inference prevent the event helper from
infering the type of generic function objects, there is nothing
technical preventing inference from the Callback class, where the
function type is encoded in the template parameters.

With adoption of the Callback class as the standard function
representation, it makes sense to support events created from
callback objects.
2017-02-15 13:43:52 -06:00
Christopher Haster 0949164422 events: Added better handling of desynchronized timers in platform layer
An odd bug (c0951c9) in the NCS36510 ticker code caused the timer/ticker
classes to become desynchronized. Updated the handling to not assume the
timers are perfectly in synch. This will increase the event's tolerance of
less robust platforms.
2017-02-15 11:00:02 -06:00
Christopher Haster f9752f957e events - Fixed overflow of timeout on STM32F4
For equeue_sema_wait, -1 is used to indicate an infinite wait.
This wasn't handled in the nonrtos implementation and caused
undefined/weird behaviour after an overflow on integer multiplication.

On most boards, the infinite wait would return after ~50 days, on the
STM32F4 the timeout killed all other timeouts for some reason.
2017-01-09 19:28:33 -06:00
Christopher Haster 87a1cfee42 Added equeue tests to travis CI 2016-11-21 12:48:16 -06:00
Christopher Haster d513587806 events - Fixed unchaining of event queues
The equeue_chain function is supposed to unchain the event queue
from whatever queue it is chained to when passed a null target.
Internally, this is accomplished by just calling equeue_background
with null and letting the previously registered update function
clean up the chaining.

However, equeue_chain did not appropriately check for null, causing
it to unnecessarily allocate memory and leaving the update function
in a bad state. Fixed with a simple null check.
2016-11-21 12:25:48 -06:00
Sam Grove 074555b715 Merge pull request #3113 from geky/static-assert
Add static assert macro
2016-11-07 10:25:17 -06:00
Christopher Haster 98db3ab1cb Adopted MBED_STATIC_ASSERT where possible 2016-11-01 21:39:48 -05:00
Christopher Haster 2fefc05f08 events - Removed unused variable warning in ndebug builds 2016-10-21 12:51:55 -05:00
Christopher Haster bac63e7533 callback - Fixed missing workaround for IAR issue with type information
Related to commit abba0c2
2016-10-12 18:08:37 -05:00
Sam Grove 3a16ca9855 Merge pull request #2911 from theotherjimmy/docs-generation
[Tools] Add documentation generation script
2016-10-06 15:57:08 -05:00
Jimmy Brisson f1a78027d3 Add tags to our code 2016-10-04 15:02:44 -05:00
Christopher Haster abba0c2173 callback - Added workaround for IAR issue with type information
In the IAR ide, implicitly generated structures based on function
templates end up with missing type information. This has no effect
on using the IAR compiler standalone, but when used through the ide
the missing type information causes the ide to error.

As a workaround, moved the function attributes generated for the
Callback and Event classes into the class scope. This avoids the
syntax that confuses IAR.
2016-10-03 18:33:25 -05:00
Christopher Haster 93ba3a7d84 Added workaround for armc assumptions on integer underflow
With ARM Compiler 5.06u3, when the equeue_tickdiff function is
inlined, the compiler treats the unsigned integer subtraction
as undefined behaviour and assumes falsely the comparisons
could never be true.

The workaround is to an explicit cast, which politely reminds the
compiler to emit the correct comparison.
2016-10-02 06:25:47 -05:00