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.
Fork of mbed-os by
main.cpp
00001 /* 00002 * Copyright (c) 2013-2016, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #include "mbed.h" 00018 #include "greentea-client/test_env.h" 00019 #include "utest/utest.h" 00020 00021 using namespace utest::v1; 00022 00023 Timeout timeout; 00024 DigitalOut led(LED1); 00025 volatile int ticker_count = 0; 00026 volatile bool print_tick = false; 00027 static const int total_ticks = 10; 00028 const int ONE_SECOND_US = 1000000; 00029 00030 void send_kv_tick() { 00031 if (ticker_count <= total_ticks) { 00032 timeout.attach_us(send_kv_tick, ONE_SECOND_US); 00033 print_tick = true; 00034 } 00035 } 00036 00037 void wait_and_print() { 00038 while(ticker_count <= total_ticks) { 00039 if (print_tick) { 00040 print_tick = false; 00041 greentea_send_kv("tick", ticker_count++); 00042 led = !led; 00043 } 00044 } 00045 } 00046 00047 void test_case_ticker() { 00048 timeout.attach_us(send_kv_tick, ONE_SECOND_US); 00049 wait_and_print(); 00050 } 00051 00052 // Test cases 00053 Case cases[] = { 00054 Case("Timers: toggle on/off", test_case_ticker), 00055 }; 00056 00057 utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { 00058 GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto"); 00059 return greentea_test_setup_handler(number_of_cases); 00060 } 00061 00062 Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); 00063 00064 int main() { 00065 Harness::run(specification); 00066 } 00067
Generated on Tue Jul 12 2022 13:15:58 by
