UART Command Parser Time Manager Data Store for SD Card for stm32l476 [it's not Licensed as BSD/GPLx]

Dependencies:   mbed SDFileSystem

main.cpp

Committer:
Inscape_ao
Date:
2019-04-21
Revision:
1:71c9c97c9f3d
Parent:
0:c347f602596d
Child:
2:a694440145e9

File content as of revision 1:71c9c97c9f3d:

/** --- Includes --- */
#include "mbed.h"
#include "UartReceiver.h"
#include "CommandParser.h"
#include "global.h"
#include "string.h"

/** --- Global Variables --- */
Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut myled(LED1);
    
/** --- Prototypes --- */
/** --- Static functions --- */
static int sampleHanlder(CommandParser *pC, char *arg)
{
    pc.printf("[sampleHanlder] ARG=%s[EOL]", arg);
    pC->reply();
    return 0;
}

CmdParseRule rules[] = {
    {"CMD", sampleHanlder},
    };

static inline int getNumOfRules(void)
{
    return sizeof(rules)/sizeof(CmdParseRule);
}

/** --- 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, getNumOfRules());
    pCP->run();
    
    pc.printf("Hello World !\n");
    while(1) {
        wait(1);
        pc.printf("This program runs since %d seconds.\n", i++);
        myled = !myled;
    }
}