2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

main.cpp

Committer:
shimniok
Date:
2018-12-03
Revision:
4:de7feb458652
Parent:
1:7019a60fd585
Child:
7:1f2661b840ed

File content as of revision 4:de7feb458652:

/* mbed Microcontroller Library
 * Copyright (c) 2018 ARM Limited
 * SPDX-License-Identifier: Apache-2.0
 */

#include "mbed.h"
#include <stdio.h>
#include <errno.h>
#include "stats_report.h"
#include "SDBlockDevice.h"
#include "FATFileSystem.h"
#include "SimpleShell.h"
#include "Config.h"

Serial pc(USBTX, USBRX);
//SDBlockDevice bd(p5, p6, p7, p8); // MOSI, MISO, CLK, CS
//FATFileSystem ffs("log", &bd);
LocalFileSystem lfs("etc");
Config config;
SimpleShell sh;

DigitalOut led1(LED1);

Thread thread;

void test() {
    printf("Hello world!\n");
}


// main() runs in its own thread in the OS
int main()
{
    printf("Bootup...\n");
    fflush(stdout);
    
    printf("Loading config...\n");
    if (config.load("/etc/2018cfg.txt")) {
        printf("error loading config\n");
    }
    
    sh.attach(test, "test");
    
    thread.start(callback(&sh, &SimpleShell::run));

/*
    FILE *fp;
    char buf[128];
    printf("Initializing the block device... ");
    fflush(stdout);
    int err = bd.init();
    printf("%s\n", (err ? "Fail :(" : "OK"));

    printf("Opening sdtest.txt...");
    fp = fopen("/log/sdtest.txt", "r");
    if(fp) {
        while (!feof(fp)) {
            fgets(buf, 127, fp);
            printf(buf);
        }
        fclose(fp);
    }
  
    printf("Opening config.txt...");
    fp = fopen("/etc/config.txt", "r");
    if(fp) {
        while (!feof(fp)) {
            fgets(buf, 127, fp);
            printf(buf);
        }
        fclose(fp);
    }
*/  

    //SystemReport sys_state(500);

    while (true) {
        // Blink LED and wait 0.5 seconds
        led1 = !led1;
        wait(0.5f);

        // Following the main thread wait, report on the current system status
        //sys_state.report_state();
    }
}