xrocusOS_ADXL355 version
Dependencies: mbed SDFileSystem
Diff: main.cpp
- Revision:
- 0:c347f602596d
- Child:
- 1:71c9c97c9f3d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Apr 20 09:23:39 2019 +0000 @@ -0,0 +1,50 @@ +/** --- Includes --- */ +#include "mbed.h" +#include "UartReceiver.h" +#include "CommandParser.h" +#include "global.h" +#include "string.h" + + +class CommandParser; + +/** --- Global Variables --- */ +Serial pc(SERIAL_TX, SERIAL_RX); +DigitalOut myled(LED1); + +/** --- Prototypes --- */ +/** --- Static functions --- */ +static int sampleHanlder(char *arg) +{ + pc.printf("[sampleHanlder] ARG=%s[EOL]", arg); + return 0; +} + +CmdParseRule rules[] = { + {"CMD", sampleHanlder}, + }; + +/** --- main --- */ +int main() +{ + int i = 1; + + /** UART Initalizer */ + /* setup UART 115200, 8bit, Parity=None, stopbit:1bit */ + /* https://os.mbed.com/users/okini3939/notebook/Serial_jp/ */ + pc.baud(115200); + pc.format(8, Serial::None, 1); + + /* Receive Buffer Control */ + pUR = new UartReceiver(&pc); + /* Generate Command parser as DeviceID = 0, ParsingRule = rules */ + pCP = new CommandParser(pUR, 0, rules, sizeof(rules)/sizeof(CmdParseRule)); + pCP->run(); + + pc.printf("Hello World !\n"); + while(1) { + wait(1); + pc.printf("This program runs since %d seconds.\n", i++); + myled = !myled; + } +}