simple program for rtos thread test.

Dependencies:   mbed-rtos mbed

threadの解説は、

http://mbed.org/users/takashikojo/notebook/r/

が詳しいです。

main.cpp

Committer:
hayashiisme
Date:
2013-01-17
Revision:
0:9c5cee1cb2ba

File content as of revision 0:9c5cee1cb2ba:

#include "mbed.h"
#include "rtos.h"
#include<vector>

LocalFileSystem local("local");
Serial pc(USBTX, USBRX);
DigitalOut myled(LED4);
Queue<uint32_t, 5> queue;


void indicater(void const *args)
{
    printf(">led thread start\r\n");
//    int n;
    FILE *fp = fopen("/local/test02.txt", "w"); 
    fprintf(fp, "Hello file system from thread!\n");
    fclose(fp);
    while(1){
//    for(n=0; n < 100; n++){
        myled = 1;
        Thread::wait(500);
        myled = 0;
        Thread::wait(500);
    }
    while(1){Thread::wait(500);}
}

int main(void)
{
    pc.baud(921600);
    printf("\r\n==== mbed program start ====\r\n");
    printf("%s\r\n", __FILE__);
    Thread th_console_out(indicater);
    FILE *fp = fopen("/local/test01.txt", "w"); 
    fprintf(fp, "Hello file system from main()!\n");
    fclose(fp);
    wait(3);
    th_console_out.terminate();
    wait(1);
    printf("=== mbed program end ====\r\n");
    exit(1);
}