2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Committer:
shimniok
Date:
Sun Dec 02 16:50:51 2018 +0000
Revision:
1:7019a60fd585
Parent:
0:7e98bbfd102a
Child:
4:de7feb458652
added command attach and test command

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:7e98bbfd102a 1 /* mbed Microcontroller Library
shimniok 0:7e98bbfd102a 2 * Copyright (c) 2018 ARM Limited
shimniok 0:7e98bbfd102a 3 * SPDX-License-Identifier: Apache-2.0
shimniok 0:7e98bbfd102a 4 */
shimniok 0:7e98bbfd102a 5
shimniok 0:7e98bbfd102a 6 #include "mbed.h"
shimniok 0:7e98bbfd102a 7 #include <stdio.h>
shimniok 0:7e98bbfd102a 8 #include <errno.h>
shimniok 0:7e98bbfd102a 9 #include "stats_report.h"
shimniok 0:7e98bbfd102a 10 #include "SDBlockDevice.h"
shimniok 0:7e98bbfd102a 11 #include "FATFileSystem.h"
shimniok 0:7e98bbfd102a 12 #include "SimpleShell.h"
shimniok 0:7e98bbfd102a 13
shimniok 0:7e98bbfd102a 14 Serial pc(USBTX, USBRX);
shimniok 0:7e98bbfd102a 15 //SDBlockDevice bd(p5, p6, p7, p8); // MOSI, MISO, CLK, CS
shimniok 0:7e98bbfd102a 16 //FATFileSystem ffs("log", &bd);
shimniok 0:7e98bbfd102a 17 LocalFileSystem lfs("etc");
shimniok 0:7e98bbfd102a 18
shimniok 0:7e98bbfd102a 19 SimpleShell sh;
shimniok 0:7e98bbfd102a 20
shimniok 0:7e98bbfd102a 21 DigitalOut led1(LED1);
shimniok 0:7e98bbfd102a 22
shimniok 0:7e98bbfd102a 23 Thread thread;
shimniok 0:7e98bbfd102a 24
shimniok 1:7019a60fd585 25 void test() {
shimniok 1:7019a60fd585 26 printf("Hello world!\n");
shimniok 1:7019a60fd585 27 }
shimniok 1:7019a60fd585 28
shimniok 1:7019a60fd585 29
shimniok 0:7e98bbfd102a 30 // main() runs in its own thread in the OS
shimniok 0:7e98bbfd102a 31 int main()
shimniok 0:7e98bbfd102a 32 {
shimniok 0:7e98bbfd102a 33 printf("Bootup...\n");
shimniok 0:7e98bbfd102a 34 fflush(stdout);
shimniok 1:7019a60fd585 35
shimniok 1:7019a60fd585 36 sh.attach(test, "test");
shimniok 1:7019a60fd585 37
shimniok 0:7e98bbfd102a 38 thread.start(callback(&sh, &SimpleShell::run));
shimniok 0:7e98bbfd102a 39
shimniok 0:7e98bbfd102a 40 /*
shimniok 0:7e98bbfd102a 41 FILE *fp;
shimniok 0:7e98bbfd102a 42 char buf[128];
shimniok 0:7e98bbfd102a 43 printf("Initializing the block device... ");
shimniok 0:7e98bbfd102a 44 fflush(stdout);
shimniok 0:7e98bbfd102a 45 int err = bd.init();
shimniok 0:7e98bbfd102a 46 printf("%s\n", (err ? "Fail :(" : "OK"));
shimniok 0:7e98bbfd102a 47
shimniok 0:7e98bbfd102a 48 printf("Opening sdtest.txt...");
shimniok 0:7e98bbfd102a 49 fp = fopen("/log/sdtest.txt", "r");
shimniok 0:7e98bbfd102a 50 if(fp) {
shimniok 0:7e98bbfd102a 51 while (!feof(fp)) {
shimniok 0:7e98bbfd102a 52 fgets(buf, 127, fp);
shimniok 0:7e98bbfd102a 53 printf(buf);
shimniok 0:7e98bbfd102a 54 }
shimniok 0:7e98bbfd102a 55 fclose(fp);
shimniok 0:7e98bbfd102a 56 }
shimniok 0:7e98bbfd102a 57
shimniok 0:7e98bbfd102a 58 printf("Opening config.txt...");
shimniok 0:7e98bbfd102a 59 fp = fopen("/etc/config.txt", "r");
shimniok 0:7e98bbfd102a 60 if(fp) {
shimniok 0:7e98bbfd102a 61 while (!feof(fp)) {
shimniok 0:7e98bbfd102a 62 fgets(buf, 127, fp);
shimniok 0:7e98bbfd102a 63 printf(buf);
shimniok 0:7e98bbfd102a 64 }
shimniok 0:7e98bbfd102a 65 fclose(fp);
shimniok 0:7e98bbfd102a 66 }
shimniok 0:7e98bbfd102a 67 */
shimniok 0:7e98bbfd102a 68
shimniok 0:7e98bbfd102a 69 //SystemReport sys_state(500);
shimniok 0:7e98bbfd102a 70
shimniok 0:7e98bbfd102a 71 while (true) {
shimniok 0:7e98bbfd102a 72 // Blink LED and wait 0.5 seconds
shimniok 0:7e98bbfd102a 73 led1 = !led1;
shimniok 0:7e98bbfd102a 74 wait(0.5f);
shimniok 0:7e98bbfd102a 75
shimniok 0:7e98bbfd102a 76 // Following the main thread wait, report on the current system status
shimniok 0:7e98bbfd102a 77 //sys_state.report_state();
shimniok 0:7e98bbfd102a 78 }
shimniok 0:7e98bbfd102a 79 }