mbed os with nrf51 internal bandgap enabled to read battery level
Dependents: BLE_file_test BLE_Blink ExternalEncoder
TESTS/mbed_drivers/rtc/main.cpp@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 | * Copyright (c) 2013-2016, ARM Limited, All Rights Reserved |
elessair | 0:f269e3021894 | 3 | * SPDX-License-Identifier: Apache-2.0 |
elessair | 0:f269e3021894 | 4 | * |
elessair | 0:f269e3021894 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
elessair | 0:f269e3021894 | 6 | * not use this file except in compliance with the License. |
elessair | 0:f269e3021894 | 7 | * You may obtain a copy of the License at |
elessair | 0:f269e3021894 | 8 | * |
elessair | 0:f269e3021894 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
elessair | 0:f269e3021894 | 10 | * |
elessair | 0:f269e3021894 | 11 | * Unless required by applicable law or agreed to in writing, software |
elessair | 0:f269e3021894 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
elessair | 0:f269e3021894 | 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
elessair | 0:f269e3021894 | 14 | * See the License for the specific language governing permissions and |
elessair | 0:f269e3021894 | 15 | * limitations under the License. |
elessair | 0:f269e3021894 | 16 | */ |
elessair | 0:f269e3021894 | 17 | #include "mbed.h" |
elessair | 0:f269e3021894 | 18 | #include "greentea-client/test_env.h" |
elessair | 0:f269e3021894 | 19 | #include "unity/unity.h" |
elessair | 0:f269e3021894 | 20 | #include "utest/utest.h" |
elessair | 0:f269e3021894 | 21 | |
elessair | 0:f269e3021894 | 22 | using namespace utest::v1; |
elessair | 0:f269e3021894 | 23 | |
elessair | 0:f269e3021894 | 24 | #define CUSTOM_TIME 1256729737 |
elessair | 0:f269e3021894 | 25 | |
elessair | 0:f269e3021894 | 26 | void test_case_rtc_strftime() { |
elessair | 0:f269e3021894 | 27 | greentea_send_kv("timestamp", CUSTOM_TIME); |
elessair | 0:f269e3021894 | 28 | |
elessair | 0:f269e3021894 | 29 | char buffer[32] = {0}; |
elessair | 0:f269e3021894 | 30 | char kv_buff[64] = {0}; |
elessair | 0:f269e3021894 | 31 | set_time(CUSTOM_TIME); // Set RTC time to Wed, 28 Oct 2009 11:35:37 |
elessair | 0:f269e3021894 | 32 | |
elessair | 0:f269e3021894 | 33 | for (int i=0; i<10; ++i) { |
elessair | 0:f269e3021894 | 34 | time_t seconds = time(NULL); |
elessair | 0:f269e3021894 | 35 | sprintf(kv_buff, "[%ld] ", seconds); |
elessair | 0:f269e3021894 | 36 | strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S %p", localtime(&seconds)); |
elessair | 0:f269e3021894 | 37 | strcat(kv_buff, buffer); |
elessair | 0:f269e3021894 | 38 | greentea_send_kv("rtc", kv_buff); |
elessair | 0:f269e3021894 | 39 | wait(1); |
elessair | 0:f269e3021894 | 40 | } |
elessair | 0:f269e3021894 | 41 | } |
elessair | 0:f269e3021894 | 42 | |
elessair | 0:f269e3021894 | 43 | Case cases[] = { |
elessair | 0:f269e3021894 | 44 | Case("RTC strftime", test_case_rtc_strftime), |
elessair | 0:f269e3021894 | 45 | }; |
elessair | 0:f269e3021894 | 46 | |
elessair | 0:f269e3021894 | 47 | utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { |
elessair | 0:f269e3021894 | 48 | GREENTEA_SETUP(20, "rtc_auto"); |
elessair | 0:f269e3021894 | 49 | return greentea_test_setup_handler(number_of_cases); |
elessair | 0:f269e3021894 | 50 | } |
elessair | 0:f269e3021894 | 51 | |
elessair | 0:f269e3021894 | 52 | Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); |
elessair | 0:f269e3021894 | 53 | |
elessair | 0:f269e3021894 | 54 | int main() { |
elessair | 0:f269e3021894 | 55 | Harness::run(specification); |
elessair | 0:f269e3021894 | 56 | } |