mbed-os
Fork of mbed-os by
targets/TARGET_ONSEMI/TARGET_NCS36510/sleep_api.c@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | /** |
elessair | 0:f269e3021894 | 2 | ******************************************************************************* |
elessair | 0:f269e3021894 | 3 | * @file sleep_api.c |
elessair | 0:f269e3021894 | 4 | * @brief Implementation of a sleep functionality |
elessair | 0:f269e3021894 | 5 | * @internal |
elessair | 0:f269e3021894 | 6 | * @author ON Semiconductor |
elessair | 0:f269e3021894 | 7 | * $Rev: $ |
elessair | 0:f269e3021894 | 8 | * $Date: $ |
elessair | 0:f269e3021894 | 9 | ****************************************************************************** |
elessair | 0:f269e3021894 | 10 | * Copyright 2016 Semiconductor Components Industries LLC (d/b/a ON Semiconductor). |
elessair | 0:f269e3021894 | 11 | * All rights reserved. This software and/or documentation is licensed by ON Semiconductor |
elessair | 0:f269e3021894 | 12 | * under limited terms and conditions. The terms and conditions pertaining to the software |
elessair | 0:f269e3021894 | 13 | * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf |
elessair | 0:f269e3021894 | 14 | * (ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software) and |
elessair | 0:f269e3021894 | 15 | * if applicable the software license agreement. Do not use this software and/or |
elessair | 0:f269e3021894 | 16 | * documentation unless you have carefully read and you agree to the limited terms and |
elessair | 0:f269e3021894 | 17 | * conditions. By using this software and/or documentation, you agree to the limited |
elessair | 0:f269e3021894 | 18 | * terms and conditions. |
elessair | 0:f269e3021894 | 19 | |
elessair | 0:f269e3021894 | 20 | * |
elessair | 0:f269e3021894 | 21 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
elessair | 0:f269e3021894 | 22 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
elessair | 0:f269e3021894 | 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
elessair | 0:f269e3021894 | 24 | * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, |
elessair | 0:f269e3021894 | 25 | * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
elessair | 0:f269e3021894 | 26 | * @endinternal |
elessair | 0:f269e3021894 | 27 | * |
elessair | 0:f269e3021894 | 28 | * @ingroup sleep |
elessair | 0:f269e3021894 | 29 | * |
elessair | 0:f269e3021894 | 30 | * @details |
elessair | 0:f269e3021894 | 31 | * Sleep implementation TBD - Dummy function is fine for first release |
elessair | 0:f269e3021894 | 32 | * |
elessair | 0:f269e3021894 | 33 | */ |
elessair | 0:f269e3021894 | 34 | |
elessair | 0:f269e3021894 | 35 | #if DEVICE_SLEEP |
elessair | 0:f269e3021894 | 36 | #include "sleep.h" |
elessair | 0:f269e3021894 | 37 | #include "sleep_api.h" |
elessair | 0:f269e3021894 | 38 | #include "cmsis_nvic.h" |
elessair | 0:f269e3021894 | 39 | |
elessair | 0:f269e3021894 | 40 | void mbed_enter_sleep(sleep_t *obj) |
elessair | 0:f269e3021894 | 41 | { |
elessair | 0:f269e3021894 | 42 | |
elessair | 0:f269e3021894 | 43 | #ifdef SLEEP_TYPE_DEFAULT |
elessair | 0:f269e3021894 | 44 | |
elessair | 0:f269e3021894 | 45 | if(SLEEP_TYPE_DEFAULT == SLEEP_TYPE_SLEEP) { |
elessair | 0:f269e3021894 | 46 | /* Sleep mode */ |
elessair | 0:f269e3021894 | 47 | sleep(); |
elessair | 0:f269e3021894 | 48 | } else if(SLEEP_TYPE_DEFAULT == SLEEP_TYPE_DEEPSLEEP) { |
elessair | 0:f269e3021894 | 49 | /* Deep Sleep mode */ |
elessair | 0:f269e3021894 | 50 | deepsleep(); |
elessair | 0:f269e3021894 | 51 | } else { |
elessair | 0:f269e3021894 | 52 | /* Coma mode */ |
elessair | 0:f269e3021894 | 53 | coma(); |
elessair | 0:f269e3021894 | 54 | } |
elessair | 0:f269e3021894 | 55 | |
elessair | 0:f269e3021894 | 56 | #else |
elessair | 0:f269e3021894 | 57 | |
elessair | 0:f269e3021894 | 58 | if(obj->SleepType == SLEEP_TYPE_NONE) { |
elessair | 0:f269e3021894 | 59 | /* Select low power mode based on sleep duration */ |
elessair | 0:f269e3021894 | 60 | |
elessair | 0:f269e3021894 | 61 | if(obj->timeToSleep <= SLEEP_DURATION_SLEEP_MAX) { |
elessair | 0:f269e3021894 | 62 | /* Sleep mode */ |
elessair | 0:f269e3021894 | 63 | sleep(); |
elessair | 0:f269e3021894 | 64 | } else if(obj->timeToSleep <= SLEEP_DURATION_DEEPSLEEP_MAX) { |
elessair | 0:f269e3021894 | 65 | /* Deep sleep */ |
elessair | 0:f269e3021894 | 66 | deepsleep(); |
elessair | 0:f269e3021894 | 67 | } else { |
elessair | 0:f269e3021894 | 68 | /* Coma */ |
elessair | 0:f269e3021894 | 69 | coma(); |
elessair | 0:f269e3021894 | 70 | } |
elessair | 0:f269e3021894 | 71 | } else if(obj->SleepType == SLEEP_TYPE_SLEEP) { |
elessair | 0:f269e3021894 | 72 | /* Sleep mode */ |
elessair | 0:f269e3021894 | 73 | sleep(); |
elessair | 0:f269e3021894 | 74 | } else if(obj->SleepType == SLEEP_TYPE_DEEPSLEEP) { |
elessair | 0:f269e3021894 | 75 | /* Deep Sleep mode */ |
elessair | 0:f269e3021894 | 76 | deepsleep(); |
elessair | 0:f269e3021894 | 77 | } else { |
elessair | 0:f269e3021894 | 78 | /* Coma mode */ |
elessair | 0:f269e3021894 | 79 | coma(); |
elessair | 0:f269e3021894 | 80 | } |
elessair | 0:f269e3021894 | 81 | |
elessair | 0:f269e3021894 | 82 | #endif |
elessair | 0:f269e3021894 | 83 | } |
elessair | 0:f269e3021894 | 84 | |
elessair | 0:f269e3021894 | 85 | void mbed_exit_sleep(sleep_t *obj) |
elessair | 0:f269e3021894 | 86 | { |
elessair | 0:f269e3021894 | 87 | (void)obj; |
elessair | 0:f269e3021894 | 88 | } |
elessair | 0:f269e3021894 | 89 | |
elessair | 0:f269e3021894 | 90 | #endif /* DEVICE_SLEEP */ |