From 3056e083d78b6edec6bab1ebac3fa9e3708644d7 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 20 Aug 2015 22:37:23 +0200 Subject: Initial commit --- firmware/src/app.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 firmware/src/app.c (limited to 'firmware/src/app.c') diff --git a/firmware/src/app.c b/firmware/src/app.c new file mode 100644 index 0000000..635c46f --- /dev/null +++ b/firmware/src/app.c @@ -0,0 +1,78 @@ +/******************************************************************************* + MPLAB Harmony Application Source File + + File Name: + app.c + + Summary: + This file contains the source code for the MPLAB Harmony application. + + Description: + This file contains the source code for the MPLAB Harmony application. It + implements the logic of the application's state machine and it may call + API routines of other MPLAB Harmony modules in the system, such as drivers, + system services, and middleware. However, it does not call any of the + system interfaces (such as the "Initialize" and "Tasks" functions) of any of + the modules in the system or make any assumptions about when those functions + are called. That is the responsibility of the configuration-specific system + files. + *******************************************************************************/ + +#include "app.h" +#include "T6963C_PIC/t6963c.h" +#include "t6963c_specific.h" +#include "T6963C_PIC/terminal.h" + +APP_DATA appData; +static Terminal* term; + +void APP_Initialize (void) { + t6963c_init(); + t6963c_clear(); + + term = terminal.construct(t6963c_rows * t6963c_columns); + term->update = t6963c_update_terminal; + + appData.state = APP_STATE_MAIN; +} + +void APP_Tasks (void) { + /* Check the application's current state. */ + switch (appData.state) { + /* Application's main state. */ + case APP_STATE_MAIN: { + if (term != NULL) { + unsigned char* string = "me@pic:~$ ls\nme@pic:~$ mkdir docs\nme@pic:~$ cd docs/\nme@pic:~/docs$ ls\nme@pic:~/docs$ touch doc.txt\nme@pic:~/docs$ ls\ndoc.txt\nme@pic:~/docs$ cat doc.txt\nme@pic:~/docs$ echo hello > doc.txt\nme@pic:~/docs$ cat doc.txt\nhello\nme@pic:~/docs$ cd ..\nme@pic:~$ tree -fFi\n.\n./docs/\n./docs/doc.txt\n\n1 directory, 1 file\nme@pic:~$ rm -r docs/\n"; + unsigned short i, j; + unsigned char state = 0; // 0 = quick, 1 = slow + for (i = 0; string[i]; i++) { + if (!terminal.appendChar(term, string[i])) { + terminal.free(term); + t6963c_clear(); + t6963c_set_address(5,5); + t6963c_writeString("ERROR"); + while (1); + } + if (string[i] == '$') { + state = 1; + terminal.appendChar(term, string[++i]); + for (j = 0; j < 10000; j++) + delay_ns(60000); + } else if (string[i] == '\n') { + state = 0; + } + if (state) + for (j = 0; j < 800; j++) + delay_ns(60000); + } + } + + break; + } + + default: { + /* TODO: Handle error in application's state machine. */ + break; + } + } +} -- cgit v1.2.3