Hiroshi SAKAMOTO / Mbed 2 deprecated test-thread-12112902

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 #include<vector>
00004 
00005 LocalFileSystem local("local");
00006 Serial pc(USBTX, USBRX);
00007 DigitalOut myled(LED4);
00008 Queue<uint32_t, 5> queue;
00009 
00010 
00011 void indicater(void const *args)
00012 {
00013     printf(">led thread start\r\n");
00014 //    int n;
00015     FILE *fp = fopen("/local/test02.txt", "w"); 
00016     fprintf(fp, "Hello file system from thread!\n");
00017     fclose(fp);
00018     while(1){
00019 //    for(n=0; n < 100; n++){
00020         myled = 1;
00021         Thread::wait(500);
00022         myled = 0;
00023         Thread::wait(500);
00024     }
00025     while(1){Thread::wait(500);}
00026 }
00027 
00028 int main(void)
00029 {
00030     pc.baud(921600);
00031     printf("\r\n==== mbed program start ====\r\n");
00032     printf("%s\r\n", __FILE__);
00033     Thread th_console_out(indicater);
00034     FILE *fp = fopen("/local/test01.txt", "w"); 
00035     fprintf(fp, "Hello file system from main()!\n");
00036     fclose(fp);
00037     wait(3);
00038     th_console_out.terminate();
00039     wait(1);
00040     printf("=== mbed program end ====\r\n");
00041     exit(1);
00042 }