test test test
snake-test/mbed/platform/mbed_power_mgmt.h@0:e4c5e6ec922e, 2020-05-25 (annotated)
- Committer:
- mohamedmoawya
- Date:
- Mon May 25 19:06:11 2020 +0000
- Revision:
- 0:e4c5e6ec922e
snake game tteest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mohamedmoawya | 0:e4c5e6ec922e | 1 | /** \addtogroup platform */ |
mohamedmoawya | 0:e4c5e6ec922e | 2 | /** @{*/ |
mohamedmoawya | 0:e4c5e6ec922e | 3 | /** |
mohamedmoawya | 0:e4c5e6ec922e | 4 | * \defgroup platform_power_mgmt Power management functions |
mohamedmoawya | 0:e4c5e6ec922e | 5 | * @{ |
mohamedmoawya | 0:e4c5e6ec922e | 6 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 7 | |
mohamedmoawya | 0:e4c5e6ec922e | 8 | /* mbed Microcontroller Library |
mohamedmoawya | 0:e4c5e6ec922e | 9 | * Copyright (c) 2006-2018 ARM Limited |
mohamedmoawya | 0:e4c5e6ec922e | 10 | * |
mohamedmoawya | 0:e4c5e6ec922e | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mohamedmoawya | 0:e4c5e6ec922e | 12 | * you may not use this file except in compliance with the License. |
mohamedmoawya | 0:e4c5e6ec922e | 13 | * You may obtain a copy of the License at |
mohamedmoawya | 0:e4c5e6ec922e | 14 | * |
mohamedmoawya | 0:e4c5e6ec922e | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
mohamedmoawya | 0:e4c5e6ec922e | 16 | * |
mohamedmoawya | 0:e4c5e6ec922e | 17 | * Unless required by applicable law or agreed to in writing, software |
mohamedmoawya | 0:e4c5e6ec922e | 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
mohamedmoawya | 0:e4c5e6ec922e | 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mohamedmoawya | 0:e4c5e6ec922e | 20 | * See the License for the specific language governing permissions and |
mohamedmoawya | 0:e4c5e6ec922e | 21 | * limitations under the License. |
mohamedmoawya | 0:e4c5e6ec922e | 22 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 23 | #ifndef MBED_POWER_MGMT_H |
mohamedmoawya | 0:e4c5e6ec922e | 24 | #define MBED_POWER_MGMT_H |
mohamedmoawya | 0:e4c5e6ec922e | 25 | |
mohamedmoawya | 0:e4c5e6ec922e | 26 | #include "hal/sleep_api.h" |
mohamedmoawya | 0:e4c5e6ec922e | 27 | #include "mbed_toolchain.h" |
mohamedmoawya | 0:e4c5e6ec922e | 28 | #include "hal/ticker_api.h" |
mohamedmoawya | 0:e4c5e6ec922e | 29 | #include <stdbool.h> |
mohamedmoawya | 0:e4c5e6ec922e | 30 | |
mohamedmoawya | 0:e4c5e6ec922e | 31 | #ifdef __cplusplus |
mohamedmoawya | 0:e4c5e6ec922e | 32 | extern "C" { |
mohamedmoawya | 0:e4c5e6ec922e | 33 | #endif |
mohamedmoawya | 0:e4c5e6ec922e | 34 | |
mohamedmoawya | 0:e4c5e6ec922e | 35 | /** |
mohamedmoawya | 0:e4c5e6ec922e | 36 | * @defgroup hal_sleep_manager Sleep manager API |
mohamedmoawya | 0:e4c5e6ec922e | 37 | * The sleep manager provides API to automatically select sleep mode. |
mohamedmoawya | 0:e4c5e6ec922e | 38 | * |
mohamedmoawya | 0:e4c5e6ec922e | 39 | * There are two sleep modes: |
mohamedmoawya | 0:e4c5e6ec922e | 40 | * - sleep |
mohamedmoawya | 0:e4c5e6ec922e | 41 | * - deepsleep |
mohamedmoawya | 0:e4c5e6ec922e | 42 | * |
mohamedmoawya | 0:e4c5e6ec922e | 43 | * Use locking/unlocking deepsleep for drivers that depend on features that |
mohamedmoawya | 0:e4c5e6ec922e | 44 | * are not allowed (=disabled) during the deepsleep. For instance, high frequency |
mohamedmoawya | 0:e4c5e6ec922e | 45 | * clocks. |
mohamedmoawya | 0:e4c5e6ec922e | 46 | * |
mohamedmoawya | 0:e4c5e6ec922e | 47 | * # Defined behavior |
mohamedmoawya | 0:e4c5e6ec922e | 48 | * * The lock is a counter |
mohamedmoawya | 0:e4c5e6ec922e | 49 | * * The lock can be locked up to USHRT_MAX - Verified by ::test_lock_eq_ushrt_max and ::test_lock_gt_ushrt_max |
mohamedmoawya | 0:e4c5e6ec922e | 50 | * * The lock has to be equally unlocked as locked - Verified by ::test_lone_unlock and ::test_lock_eq_ushrt_max |
mohamedmoawya | 0:e4c5e6ec922e | 51 | * * The function sleep_manager_lock_deep_sleep_internal() locks the automatic deep mode selection - Verified by ::test_lock_unlock |
mohamedmoawya | 0:e4c5e6ec922e | 52 | * * The function sleep_manager_unlock_deep_sleep_internal() unlocks the automatic deep mode selection - Verified by ::test_lock_unlock |
mohamedmoawya | 0:e4c5e6ec922e | 53 | * * The function sleep_manager_sleep_auto() chooses the sleep or deep sleep modes based on the lock - Verified by ::test_sleep_auto |
mohamedmoawya | 0:e4c5e6ec922e | 54 | * * The function sleep_manager_lock_deep_sleep_internal() is IRQ and thread safe - Verified by ::sleep_manager_multithread_test and ::sleep_manager_irq_test |
mohamedmoawya | 0:e4c5e6ec922e | 55 | * * The function sleep_manager_unlock_deep_sleep_internal() is IRQ and thread safe - Verified by ::sleep_manager_multithread_test and ::sleep_manager_irq_test |
mohamedmoawya | 0:e4c5e6ec922e | 56 | * * The function sleep_manager_sleep_auto() is IRQ and thread safe |
mohamedmoawya | 0:e4c5e6ec922e | 57 | * |
mohamedmoawya | 0:e4c5e6ec922e | 58 | * Example: |
mohamedmoawya | 0:e4c5e6ec922e | 59 | * @code |
mohamedmoawya | 0:e4c5e6ec922e | 60 | * |
mohamedmoawya | 0:e4c5e6ec922e | 61 | * void driver::handler() |
mohamedmoawya | 0:e4c5e6ec922e | 62 | * { |
mohamedmoawya | 0:e4c5e6ec922e | 63 | * if (_sensor.get_event()) { |
mohamedmoawya | 0:e4c5e6ec922e | 64 | * // any event - we are finished, unlock the deepsleep |
mohamedmoawya | 0:e4c5e6ec922e | 65 | * sleep_manager_unlock_deep_sleep(); |
mohamedmoawya | 0:e4c5e6ec922e | 66 | * _callback(); |
mohamedmoawya | 0:e4c5e6ec922e | 67 | * } |
mohamedmoawya | 0:e4c5e6ec922e | 68 | * } |
mohamedmoawya | 0:e4c5e6ec922e | 69 | * |
mohamedmoawya | 0:e4c5e6ec922e | 70 | * int driver::measure(event_t event, callback_t& callback) |
mohamedmoawya | 0:e4c5e6ec922e | 71 | * { |
mohamedmoawya | 0:e4c5e6ec922e | 72 | * _callback = callback; |
mohamedmoawya | 0:e4c5e6ec922e | 73 | * sleep_manager_lock_deep_sleep(); |
mohamedmoawya | 0:e4c5e6ec922e | 74 | * // start async transaction, we are waiting for an event |
mohamedmoawya | 0:e4c5e6ec922e | 75 | * return _sensor.start(event, callback); |
mohamedmoawya | 0:e4c5e6ec922e | 76 | * } |
mohamedmoawya | 0:e4c5e6ec922e | 77 | * @endcode |
mohamedmoawya | 0:e4c5e6ec922e | 78 | * @{ |
mohamedmoawya | 0:e4c5e6ec922e | 79 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 80 | |
mohamedmoawya | 0:e4c5e6ec922e | 81 | /** |
mohamedmoawya | 0:e4c5e6ec922e | 82 | * @defgroup hal_sleep_manager_tests Sleep manager API tests |
mohamedmoawya | 0:e4c5e6ec922e | 83 | * Tests to validate the proper implementation of the sleep manager |
mohamedmoawya | 0:e4c5e6ec922e | 84 | * |
mohamedmoawya | 0:e4c5e6ec922e | 85 | * To run the sleep manager hal tests use the command: |
mohamedmoawya | 0:e4c5e6ec922e | 86 | * |
mohamedmoawya | 0:e4c5e6ec922e | 87 | * mbed test -t <toolchain> -m <target> -n tests-mbed_hal-sleep_manager* |
mohamedmoawya | 0:e4c5e6ec922e | 88 | * |
mohamedmoawya | 0:e4c5e6ec922e | 89 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 90 | |
mohamedmoawya | 0:e4c5e6ec922e | 91 | #ifdef MBED_SLEEP_TRACING_ENABLED |
mohamedmoawya | 0:e4c5e6ec922e | 92 | |
mohamedmoawya | 0:e4c5e6ec922e | 93 | void sleep_tracker_lock(const char *const filename, int line); |
mohamedmoawya | 0:e4c5e6ec922e | 94 | void sleep_tracker_unlock(const char *const filename, int line); |
mohamedmoawya | 0:e4c5e6ec922e | 95 | |
mohamedmoawya | 0:e4c5e6ec922e | 96 | #define sleep_manager_lock_deep_sleep() \ |
mohamedmoawya | 0:e4c5e6ec922e | 97 | do \ |
mohamedmoawya | 0:e4c5e6ec922e | 98 | { \ |
mohamedmoawya | 0:e4c5e6ec922e | 99 | sleep_manager_lock_deep_sleep_internal(); \ |
mohamedmoawya | 0:e4c5e6ec922e | 100 | sleep_tracker_lock(MBED_FILENAME, __LINE__); \ |
mohamedmoawya | 0:e4c5e6ec922e | 101 | } while (0); |
mohamedmoawya | 0:e4c5e6ec922e | 102 | |
mohamedmoawya | 0:e4c5e6ec922e | 103 | #define sleep_manager_unlock_deep_sleep() \ |
mohamedmoawya | 0:e4c5e6ec922e | 104 | do \ |
mohamedmoawya | 0:e4c5e6ec922e | 105 | { \ |
mohamedmoawya | 0:e4c5e6ec922e | 106 | sleep_manager_unlock_deep_sleep_internal(); \ |
mohamedmoawya | 0:e4c5e6ec922e | 107 | sleep_tracker_unlock(MBED_FILENAME, __LINE__); \ |
mohamedmoawya | 0:e4c5e6ec922e | 108 | } while (0); |
mohamedmoawya | 0:e4c5e6ec922e | 109 | |
mohamedmoawya | 0:e4c5e6ec922e | 110 | #else |
mohamedmoawya | 0:e4c5e6ec922e | 111 | |
mohamedmoawya | 0:e4c5e6ec922e | 112 | #define sleep_manager_lock_deep_sleep() \ |
mohamedmoawya | 0:e4c5e6ec922e | 113 | sleep_manager_lock_deep_sleep_internal() |
mohamedmoawya | 0:e4c5e6ec922e | 114 | |
mohamedmoawya | 0:e4c5e6ec922e | 115 | #define sleep_manager_unlock_deep_sleep() \ |
mohamedmoawya | 0:e4c5e6ec922e | 116 | sleep_manager_unlock_deep_sleep_internal() |
mohamedmoawya | 0:e4c5e6ec922e | 117 | |
mohamedmoawya | 0:e4c5e6ec922e | 118 | #endif // MBED_SLEEP_TRACING_ENABLED |
mohamedmoawya | 0:e4c5e6ec922e | 119 | |
mohamedmoawya | 0:e4c5e6ec922e | 120 | /** Lock the deep sleep mode |
mohamedmoawya | 0:e4c5e6ec922e | 121 | * |
mohamedmoawya | 0:e4c5e6ec922e | 122 | * This locks the automatic deep mode selection. |
mohamedmoawya | 0:e4c5e6ec922e | 123 | * sleep_manager_sleep_auto() will ignore deepsleep mode if |
mohamedmoawya | 0:e4c5e6ec922e | 124 | * this function is invoked at least once (the internal counter is non-zero) |
mohamedmoawya | 0:e4c5e6ec922e | 125 | * |
mohamedmoawya | 0:e4c5e6ec922e | 126 | * Use this locking mechanism for interrupt driven API that are |
mohamedmoawya | 0:e4c5e6ec922e | 127 | * running in the background and deepsleep could affect their functionality |
mohamedmoawya | 0:e4c5e6ec922e | 128 | * |
mohamedmoawya | 0:e4c5e6ec922e | 129 | * The lock is a counter, can be locked up to USHRT_MAX |
mohamedmoawya | 0:e4c5e6ec922e | 130 | * This function is IRQ and thread safe |
mohamedmoawya | 0:e4c5e6ec922e | 131 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 132 | void sleep_manager_lock_deep_sleep_internal(void); |
mohamedmoawya | 0:e4c5e6ec922e | 133 | |
mohamedmoawya | 0:e4c5e6ec922e | 134 | /** Unlock the deep sleep mode |
mohamedmoawya | 0:e4c5e6ec922e | 135 | * |
mohamedmoawya | 0:e4c5e6ec922e | 136 | * Use unlocking in pair with sleep_manager_lock_deep_sleep(). |
mohamedmoawya | 0:e4c5e6ec922e | 137 | * |
mohamedmoawya | 0:e4c5e6ec922e | 138 | * The lock is a counter, should be equally unlocked as locked |
mohamedmoawya | 0:e4c5e6ec922e | 139 | * This function is IRQ and thread safe |
mohamedmoawya | 0:e4c5e6ec922e | 140 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 141 | void sleep_manager_unlock_deep_sleep_internal(void); |
mohamedmoawya | 0:e4c5e6ec922e | 142 | |
mohamedmoawya | 0:e4c5e6ec922e | 143 | /** Get the status of deep sleep allowance for a target |
mohamedmoawya | 0:e4c5e6ec922e | 144 | * |
mohamedmoawya | 0:e4c5e6ec922e | 145 | * @return true if a target can go to deepsleep, false otherwise |
mohamedmoawya | 0:e4c5e6ec922e | 146 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 147 | bool sleep_manager_can_deep_sleep(void); |
mohamedmoawya | 0:e4c5e6ec922e | 148 | |
mohamedmoawya | 0:e4c5e6ec922e | 149 | /** Check if the target can deep sleep within a period of time |
mohamedmoawya | 0:e4c5e6ec922e | 150 | * |
mohamedmoawya | 0:e4c5e6ec922e | 151 | * This function in intended for use in testing. The amount |
mohamedmoawya | 0:e4c5e6ec922e | 152 | * of time this functions waits for deeps sleep to be available |
mohamedmoawya | 0:e4c5e6ec922e | 153 | * is currently 2ms. This may change in the future depending |
mohamedmoawya | 0:e4c5e6ec922e | 154 | * on testing requirements. |
mohamedmoawya | 0:e4c5e6ec922e | 155 | * |
mohamedmoawya | 0:e4c5e6ec922e | 156 | * @return true if a target can go to deepsleep, false otherwise |
mohamedmoawya | 0:e4c5e6ec922e | 157 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 158 | bool sleep_manager_can_deep_sleep_test_check(void); |
mohamedmoawya | 0:e4c5e6ec922e | 159 | |
mohamedmoawya | 0:e4c5e6ec922e | 160 | /** Enter auto selected sleep mode. It chooses the sleep or deepsleep modes based |
mohamedmoawya | 0:e4c5e6ec922e | 161 | * on the deepsleep locking counter |
mohamedmoawya | 0:e4c5e6ec922e | 162 | * |
mohamedmoawya | 0:e4c5e6ec922e | 163 | * This function is IRQ and thread safe |
mohamedmoawya | 0:e4c5e6ec922e | 164 | * |
mohamedmoawya | 0:e4c5e6ec922e | 165 | * @note |
mohamedmoawya | 0:e4c5e6ec922e | 166 | * If MBED_DEBUG is defined, only hal_sleep is allowed. This ensures the debugger |
mohamedmoawya | 0:e4c5e6ec922e | 167 | * to be active for debug modes. |
mohamedmoawya | 0:e4c5e6ec922e | 168 | * |
mohamedmoawya | 0:e4c5e6ec922e | 169 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 170 | void sleep_manager_sleep_auto(void); |
mohamedmoawya | 0:e4c5e6ec922e | 171 | |
mohamedmoawya | 0:e4c5e6ec922e | 172 | /** Send the microcontroller to sleep |
mohamedmoawya | 0:e4c5e6ec922e | 173 | * |
mohamedmoawya | 0:e4c5e6ec922e | 174 | * @note This function can be a noop if not implemented by the platform. |
mohamedmoawya | 0:e4c5e6ec922e | 175 | * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined). |
mohamedmoawya | 0:e4c5e6ec922e | 176 | * @note This function will be a noop if the following conditions are met: |
mohamedmoawya | 0:e4c5e6ec922e | 177 | * - The RTOS is present |
mohamedmoawya | 0:e4c5e6ec922e | 178 | * - The processor turn off the Systick clock during sleep |
mohamedmoawya | 0:e4c5e6ec922e | 179 | * - The target does not implement tickless mode |
mohamedmoawya | 0:e4c5e6ec922e | 180 | * |
mohamedmoawya | 0:e4c5e6ec922e | 181 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the |
mohamedmoawya | 0:e4c5e6ec922e | 182 | * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates |
mohamedmoawya | 0:e4c5e6ec922e | 183 | * dynamic power used by the processor, memory systems and buses. The processor, peripheral and |
mohamedmoawya | 0:e4c5e6ec922e | 184 | * memory state are maintained, and the peripherals continue to work and can generate interrupts. |
mohamedmoawya | 0:e4c5e6ec922e | 185 | * |
mohamedmoawya | 0:e4c5e6ec922e | 186 | * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. |
mohamedmoawya | 0:e4c5e6ec922e | 187 | * |
mohamedmoawya | 0:e4c5e6ec922e | 188 | * @note |
mohamedmoawya | 0:e4c5e6ec922e | 189 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
mohamedmoawya | 0:e4c5e6ec922e | 190 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
mohamedmoawya | 0:e4c5e6ec922e | 191 | * able to access the LocalFileSystem |
mohamedmoawya | 0:e4c5e6ec922e | 192 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 193 | static inline void sleep(void) |
mohamedmoawya | 0:e4c5e6ec922e | 194 | { |
mohamedmoawya | 0:e4c5e6ec922e | 195 | #if DEVICE_SLEEP |
mohamedmoawya | 0:e4c5e6ec922e | 196 | #if (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_SYSTICK_CLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) |
mohamedmoawya | 0:e4c5e6ec922e | 197 | sleep_manager_sleep_auto(); |
mohamedmoawya | 0:e4c5e6ec922e | 198 | #endif /* (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_SYSTICK_CLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) */ |
mohamedmoawya | 0:e4c5e6ec922e | 199 | #endif /* DEVICE_SLEEP */ |
mohamedmoawya | 0:e4c5e6ec922e | 200 | } |
mohamedmoawya | 0:e4c5e6ec922e | 201 | |
mohamedmoawya | 0:e4c5e6ec922e | 202 | /** Send the microcontroller to deep sleep |
mohamedmoawya | 0:e4c5e6ec922e | 203 | * |
mohamedmoawya | 0:e4c5e6ec922e | 204 | * @deprecated |
mohamedmoawya | 0:e4c5e6ec922e | 205 | * Do not use this function. Applications should use sleep() API which puts the system in deepsleep mode if supported. |
mohamedmoawya | 0:e4c5e6ec922e | 206 | * |
mohamedmoawya | 0:e4c5e6ec922e | 207 | * @note This function can be a noop if not implemented by the platform. |
mohamedmoawya | 0:e4c5e6ec922e | 208 | * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined) |
mohamedmoawya | 0:e4c5e6ec922e | 209 | * |
mohamedmoawya | 0:e4c5e6ec922e | 210 | * This processor is setup ready for deep sleep, and sent to sleep. This mode |
mohamedmoawya | 0:e4c5e6ec922e | 211 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state |
mohamedmoawya | 0:e4c5e6ec922e | 212 | * is still maintained. |
mohamedmoawya | 0:e4c5e6ec922e | 213 | * |
mohamedmoawya | 0:e4c5e6ec922e | 214 | * The processor can only be woken up by an external interrupt on a pin or a watchdog timer. |
mohamedmoawya | 0:e4c5e6ec922e | 215 | * |
mohamedmoawya | 0:e4c5e6ec922e | 216 | * @note |
mohamedmoawya | 0:e4c5e6ec922e | 217 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
mohamedmoawya | 0:e4c5e6ec922e | 218 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
mohamedmoawya | 0:e4c5e6ec922e | 219 | * able to access the LocalFileSystem |
mohamedmoawya | 0:e4c5e6ec922e | 220 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 221 | |
mohamedmoawya | 0:e4c5e6ec922e | 222 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "One entry point for an application, use sleep()") |
mohamedmoawya | 0:e4c5e6ec922e | 223 | static inline void deepsleep(void) |
mohamedmoawya | 0:e4c5e6ec922e | 224 | { |
mohamedmoawya | 0:e4c5e6ec922e | 225 | #if DEVICE_SLEEP |
mohamedmoawya | 0:e4c5e6ec922e | 226 | sleep_manager_sleep_auto(); |
mohamedmoawya | 0:e4c5e6ec922e | 227 | #endif /* DEVICE_SLEEP */ |
mohamedmoawya | 0:e4c5e6ec922e | 228 | } |
mohamedmoawya | 0:e4c5e6ec922e | 229 | |
mohamedmoawya | 0:e4c5e6ec922e | 230 | /** Provides the time spent in sleep mode since boot. |
mohamedmoawya | 0:e4c5e6ec922e | 231 | * |
mohamedmoawya | 0:e4c5e6ec922e | 232 | * @return Time spent in sleep |
mohamedmoawya | 0:e4c5e6ec922e | 233 | * @note Works only if platform supports LP ticker. |
mohamedmoawya | 0:e4c5e6ec922e | 234 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 235 | us_timestamp_t mbed_time_sleep(void); |
mohamedmoawya | 0:e4c5e6ec922e | 236 | |
mohamedmoawya | 0:e4c5e6ec922e | 237 | /** Provides the time spent in deep sleep mode since boot. |
mohamedmoawya | 0:e4c5e6ec922e | 238 | * |
mohamedmoawya | 0:e4c5e6ec922e | 239 | * @return Time spent in deep sleep |
mohamedmoawya | 0:e4c5e6ec922e | 240 | * @note Works only if platform supports LP ticker. |
mohamedmoawya | 0:e4c5e6ec922e | 241 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 242 | us_timestamp_t mbed_time_deepsleep(void); |
mohamedmoawya | 0:e4c5e6ec922e | 243 | |
mohamedmoawya | 0:e4c5e6ec922e | 244 | /** Provides the time spent in idle mode since boot. |
mohamedmoawya | 0:e4c5e6ec922e | 245 | * |
mohamedmoawya | 0:e4c5e6ec922e | 246 | * @return Idle thread time. |
mohamedmoawya | 0:e4c5e6ec922e | 247 | * @note Works only if platform supports LP ticker. |
mohamedmoawya | 0:e4c5e6ec922e | 248 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 249 | us_timestamp_t mbed_time_idle(void); |
mohamedmoawya | 0:e4c5e6ec922e | 250 | |
mohamedmoawya | 0:e4c5e6ec922e | 251 | /** Provides the time since the system is up i.e. boot. |
mohamedmoawya | 0:e4c5e6ec922e | 252 | * |
mohamedmoawya | 0:e4c5e6ec922e | 253 | * @return System uptime. |
mohamedmoawya | 0:e4c5e6ec922e | 254 | * @note Works only if platform supports LP ticker. |
mohamedmoawya | 0:e4c5e6ec922e | 255 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 256 | us_timestamp_t mbed_uptime(void); |
mohamedmoawya | 0:e4c5e6ec922e | 257 | |
mohamedmoawya | 0:e4c5e6ec922e | 258 | /** @}*/ |
mohamedmoawya | 0:e4c5e6ec922e | 259 | |
mohamedmoawya | 0:e4c5e6ec922e | 260 | /** Resets the processor and most of the sub-system |
mohamedmoawya | 0:e4c5e6ec922e | 261 | * |
mohamedmoawya | 0:e4c5e6ec922e | 262 | * @note Does not affect the debug sub-system |
mohamedmoawya | 0:e4c5e6ec922e | 263 | */ |
mohamedmoawya | 0:e4c5e6ec922e | 264 | static inline void system_reset(void) |
mohamedmoawya | 0:e4c5e6ec922e | 265 | { |
mohamedmoawya | 0:e4c5e6ec922e | 266 | NVIC_SystemReset(); |
mohamedmoawya | 0:e4c5e6ec922e | 267 | } |
mohamedmoawya | 0:e4c5e6ec922e | 268 | |
mohamedmoawya | 0:e4c5e6ec922e | 269 | #ifdef __cplusplus |
mohamedmoawya | 0:e4c5e6ec922e | 270 | } |
mohamedmoawya | 0:e4c5e6ec922e | 271 | #endif |
mohamedmoawya | 0:e4c5e6ec922e | 272 | |
mohamedmoawya | 0:e4c5e6ec922e | 273 | #endif |
mohamedmoawya | 0:e4c5e6ec922e | 274 | |
mohamedmoawya | 0:e4c5e6ec922e | 275 | /** @}*/ |
mohamedmoawya | 0:e4c5e6ec922e | 276 | /** @}*/ |