Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-os/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/sleep_api.c@0:4beb2ea291ec, 2020-03-16 (annotated)
- Committer:
- boro
- Date:
- Mon Mar 16 13:12:31 2020 +0000
- Revision:
- 0:4beb2ea291ec
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
boro | 0:4beb2ea291ec | 1 | /* mbed Microcontroller Library |
boro | 0:4beb2ea291ec | 2 | * Copyright (c) 2006-2015 ARM Limited |
boro | 0:4beb2ea291ec | 3 | * |
boro | 0:4beb2ea291ec | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
boro | 0:4beb2ea291ec | 5 | * you may not use this file except in compliance with the License. |
boro | 0:4beb2ea291ec | 6 | * You may obtain a copy of the License at |
boro | 0:4beb2ea291ec | 7 | * |
boro | 0:4beb2ea291ec | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
boro | 0:4beb2ea291ec | 9 | * |
boro | 0:4beb2ea291ec | 10 | * Unless required by applicable law or agreed to in writing, software |
boro | 0:4beb2ea291ec | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
boro | 0:4beb2ea291ec | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
boro | 0:4beb2ea291ec | 13 | * See the License for the specific language governing permissions and |
boro | 0:4beb2ea291ec | 14 | * limitations under the License. |
boro | 0:4beb2ea291ec | 15 | */ |
boro | 0:4beb2ea291ec | 16 | #include "mbed_assert.h" |
boro | 0:4beb2ea291ec | 17 | #include "sleep_api.h" |
boro | 0:4beb2ea291ec | 18 | |
boro | 0:4beb2ea291ec | 19 | #include "power.h" |
boro | 0:4beb2ea291ec | 20 | |
boro | 0:4beb2ea291ec | 21 | /** Send the device to sleep |
boro | 0:4beb2ea291ec | 22 | * |
boro | 0:4beb2ea291ec | 23 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the |
boro | 0:4beb2ea291ec | 24 | * system clock to the core is stopped until a reset or an interrupt occurs. |
boro | 0:4beb2ea291ec | 25 | * @param[void] void |
boro | 0:4beb2ea291ec | 26 | * @return void |
boro | 0:4beb2ea291ec | 27 | */ |
boro | 0:4beb2ea291ec | 28 | void hal_sleep(void) |
boro | 0:4beb2ea291ec | 29 | { |
boro | 0:4beb2ea291ec | 30 | #if (SAMD21) || (SAMR21) |
boro | 0:4beb2ea291ec | 31 | system_set_sleepmode(SYSTEM_SLEEPMODE_IDLE_2); |
boro | 0:4beb2ea291ec | 32 | #elif (SAML21) |
boro | 0:4beb2ea291ec | 33 | system_set_sleepmode(SYSTEM_SLEEPMODE_IDLE); |
boro | 0:4beb2ea291ec | 34 | #endif |
boro | 0:4beb2ea291ec | 35 | system_sleep(); |
boro | 0:4beb2ea291ec | 36 | } |
boro | 0:4beb2ea291ec | 37 | |
boro | 0:4beb2ea291ec | 38 | /** Send the device to deep sleep |
boro | 0:4beb2ea291ec | 39 | * |
boro | 0:4beb2ea291ec | 40 | * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode |
boro | 0:4beb2ea291ec | 41 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state |
boro | 0:4beb2ea291ec | 42 | * is still maintained. |
boro | 0:4beb2ea291ec | 43 | * @param[void] void |
boro | 0:4beb2ea291ec | 44 | * @return void |
boro | 0:4beb2ea291ec | 45 | */ |
boro | 0:4beb2ea291ec | 46 | void hal_deepsleep(void) |
boro | 0:4beb2ea291ec | 47 | { |
boro | 0:4beb2ea291ec | 48 | system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY); |
boro | 0:4beb2ea291ec | 49 | system_sleep(); |
boro | 0:4beb2ea291ec | 50 | } |