Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 #if !DEVICE_LOCALFILESYSTEM 00004 #error [NOT_SUPPORTED] LocalFileSystem not supported 00005 #endif 00006 00007 #include "TextLCD.h" 00008 00009 int main() { 00010 printf("printf to stdout\n"); 00011 00012 // printf to specific peripherals 00013 Serial pc(USBTX, USBRX); 00014 pc.printf("Serial(USBTX, USBRX).printf\n"); 00015 00016 TextLCD lcd(p14, p15, p16, p17, p18, p19, p20, "lcd"); // rs, rw, e, d0-d3, name 00017 lcd.printf("TextLCD.printf\n"); 00018 00019 // change stdout to file 00020 LocalFileSystem local("local"); 00021 freopen("/local/output.txt", "w", stdout); 00022 printf("printf redirected to LocalFileSystem\n"); 00023 fclose(stdout); 00024 00025 // change stdout to LCD 00026 freopen("/lcd", "w", stdout); 00027 printf("printf redirected to TextLCD\n"); 00028 fclose(stdout); 00029 00030 DigitalOut led(LED1); 00031 while (true) { 00032 led = !led; 00033 wait(1); 00034 } 00035 }
Generated on Sun Jul 17 2022 08:25:26 by 1.7.2