12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include "drivers/Ticker.h"
- #include "drivers/TimerEvent.h"
- #include "platform/FunctionPointer.h"
- #include "hal/ticker_api.h"
- #include "platform/mbed_critical.h"
- namespace mbed {
- void Ticker::detach()
- {
- core_util_critical_section_enter();
- remove();
-
- if (_function && _lock_deepsleep) {
- sleep_manager_unlock_deep_sleep();
- }
- _function = 0;
- core_util_critical_section_exit();
- }
- void Ticker::setup(us_timestamp_t t)
- {
- core_util_critical_section_enter();
- remove();
- _delay = t;
- insert_absolute(_delay + ticker_read_us(_ticker_data));
- core_util_critical_section_exit();
- }
- void Ticker::handler()
- {
- insert_absolute(event.timestamp + _delay);
- if (_function) {
- _function();
- }
- }
- }
|