Ram Gandikota / Mbed OS ABCD
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pal_socket_test_main_mbedOS.cpp Source File

pal_socket_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 = 0;
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 
00047 // Run all the unity tests
00048 //extern "C" void RunAllTests(void);
00049 // Include explicitly and not using the h file because we are compiling this file with C++ and the h file does not
00050 // declare it extern "C"
00051 extern "C" int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
00052 
00053 extern "C" void TEST_pal_socket_GROUP_RUNNER(void);
00054 
00055 int main(int argc, const char * argv[])
00056 {
00057     const char * myargv[] = {"app","-v"};
00058 
00059     Thread::wait(2000);
00060     printf("Start tests\n");
00061     fflush(stdout);
00062 
00063     UnityMain(sizeof(myargv)/sizeof(myargv[0]), myargv, TEST_pal_socket_GROUP_RUNNER);
00064 
00065     // This is detected by test runner app, so that it can know when to terminate without waiting for timeout.
00066     printf("***END OF TESTS**\n");for(int i=0;i<1000;i++)putchar('x');putchar('\n');
00067     fflush(stdout);
00068 }