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.
pal_rtos_test_main_mbedOS.cpp
00001 /* 00002 * Copyright (c) 2016 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "mbed.h" 00018 #include "rtos.h" 00019 00020 DigitalOut led1(LED1); 00021 InterruptIn sw2(SW2); 00022 uint32_t button_pressed; 00023 Thread *thread2; 00024 00025 void sw2_press(void) 00026 { 00027 thread2->signal_set(0x1); 00028 } 00029 00030 void led_thread(void const *argument) 00031 { 00032 while (true) { 00033 led1 = !led1; 00034 Thread::wait(1000); 00035 } 00036 } 00037 00038 void button_thread(void const *argument) 00039 { 00040 while (true) { 00041 Thread::signal_wait(0x1); 00042 button_pressed++; 00043 } 00044 } 00045 00046 // Run all the unity tests 00047 //extern "C" void RunAllTests(void); 00048 // Include explicitly and not using the h file because we are compiling this file with C++ and the h file does not 00049 // declare it extern "C" 00050 extern "C" int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); 00051 00052 extern "C" void TEST_pal_rtos_GROUP_RUNNER(void); 00053 00054 int main(int argc, const char * argv[]) 00055 { 00056 const char * myargv[] = {"app","-v"}; 00057 00058 Thread::wait(2000); 00059 printf("Start tests\n"); 00060 fflush(stdout); 00061 00062 UnityMain(sizeof(myargv)/sizeof(myargv[0]), myargv, TEST_pal_rtos_GROUP_RUNNER); 00063 00064 // This is detected by test runner app, so that it can know when to terminate without waiting for timeout. 00065 printf("***END OF TESTS**\n");for(int i=0;i<1000;i++)putchar('x');putchar('\n'); 00066 fflush(stdout); 00067 }
Generated on Tue Jul 12 2022 21:20:29 by
1.7.2