physicien nocturne / gmon

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
physnoct
Date:
Mon Nov 18 06:09:14 2019 +0000
Commit message:
Initial commit

Changed in this revision

gmon/.mbed Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/C12832.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/C12832.h Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/GraphicsDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/GraphicsDisplay.h Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/Small_7.h Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/TextDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/C12832/TextDisplay.h Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/FATDirHandle.h Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/FATFileHandle.h Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/FATFileSystem.h Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/LPC1768/FATFileSystem.ar Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/diskio.h Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/ff.h Show annotated file Show diff for this revision Revisions of this file
gmon/FatFileSystem/integer.h Show annotated file Show diff for this revision Revisions of this file
gmon/GettingStarted.html Show annotated file Show diff for this revision Revisions of this file
gmon/LM75B/LM75B.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/LM75B/LM75B.h Show annotated file Show diff for this revision Revisions of this file
gmon/MMA7660/MMA7660.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/MMA7660/MMA7660.h Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/MSCFileSystem.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/MSCFileSystem.h Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_cpu.h Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_err.h Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_inc.h Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_lpc17xx.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_lpc17xx.h Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_ms.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/MSCFileSystem/USBHostLite/usbhost_ms.h Show annotated file Show diff for this revision Revisions of this file
gmon/NTPClient/NTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/NTPClient/NTPClient.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Helper/def.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/Endpoint.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/Endpoint.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/Socket.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/Socket.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/TCPSocketConnection.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/TCPSocketConnection.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/TCPSocketServer.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/TCPSocketServer.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/UDPSocket.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Socket/UDPSocket.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Wifly/CBuffer.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Wifly/Wifly.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/Wifly/Wifly.h Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/WiflyInterface.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/WiflyInterface/WiflyInterface.h Show annotated file Show diff for this revision Revisions of this file
gmon/gmon.cpp Show annotated file Show diff for this revision Revisions of this file
gmon/mbed.bld Show annotated file Show diff for this revision Revisions of this file
gmon/mbed_config.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/.mbed	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,1 @@
+ROOT=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/C12832.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,564 @@
+/* mbed library for the mbed Lab Board  128*32 pixel LCD
+ * use C12832 controller
+ * Copyright (c) 2012 Peter Drescher - DC2PD
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+// 13.10.12    initial design
+// 25.10.12    add autorefresh of screen
+// 25.10.12    add standart font
+// 20.12.12    add bitmap graphics
+
+// optional defines :
+// #define debug_lcd  1
+
+#include "C12832.h"
+#include "mbed.h"
+#include "stdio.h"
+#include "Small_7.h"
+
+#define BPP    1       // Bits per pixel
+
+
+C12832::C12832(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name)
+    : _spi(mosi,NC,sck),_reset(reset),_A0(a0),_CS(ncs),GraphicsDisplay(name)
+{
+    orientation = 1;
+    draw_mode = NORMAL;
+    char_x = 0;
+    lcd_reset();
+}
+
+
+int C12832::width()
+{
+    if (orientation == 0 || orientation == 2) return 32;
+    else return 128;
+}
+
+int C12832::height()
+{
+    if (orientation == 0 || orientation == 2) return 128;
+    else return 32;
+}
+
+
+void C12832::invert(unsigned int o)
+{
+    if(o == 0) wr_cmd(0xA6);
+    else wr_cmd(0xA7);
+}
+
+
+void C12832::set_contrast(unsigned int o)
+{
+    contrast = o;
+    wr_cmd(0x81);      //  set volume
+    wr_cmd(o & 0x3F);
+}
+
+unsigned int C12832::get_contrast(void)
+{
+    return(contrast);
+}
+
+
+// write command to lcd controller
+
+void C12832::wr_cmd(unsigned char cmd)
+{
+    _A0 = 0;
+    _CS = 0;
+    _spi.write(cmd);
+    _CS = 1;
+}
+
+// write data to lcd controller
+
+void C12832::wr_dat(unsigned char dat)
+{
+    _A0 = 1;
+    _CS = 0;
+    _spi.write(dat);
+    _CS = 1;
+}
+
+// reset and init the lcd controller
+
+void C12832::lcd_reset()
+{
+
+    _spi.format(8,3);                 // 8 bit spi mode 3
+    _spi.frequency(20000000);          // 19,2 Mhz SPI clock
+    _A0 = 0;
+    _CS = 1;
+    _reset = 0;                        // display reset
+    wait_us(50);
+    _reset = 1;                       // end reset
+    wait_ms(5);
+
+    /* Start Initial Sequence ----------------------------------------------------*/
+
+    wr_cmd(0xAE);   //  display off
+    wr_cmd(0xA2);   //  bias voltage
+
+    wr_cmd(0xA0);
+    wr_cmd(0xC8);   //  colum normal
+
+    wr_cmd(0x22);   //  voltage resistor ratio
+    wr_cmd(0x2F);   //  power on
+    //wr_cmd(0xA4);   //  LCD display ram
+    wr_cmd(0x40);   // start line = 0
+    wr_cmd(0xAF);     // display ON
+
+    wr_cmd(0x81);   //  set contrast
+    wr_cmd(0x17);   //  set contrast
+
+    wr_cmd(0xA6);     // display normal
+
+
+    // clear and update LCD
+    memset(buffer,0x00,512);  // clear display buffer
+    copy_to_lcd();
+    auto_up = 1;              // switch on auto update
+    // dont do this by default. Make the user call
+    //claim(stdout);           // redirekt printf to lcd
+    locate(0,0);
+    set_font((unsigned char*)Small_7);  // standart font
+}
+
+// set one pixel in buffer
+
+void C12832::pixel(int x, int y, int color)
+{
+    // first check parameter
+    if(x > 128 || y > 32 || x < 0 || y < 0) return;
+
+    if(draw_mode == NORMAL) {
+        if(color == 0)
+            buffer[x + ((y/8) * 128)] &= ~(1 << (y%8));  // erase pixel
+        else
+            buffer[x + ((y/8) * 128)] |= (1 << (y%8));   // set pixel
+    } else { // XOR mode
+        if(color == 1)
+            buffer[x + ((y/8) * 128)] ^= (1 << (y%8));   // xor pixel
+    }
+}
+
+// update lcd
+
+void C12832::copy_to_lcd(void)
+{
+    
+    int i=0;
+    
+    //page 0
+    wr_cmd(0x00);      // set column low nibble 0
+    wr_cmd(0x10);      // set column hi  nibble 0
+    wr_cmd(0xB0);      // set page address  0
+    _A0 = 1;
+    for(i=0; i<128; i++) {
+        wr_dat(buffer[i]);
+    }
+
+    // page 1
+    wr_cmd(0x00);      // set column low nibble 0
+    wr_cmd(0x10);      // set column hi  nibble 0
+    wr_cmd(0xB1);      // set page address  1
+    _A0 = 1;
+    for(i=128; i<256; i++) {
+        wr_dat(buffer[i]);
+    }
+
+    //page 2
+    wr_cmd(0x00);      // set column low nibble 0
+    wr_cmd(0x10);      // set column hi  nibble 0
+    wr_cmd(0xB2);      // set page address  2
+    _A0 = 1;
+    for(i=256; i<384; i++) {
+        wr_dat(buffer[i]);
+    }
+
+    //page 3
+    wr_cmd(0x00);      // set column low nibble 0
+    wr_cmd(0x10);      // set column hi  nibble 0
+    wr_cmd(0xB3);      // set page address  3
+    _A0 = 1;
+
+    _CS = 0;
+    
+    for(i=384; i<512; i++) {
+        wr_dat(buffer[i]);
+    }
+
+}
+
+void C12832::cls(void)
+{
+    memset(buffer,0x00,512);  // clear display buffer
+    copy_to_lcd();
+}
+
+
+void C12832::line(int x0, int y0, int x1, int y1, int color)
+{
+    int   dx = 0, dy = 0;
+    int   dx_sym = 0, dy_sym = 0;
+    int   dx_x2 = 0, dy_x2 = 0;
+    int   di = 0;
+
+    dx = x1-x0;
+    dy = y1-y0;
+
+    //  if (dx == 0) {        /* vertical line */
+    //      if (y1 > y0) vline(x0,y0,y1,color);
+    //      else vline(x0,y1,y0,color);
+    //      return;
+    //  }
+
+    if (dx > 0) {
+        dx_sym = 1;
+    } else {
+        dx_sym = -1;
+    }
+    //  if (dy == 0) {        /* horizontal line */
+    //      if (x1 > x0) hline(x0,x1,y0,color);
+    //      else  hline(x1,x0,y0,color);
+    //      return;
+    //  }
+
+    if (dy > 0) {
+        dy_sym = 1;
+    } else {
+        dy_sym = -1;
+    }
+
+    dx = dx_sym*dx;
+    dy = dy_sym*dy;
+
+    dx_x2 = dx*2;
+    dy_x2 = dy*2;
+
+    if (dx >= dy) {
+        di = dy_x2 - dx;
+        while (x0 != x1) {
+
+            pixel(x0, y0, color);
+            x0 += dx_sym;
+            if (di<0) {
+                di += dy_x2;
+            } else {
+                di += dy_x2 - dx_x2;
+                y0 += dy_sym;
+            }
+        }
+        pixel(x0, y0, color);
+    } else {
+        di = dx_x2 - dy;
+        while (y0 != y1) {
+            pixel(x0, y0, color);
+            y0 += dy_sym;
+            if (di < 0) {
+                di += dx_x2;
+            } else {
+                di += dx_x2 - dy_x2;
+                x0 += dx_sym;
+            }
+        }
+        pixel(x0, y0, color);
+    }
+    if(auto_up) copy_to_lcd();
+}
+
+void C12832::rect(int x0, int y0, int x1, int y1, int color)
+{
+
+    if (x1 > x0) line(x0,y0,x1,y0,color);
+    else  line(x1,y0,x0,y0,color);
+
+    if (y1 > y0) line(x0,y0,x0,y1,color);
+    else line(x0,y1,x0,y0,color);
+
+    if (x1 > x0) line(x0,y1,x1,y1,color);
+    else  line(x1,y1,x0,y1,color);
+
+    if (y1 > y0) line(x1,y0,x1,y1,color);
+    else line(x1,y1,x1,y0,color);
+
+    if(auto_up) copy_to_lcd();
+}
+
+void C12832::fillrect(int x0, int y0, int x1, int y1, int color)
+{
+    int l,c,i;
+    if(x0 > x1) {
+        i = x0;
+        x0 = x1;
+        x1 = i;
+    }
+
+    if(y0 > y1) {
+        i = y0;
+        y0 = y1;
+        y1 = i;
+    }
+
+    for(l = x0; l<= x1; l ++) {
+        for(c = y0; c<= y1; c++) {
+            pixel(l,c,color);
+        }
+    }
+    if(auto_up) copy_to_lcd();
+}
+
+
+
+void C12832::circle(int x0, int y0, int r, int color)
+{
+
+    int draw_x0, draw_y0;
+    int draw_x1, draw_y1;
+    int draw_x2, draw_y2;
+    int draw_x3, draw_y3;
+    int draw_x4, draw_y4;
+    int draw_x5, draw_y5;
+    int draw_x6, draw_y6;
+    int draw_x7, draw_y7;
+    int xx, yy;
+    int di;
+    //WindowMax();
+    if (r == 0) {       /* no radius */
+        return;
+    }
+
+    draw_x0 = draw_x1 = x0;
+    draw_y0 = draw_y1 = y0 + r;
+    if (draw_y0 < height()) {
+        pixel(draw_x0, draw_y0, color);     /* 90 degree */
+    }
+
+    draw_x2 = draw_x3 = x0;
+    draw_y2 = draw_y3 = y0 - r;
+    if (draw_y2 >= 0) {
+        pixel(draw_x2, draw_y2, color);    /* 270 degree */
+    }
+
+    draw_x4 = draw_x6 = x0 + r;
+    draw_y4 = draw_y6 = y0;
+    if (draw_x4 < width()) {
+        pixel(draw_x4, draw_y4, color);     /* 0 degree */
+    }
+
+    draw_x5 = draw_x7 = x0 - r;
+    draw_y5 = draw_y7 = y0;
+    if (draw_x5>=0) {
+        pixel(draw_x5, draw_y5, color);     /* 180 degree */
+    }
+
+    if (r == 1) {
+        return;
+    }
+
+    di = 3 - 2*r;
+    xx = 0;
+    yy = r;
+    while (xx < yy) {
+
+        if (di < 0) {
+            di += 4*xx + 6;
+        } else {
+            di += 4*(xx - yy) + 10;
+            yy--;
+            draw_y0--;
+            draw_y1--;
+            draw_y2++;
+            draw_y3++;
+            draw_x4--;
+            draw_x5++;
+            draw_x6--;
+            draw_x7++;
+        }
+        xx++;
+        draw_x0++;
+        draw_x1--;
+        draw_x2++;
+        draw_x3--;
+        draw_y4++;
+        draw_y5++;
+        draw_y6--;
+        draw_y7--;
+
+        if ( (draw_x0 <= width()) && (draw_y0>=0) ) {
+            pixel(draw_x0, draw_y0, color);
+        }
+
+        if ( (draw_x1 >= 0) && (draw_y1 >= 0) ) {
+            pixel(draw_x1, draw_y1, color);
+        }
+
+        if ( (draw_x2 <= width()) && (draw_y2 <= height()) ) {
+            pixel(draw_x2, draw_y2, color);
+        }
+
+        if ( (draw_x3 >=0 ) && (draw_y3 <= height()) ) {
+            pixel(draw_x3, draw_y3, color);
+        }
+
+        if ( (draw_x4 <= width()) && (draw_y4 >= 0) ) {
+            pixel(draw_x4, draw_y4, color);
+        }
+
+        if ( (draw_x5 >= 0) && (draw_y5 >= 0) ) {
+            pixel(draw_x5, draw_y5, color);
+        }
+        if ( (draw_x6 <=width()) && (draw_y6 <= height()) ) {
+            pixel(draw_x6, draw_y6, color);
+        }
+        if ( (draw_x7 >= 0) && (draw_y7 <= height()) ) {
+            pixel(draw_x7, draw_y7, color);
+        }
+    }
+    if(auto_up) copy_to_lcd();
+}
+
+void C12832::fillcircle(int x, int y, int r, int color)
+{
+    int i,up;
+    up = auto_up;
+    auto_up = 0;   // off
+    for (i = 0; i <= r; i++)
+        circle(x,y,i,color);
+    auto_up = up;
+    if(auto_up) copy_to_lcd();
+}
+
+void C12832::setmode(int mode)
+{
+    draw_mode = mode;
+}
+
+void C12832::locate(int x, int y)
+{
+    char_x = x;
+    char_y = y;
+}
+
+
+
+int C12832::columns()
+{
+    return width() / font[1];
+}
+
+
+
+int C12832::rows()
+{
+    return height() / font[2];
+}
+
+
+
+int C12832::_putc(int value)
+{
+    if (value == '\n') {    // new line
+        char_x = 0;
+        char_y = char_y + font[2];
+        if (char_y >= height() - font[2]) {
+            char_y = 0;
+        }
+    } else {
+        character(char_x, char_y, value);
+        if(auto_up) copy_to_lcd();
+    }
+    return value;
+}
+
+void C12832::character(int x, int y, int c)
+{
+    unsigned int hor,vert,offset,bpl,j,i,b;
+    unsigned char* zeichen;
+    unsigned char z,w;
+
+    if ((c < 31) || (c > 127)) return;   // test char range
+
+    // read font parameter from start of array
+    offset = font[0];                    // bytes / char
+    hor = font[1];                       // get hor size of font
+    vert = font[2];                      // get vert size of font
+    bpl = font[3];                       // bytes per line
+
+    if (char_x + hor > width()) {
+        char_x = 0;
+        char_y = char_y + vert;
+        if (char_y >= height() - font[2]) {
+            char_y = 0;
+        }
+    }
+
+    zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap
+    w = zeichen[0];                          // width of actual char
+    // construct the char into the buffer
+    for (j=0; j<vert; j++) {  //  vert line
+        for (i=0; i<hor; i++) {   //  horz line
+            z =  zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
+            b = 1 << (j & 0x07);
+            if (( z & b ) == 0x00) {
+                pixel(x+i,y+j,0);
+            } else {
+                pixel(x+i,y+j,1);
+            }
+
+        }
+    }
+
+    char_x += w;
+}
+
+
+void C12832::set_font(unsigned char* f)
+{
+    font = f;
+}
+
+void C12832::set_auto_up(unsigned int up)
+{
+    if(up ) auto_up = 1;
+    else auto_up = 0;
+}
+
+unsigned int C12832::get_auto_up(void)
+{
+    return (auto_up);
+}
+
+void C12832::print_bm(Bitmap bm, int x, int y)
+{
+    int h,v,b;
+    char d;
+
+    for(v=0; v < bm.ySize; v++) {   // lines
+        for(h=0; h < bm.xSize; h++) { // pixel
+            if(h + x > 127) break;
+            if(v + y > 31) break;
+            d = bm.data[bm.Byte_in_Line * v + ((h & 0xF8) >> 3)];
+            b = 0x80 >> (h & 0x07);
+            if((d & b) == 0) {
+                pixel(x+h,y+v,0);
+            } else {
+                pixel(x+h,y+v,1);
+            }
+        }
+    }
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/C12832.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,306 @@
+/* mbed library for the mbed Lab Board  128*32 pixel LCD
+ * use C12832 controller
+ * Copyright (c) 2012 Peter Drescher - DC2PD
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef C12832_H
+#define C12832_H
+
+#include "mbed.h"
+#include "GraphicsDisplay.h"
+
+
+/** optional Defines :
+  * #define debug_lcd  1  enable infos to PC_USB
+  */
+
+// some defines for the DMA use
+#define DMA_CHANNEL_ENABLE      1
+#define DMA_TRANSFER_TYPE_M2P   (1UL << 11)
+#define DMA_CHANNEL_TCIE        (1UL << 31)
+#define DMA_CHANNEL_SRC_INC     (1UL << 26)
+#define DMA_MASK_IE             (1UL << 14)
+#define DMA_MASK_ITC            (1UL << 15)
+#define DMA_SSP1_TX             (1UL << 2)
+#define DMA_SSP0_TX             (0)
+#define DMA_DEST_SSP1_TX        (2UL << 6)
+#define DMA_DEST_SSP0_TX        (0UL << 6)
+
+/** Draw mode
+  * NORMAl
+  * XOR set pixel by xor the screen
+  */
+enum {NORMAL,XOR};
+
+/** Bitmap
+ */
+struct Bitmap{
+    int xSize;
+    int ySize;
+    int Byte_in_Line;
+    char* data;
+    };
+
+class C12832 : public GraphicsDisplay
+{
+public:
+    /** Create a C12832 object connected to SPI1
+      *
+      */
+
+    C12832(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name = "LCD");
+
+
+    /** Get the width of the screen in pixel
+      *
+      * @param
+      * @returns width of screen in pixel
+      *
+      */
+    virtual int width();
+
+    /** Get the height of the screen in pixel
+     *
+     * @returns height of screen in pixel
+     *
+     */
+    virtual int height();
+
+    /** Draw a pixel at x,y black or white
+     *
+     * @param x horizontal position
+     * @param y vertical position
+     * @param colour ,1 set pixel ,0 erase pixel
+     */
+    virtual void pixel(int x, int y,int colour);
+
+    /** draw a circle
+      *
+      * @param x0,y0 center
+      * @param r radius
+      * @param colour ,1 set pixel ,0 erase pixel
+      *
+      */
+    void circle(int x, int y, int r, int colour);
+
+    /** draw a filled circle
+     *
+     * @param x0,y0 center
+     * @param r radius
+     * @param color ,1 set pixel ,0 erase pixel
+     *
+     * use circle with different radius,
+     * can miss some pixel
+     */
+    void fillcircle(int x, int y, int r, int colour);
+
+    /** draw a 1 pixel line
+      *
+      * @param x0,y0 start point
+      * @param x1,y1 stop point
+      * @param color ,1 set pixel ,0 erase pixel
+      *
+      */
+    void line(int x0, int y0, int x1, int y1, int colour);
+
+    /** draw a rect
+    *
+    * @param x0,y0 top left corner
+    * @param x1,y1 down right corner
+    * @param color 1 set pixel ,0 erase pixel
+    *                                                   *
+    */
+    void rect(int x0, int y0, int x1, int y1, int colour);
+
+    /** draw a filled rect
+      *
+      * @param x0,y0 top left corner
+      * @param x1,y1 down right corner
+      * @param color 1 set pixel ,0 erase pixel
+      *
+      */
+    void fillrect(int x0, int y0, int x1, int y1, int colour);
+
+    /** copy display buffer to lcd
+      *
+      */
+
+    void copy_to_lcd(void);
+
+    /** set the orienation of the screen
+      *
+      */
+
+
+    void set_contrast(unsigned int o);
+
+    /** read the contrast level
+      *
+      */
+    unsigned int get_contrast(void);
+
+
+    /** invert the screen
+      *
+      * @param o = 0 normal, 1 invert
+      */
+    void invert(unsigned int o);
+
+    /** clear the screen
+       *
+       */
+    virtual void cls(void);
+
+    /** set the drawing mode
+      *
+      * @param mode NORMAl or XOR
+      */
+
+    void setmode(int mode);
+
+    virtual int columns(void);
+
+    /** calculate the max number of columns
+     *
+     * @returns max column
+     * depends on actual font size
+     *
+     */
+    virtual int rows(void);
+
+    /** put a char on the screen
+     *
+     * @param value char to print
+     * @returns printed char
+     *
+     */
+    virtual int _putc(int value);
+
+    /** draw a character on given position out of the active font to the LCD
+     *
+     * @param x x-position of char (top left)
+     * @param y y-position
+     * @param c char to print
+     *
+     */
+    virtual void character(int x, int y, int c);
+
+    /** setup cursor position
+     *
+     * @param x x-position (top left)
+     * @param y y-position
+     */
+    virtual void locate(int x, int y);
+    
+    /** setup auto update of screen 
+      *
+      * @param up 1 = on , 0 = off
+      * if switched off the program has to call copy_to_lcd() 
+      * to update screen from framebuffer
+      */
+    void set_auto_up(unsigned int up);
+
+    /** get status of the auto update function
+      *
+      *  @returns if auto update is on
+      */
+    unsigned int get_auto_up(void);
+
+    /** Vars     */
+    SPI _spi;
+    DigitalOut _reset;
+    DigitalOut _A0;
+    DigitalOut _CS;
+    unsigned char* font;
+    unsigned int draw_mode;
+
+
+    /** select the font to use
+      *
+      * @param f pointer to font array
+      *
+      *   font array can created with GLCD Font Creator from http://www.mikroe.com
+      *   you have to add 4 parameter at the beginning of the font array to use:
+      *   - the number of byte / char
+      *   - the vertial size in pixel
+      *   - the horizontal size in pixel
+      *   - the number of byte per vertical line
+      *   you also have to change the array to char[]
+      *
+      */
+    void set_font(unsigned char* f);
+    
+    /** print bitmap to buffer
+      *
+      * @param bm Bitmap in flash
+      * @param x  x start
+      * @param y  y start 
+      *
+      */
+
+    void print_bm(Bitmap bm, int x, int y);
+
+protected:
+
+    /** draw a horizontal line
+      *
+      * @param x0 horizontal start
+      * @param x1 horizontal stop
+      * @param y vertical position
+      * @param ,1 set pixel ,0 erase pixel
+      *
+      */
+    void hline(int x0, int x1, int y, int colour);
+
+    /** draw a vertical line
+     *
+     * @param x horizontal position
+     * @param y0 vertical start
+     * @param y1 vertical stop
+     * @param ,1 set pixel ,0 erase pixel
+     */
+    void vline(int y0, int y1, int x, int colour);
+
+    /** Init the C12832 LCD controller
+     *
+     */
+    void lcd_reset();
+
+    /** Write data to the LCD controller
+     *
+     * @param dat data written to LCD controller
+     *
+     */
+    void wr_dat(unsigned char value);
+
+    /** Write a command the LCD controller
+      *
+      * @param cmd: command to be written
+      *
+      */
+    void wr_cmd(unsigned char value);
+
+    void wr_cnt(unsigned char cmd);
+
+    unsigned int orientation;
+    unsigned int char_x;
+    unsigned int char_y;
+    unsigned char buffer[512];
+    unsigned int contrast;
+    unsigned int auto_up;
+
+};
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/GraphicsDisplay.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,176 @@
+/* mbed GraphicsDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+ 
+#include "GraphicsDisplay.h"
+
+const unsigned char FONT8x8[97][8] = {
+0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per_char
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20
+0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // !
+0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // "
+0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // #
+0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $
+0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // %
+0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // &
+0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // '
+0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // (
+0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // )
+0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // *
+0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // +
+0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // ,
+0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // -
+0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // .
+0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash)
+0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30
+0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1
+0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2
+0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3
+0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4
+0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5
+0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6
+0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7
+0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8
+0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9
+0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // :
+0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ;
+0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // <
+0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // =
+0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // >
+0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ?
+0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40
+0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A
+0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B
+0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C
+0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D
+0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E
+0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F
+0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G
+0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H
+0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I
+0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J
+0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K
+0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L
+0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M
+0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N
+0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O
+0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50
+0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q
+0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R
+0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S
+0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T
+0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U
+0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V
+0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W
+0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X
+0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y
+0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z
+0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [
+0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash)
+0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ]
+0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _
+0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60
+0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a
+0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b
+0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c
+0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d
+0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e
+0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f
+0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g
+0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h
+0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i
+0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j
+0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k
+0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l
+0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m
+0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n
+0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o
+0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p
+0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q
+0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r
+0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s
+0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t
+0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u
+0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v
+0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w
+0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x
+0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y
+0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z
+0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // {
+0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // |
+0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // }
+0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~
+0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00}; // DEL
+    
+GraphicsDisplay::GraphicsDisplay(const char *name):TextDisplay(name) {
+    foreground(0xFFFF);
+    background(0x0000);
+}
+    
+void GraphicsDisplay::character(int column, int row, int value) { 
+    blitbit(column * 8, row * 8, 8, 8, (char*)&(FONT8x8[value - 0x1F][0]));
+}
+
+void GraphicsDisplay::window(int x, int y, int w, int h) {
+    // current pixel location
+    _x = x;
+    _y = y;
+    // window settings
+    _x1 = x;
+    _x2 = x + w - 1;
+    _y1 = y;
+    _y2 = y + h - 1;
+}
+    
+void GraphicsDisplay::putp(int colour) {
+    // put pixel at current pixel location
+    pixel(_x, _y, colour);
+    // update pixel location based on window settings
+    _x++;
+    if(_x > _x2) {
+        _x = _x1;
+        _y++;
+        if(_y > _y2) {
+            _y = _y1;
+        }
+    }
+}
+
+void GraphicsDisplay::fill(int x, int y, int w, int h, int colour) { 
+    window(x, y, w, h);
+    for(int i=0; i<w*h; i++) {
+        putp(colour);
+    }
+}
+    
+void GraphicsDisplay::cls() {
+    fill(0, 0, width(), height(), _background);
+}
+    
+void GraphicsDisplay::blit(int x, int y, int w, int h, const int *colour) { 
+    window(x, y, w, h);
+    for(int i=0; i<w*h; i++) {
+        putp(colour[i]);
+    }
+}
+    
+void GraphicsDisplay::blitbit(int x, int y, int w, int h, const char* colour) {
+    window(x, y, w, h);
+    for(int i = 0; i < w*h; i++) {
+        char byte = colour[i >> 3];
+        int offset = i & 0x7;
+        int c = ((byte << offset) & 0x80) ? _foreground : _background;
+        putp(c);
+    }
+}
+    
+int GraphicsDisplay::columns() { 
+    return width() / 8; 
+}
+
+int GraphicsDisplay::rows() { 
+    return height() / 8; 
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/GraphicsDisplay.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,55 @@
+/* mbed GraphicsDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A library for providing a common base class for Graphics displays
+ * To port a new display, derive from this class and implement
+ * the constructor (setup the display), pixel (put a pixel
+ * at a location), width and height functions. Everything else
+ * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) 
+ * will come for free. You can also provide a specialised implementation
+ * of window and putp to speed up the results
+ */
+
+#ifndef MBED_GRAPHICSDISPLAY_H
+#define MBED_GRAPHICSDISPLAY_H
+
+#include "TextDisplay.h"
+
+class GraphicsDisplay : public TextDisplay {
+
+public:         
+          
+    GraphicsDisplay(const char* name);
+     
+    virtual void pixel(int x, int y, int colour) = 0;
+    virtual int width() = 0;
+    virtual int height() = 0;
+        
+    virtual void window(int x, int y, int w, int h);
+    virtual void putp(int colour);
+    
+    virtual void cls();
+    virtual void fill(int x, int y, int w, int h, int colour);
+    virtual void blit(int x, int y, int w, int h, const int *colour);    
+    virtual void blitbit(int x, int y, int w, int h, const char* colour);
+    
+    virtual void character(int column, int row, int value);
+    virtual int columns();
+    virtual int rows();
+    
+protected:
+
+    // pixel location
+    short _x;
+    short _y;
+    
+    // window location
+    short _x1;
+    short _x2;
+    short _y1;
+    short _y2;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/Small_7.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,104 @@
+#ifndef small_7
+#define small_7
+
+const unsigned char Small_7[] = {
+        19,9,9,2,                                    // Length,horz,vert,byte/vert    
+        0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char  
+        0x02, 0x00, 0x00, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char !
+        0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char "
+        0x06, 0x00, 0x00, 0x50, 0x00, 0xF8, 0x00, 0x50, 0x00, 0xF8, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char #
+        0x06, 0x00, 0x00, 0x8C, 0x00, 0x92, 0x00, 0xFE, 0x01, 0xA2, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char $
+        0x07, 0x1E, 0x00, 0x92, 0x00, 0x5E, 0x00, 0x20, 0x00, 0xF8, 0x00, 0x94, 0x00, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char %
+        0x07, 0x00, 0x00, 0x64, 0x00, 0x9A, 0x00, 0xAA, 0x00, 0xCC, 0x00, 0x60, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char &
+        0x02, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char '
+        0x03, 0x00, 0x00, 0x7C, 0x00, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char (
+        0x03, 0x00, 0x00, 0x83, 0x01, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char )
+        0x04, 0x00, 0x00, 0x30, 0x00, 0x78, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char *
+        0x05, 0x10, 0x00, 0x10, 0x00, 0x7C, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char +
+        0x02, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ,
+        0x04, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char -
+        0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char .
+        0x04, 0x00, 0x01, 0xE0, 0x00, 0x1C, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char /
+        0x05, 0x00, 0x00, 0x7C, 0x00, 0x82, 0x00, 0x82, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 0
+        0x05, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 1
+        0x05, 0x00, 0x00, 0x84, 0x00, 0xC2, 0x00, 0xA2, 0x00, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 2
+        0x05, 0x00, 0x00, 0x82, 0x00, 0x92, 0x00, 0x92, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 3
+        0x05, 0x00, 0x00, 0x38, 0x00, 0x2C, 0x00, 0x22, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 4
+        0x05, 0x00, 0x00, 0x9E, 0x00, 0x92, 0x00, 0x92, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 5
+        0x05, 0x00, 0x00, 0x7C, 0x00, 0x92, 0x00, 0x92, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 6
+        0x05, 0x00, 0x00, 0x02, 0x00, 0xC2, 0x00, 0x32, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 7
+        0x05, 0x00, 0x00, 0x6C, 0x00, 0x92, 0x00, 0x92, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 8
+        0x05, 0x00, 0x00, 0x9C, 0x00, 0x92, 0x00, 0x92, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char 9
+        0x02, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char :
+        0x02, 0x00, 0x01, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ;
+        0x05, 0x10, 0x00, 0x10, 0x00, 0x28, 0x00, 0x28, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char <
+        0x05, 0x00, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char =
+        0x05, 0x00, 0x00, 0x44, 0x00, 0x28, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char >
+        0x05, 0x00, 0x00, 0x02, 0x00, 0xB2, 0x00, 0x12, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ?
+        0x09, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x01, 0x72, 0x01, 0x4A, 0x01, 0x4A, 0x01, 0x7A, 0x01, 0x42, 0x00, 0x3C, 0x00,  // Code for char @
+        0x06, 0x00, 0x00, 0xF8, 0x00, 0x24, 0x00, 0x22, 0x00, 0x24, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char A
+        0x06, 0x00, 0x00, 0xFE, 0x00, 0x92, 0x00, 0x92, 0x00, 0x92, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char B
+        0x06, 0x00, 0x00, 0x7C, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char C
+        0x06, 0x00, 0x00, 0xFE, 0x00, 0x82, 0x00, 0x82, 0x00, 0xC6, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char D
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x92, 0x00, 0x92, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char E
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char F
+        0x06, 0x00, 0x00, 0x7C, 0x00, 0xC6, 0x00, 0x82, 0x00, 0x92, 0x00, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char G
+        0x06, 0x00, 0x00, 0xFE, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char H
+        0x02, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char I
+        0x04, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char J
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x10, 0x00, 0x2C, 0x00, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char K
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char L
+        0x08, 0x00, 0x00, 0xFE, 0x00, 0x06, 0x00, 0x18, 0x00, 0xE0, 0x00, 0x18, 0x00, 0x06, 0x00, 0xFE, 0x00, 0x00, 0x00,  // Code for char M
+        0x06, 0x00, 0x00, 0xFE, 0x00, 0x06, 0x00, 0x18, 0x00, 0x60, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char N
+        0x06, 0x00, 0x00, 0x7C, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char O
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x12, 0x00, 0x12, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char P
+        0x07, 0x00, 0x00, 0x7C, 0x00, 0x82, 0x00, 0x82, 0x00, 0xC2, 0x00, 0xFC, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,  // Code for char Q
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x12, 0x00, 0x12, 0x00, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char R
+        0x05, 0x00, 0x00, 0xCC, 0x00, 0x92, 0x00, 0x92, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char S
+        0x06, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0xFE, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char T
+        0x06, 0x00, 0x00, 0x7E, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char U
+        0x07, 0x00, 0x00, 0x06, 0x00, 0x3C, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0x1C, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char V
+        0x06, 0x00, 0x00, 0x1E, 0x00, 0xE0, 0x00, 0x3E, 0x00, 0xE0, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char W
+        0x06, 0x00, 0x00, 0x82, 0x00, 0x64, 0x00, 0x38, 0x00, 0x6C, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char X
+        0x06, 0x00, 0x00, 0x02, 0x00, 0x0C, 0x00, 0xF0, 0x00, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char Y
+        0x06, 0x00, 0x00, 0x82, 0x00, 0xE2, 0x00, 0x92, 0x00, 0x8E, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char Z
+        0x03, 0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char [
+        0x04, 0x01, 0x00, 0x0E, 0x00, 0x70, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char BackSlash
+        0x02, 0x01, 0x01, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ]
+        0x04, 0x00, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ^
+        0x06, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char _
+        0x03, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char `
+        0x05, 0x00, 0x00, 0xE8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char a
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char b
+        0x05, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char c
+        0x05, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, 0x88, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char d
+        0x05, 0x00, 0x00, 0x70, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char e
+        0x04, 0x08, 0x00, 0xFE, 0x00, 0x0A, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char f
+        0x05, 0x00, 0x00, 0x30, 0x00, 0x48, 0x01, 0x48, 0x01, 0xF8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char g
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char h
+        0x02, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char i
+        0x02, 0x00, 0x01, 0xFA, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char j
+        0x05, 0x00, 0x00, 0xFE, 0x00, 0x20, 0x00, 0x50, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char k
+        0x02, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char l
+        0x06, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, 0xF8, 0x00, 0x08, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char m
+        0x05, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char n
+        0x05, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char o
+        0x05, 0x00, 0x00, 0xF8, 0x01, 0x48, 0x00, 0x48, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char p
+        0x05, 0x00, 0x00, 0x30, 0x00, 0x48, 0x00, 0x48, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char q
+        0x04, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char r
+        0x04, 0x00, 0x00, 0x98, 0x00, 0xA8, 0x00, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char s
+        0x04, 0x00, 0x00, 0x08, 0x00, 0xFC, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char t
+        0x05, 0x00, 0x00, 0x78, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char u
+        0x04, 0x00, 0x00, 0x38, 0x00, 0xC0, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char v
+        0x06, 0x00, 0x00, 0x78, 0x00, 0xC0, 0x00, 0x38, 0x00, 0xC0, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char w
+        0x05, 0x00, 0x00, 0x88, 0x00, 0x70, 0x00, 0x70, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char x
+        0x05, 0x00, 0x00, 0x38, 0x00, 0x40, 0x01, 0x40, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char y
+        0x05, 0x00, 0x00, 0xC8, 0x00, 0xE8, 0x00, 0xB8, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char z
+        0x04, 0x10, 0x00, 0x38, 0x00, 0xEF, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char {
+        0x03, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char |
+        0x04, 0x01, 0x01, 0xC7, 0x01, 0x38, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char }
+        0x05, 0x0C, 0x00, 0x04, 0x00, 0x0C, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ~
+        0x03, 0xFE, 0x01, 0x02, 0x01, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // Code for char 
+        };
+        
+#endif        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/TextDisplay.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,77 @@
+/* mbed TextDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+ 
+#include "TextDisplay.h"
+
+TextDisplay::TextDisplay(const char *name) : Stream(name){
+    _row = 0;
+    _column = 0;
+    if (name == NULL) {
+        _path = NULL;
+    } else {
+        _path = new char[strlen(name) + 2];
+        sprintf(_path, "/%s", name);
+    }
+}
+    
+int TextDisplay::_putc(int value) {
+    if(value == '\n') {
+        _column = 0;
+        _row++;
+        if(_row >= rows()) {
+            _row = 0;
+        }
+    } else {
+        character(_column, _row, value);
+        _column++;
+        if(_column >= columns()) {
+            _column = 0;
+            _row++;
+            if(_row >= rows()) {
+                _row = 0;
+            }
+        }
+    }
+    return value;
+}
+
+// crude cls implementation, should generally be overwritten in derived class
+void TextDisplay::cls() {
+    locate(0, 0);
+    for(int i=0; i<columns()*rows(); i++) {
+        putc(' ');
+    }
+}
+
+void TextDisplay::locate(int column, int row) {
+    _column = column;
+    _row = row;
+}
+
+int TextDisplay::_getc() {
+    return -1;
+}
+        
+void TextDisplay::foreground(uint16_t colour) {
+    _foreground = colour;
+}
+
+void TextDisplay::background(uint16_t colour) {
+    _background = colour;
+}
+
+bool TextDisplay::claim (FILE *stream) {
+    if ( _path == NULL) {
+        fprintf(stderr, "claim requires a name to be given in the instantioator of the TextDisplay instance!\r\n");
+        return false;
+    }
+    if (freopen(_path, "w", stream) == NULL) {
+        // Failed, should not happen
+        return false;
+    }
+    // make sure we use line buffering
+    setvbuf(stdout, NULL, _IOLBF, columns());
+    return true;
+} 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/C12832/TextDisplay.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,80 @@
+/* mbed TextDisplay Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A common base class for Text displays
+ * To port a new display, derive from this class and implement
+ * the constructor (setup the display), character (put a character
+ * at a location), rows and columns (number of rows/cols) functions.
+ * Everything else (locate, printf, putc, cls) will come for free
+ *
+ * The model is the display will wrap at the right and bottom, so you can
+ * keep writing and will always get valid characters. The location is 
+ * maintained internally to the class to make this easy
+ */
+
+#ifndef MBED_TEXTDISPLAY_H
+#define MBED_TEXTDISPLAY_H
+
+#include "mbed.h"
+
+class TextDisplay : public Stream {
+public:
+
+  // functions needing implementation in derived implementation class
+  /** Create a TextDisplay interface
+     *
+     * @param name The name used in the path to access the strean through the filesystem
+     */
+    TextDisplay(const char *name = NULL);
+
+    /** output a character at the given position
+     *
+     * @param column column where charater must be written
+     * @param  row where character must be written
+     * @param c the character to be written to the TextDisplay
+     */
+    virtual void character(int column, int row, int c) = 0;
+
+    /** return number if rows on TextDisplay
+     * @result number of rows
+     */
+    virtual int rows() = 0;
+
+    /** return number if columns on TextDisplay
+    * @result number of rows
+    */
+    virtual int columns() = 0;
+    
+    // functions that come for free, but can be overwritten
+
+    /** redirect output from a stream (stoud, sterr) to  display
+    * @param stream stream that shall be redirected to the TextDisplay
+    */
+    virtual bool claim (FILE *stream);
+
+    /** clear screen
+    */
+    virtual void cls();
+    virtual void locate(int column, int row);
+    virtual void foreground(uint16_t colour);
+    virtual void background(uint16_t colour);
+    // putc (from Stream)
+    // printf (from Stream)
+    
+protected:
+
+    virtual int _putc(int value);
+    virtual int _getc();
+
+    // character location
+    uint16_t _column;
+    uint16_t _row;
+
+    // colours
+    uint16_t _foreground;
+    uint16_t _background;
+    char *_path;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/FatFileSystem/FATDirHandle.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,29 @@
+/* Copyright 2008 ARM Limited. All rights reserved. */
+
+#ifndef MBED_FATDIRHANDLE_H
+#define MBED_FATDIRHANDLE_H
+
+#include "DirHandle.h"
+#include "ff.h"
+
+namespace mbed {
+
+class FATDirHandle : public DirHandle {
+
+ public:
+    FATDirHandle(const FATFS_DIR &the_dir);
+    virtual int closedir();
+    virtual struct dirent *readdir();
+    virtual void rewinddir();
+    virtual off_t telldir();
+    virtual void seekdir(off_t location);
+
+ private:
+    FATFS_DIR dir;
+    struct dirent cur_entry;
+
+};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/FatFileSystem/FATFileHandle.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,33 @@
+/* mbed Microcontroller Library - FATFileHandle
+ * Copyright (c) 2008, sford
+ */
+
+#ifndef MBED_FATFILEHANDLE_H
+#define MBED_FATFILEHANDLE_H
+
+#include "FileHandle.h"
+#include "ff.h"
+
+namespace mbed {
+
+class FATFileHandle : public FileHandle {
+public:
+
+    FATFileHandle(FIL fh);
+    virtual int close();
+    virtual ssize_t write(const void* buffer, size_t length);
+    virtual ssize_t read(void* buffer, size_t length);
+    virtual int isatty();
+    virtual off_t lseek(off_t position, int whence);
+    virtual int fsync();
+    virtual off_t flen();
+
+protected:
+
+    FIL _fh;
+
+};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/FatFileSystem/FATFileSystem.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,61 @@
+/* mbed Microcontroller Library - FATFileSystem
+ * Copyright (c) 2008, sford
+ */
+
+/* Library: FATFileSystem.h
+ * A library of stuff to make a fat filesystem on top of a block device
+ */
+
+#ifndef MBED_FATFILESYSTEM_H
+#define MBED_FATFILESYSTEM_H
+
+#ifndef FFSDEBUG_ENABLED
+#define FFSDEBUG_ENABLED 0
+#endif
+
+#if FFSDEBUG_ENABLED
+#define FFSDEBUG(FMT, ...) printf(FMT, ##__VA_ARGS__)
+#else
+#define FFSDEBUG(FMT, ...)
+#endif
+
+#include "FileSystemLike.h"
+#include "FileHandle.h"
+#include "ff.h"
+#include "diskio.h"
+
+namespace mbed {
+/* Class: FATFileSystem
+ * The class itself
+ */
+class FATFileSystem : public FileSystemLike {
+public:
+
+	FATFileSystem(const char* n);
+	virtual ~FATFileSystem();
+	
+	/* Function: open
+       * open a file on the filesystem. never called directly
+       */
+	virtual FileHandle *open(const char* name, int flags);
+	virtual int remove(const char *filename);
+	virtual int format();
+        virtual DirHandle *opendir(const char *name);
+        virtual int mkdir(const char *name, mode_t mode);
+	
+    FATFS _fs;            					// Work area (file system object) for logical drive	
+    static FATFileSystem *_ffs[_DRIVES];	// FATFileSystem objects, as parallel to FatFs drives array
+	int _fsid;
+	
+	virtual int disk_initialize() { return 0; }
+	virtual int disk_status() { return 0; }
+	virtual int disk_read(char *buffer, int sector) = 0;
+	virtual int disk_write(const char *buffer, int sector) = 0;
+	virtual int disk_sync() { return 0; }
+	virtual int disk_sectors() = 0;
+	 
+};
+	
+}
+
+#endif
Binary file gmon/FatFileSystem/LPC1768/FATFileSystem.ar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/FatFileSystem/diskio.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,76 @@
+/*-----------------------------------------------------------------------
+/  Low level disk interface modlue include file  R0.06   (C)ChaN, 2007
+/-----------------------------------------------------------------------*/
+
+#ifndef _DISKIO
+
+#define _READONLY	0	/* 1: Read-only mode */
+#define _USE_IOCTL	1
+
+#include "integer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Status of Disk Functions */
+typedef BYTE	DSTATUS;
+
+/* Results of Disk Functions */
+typedef enum {
+	RES_OK = 0,		/* 0: Successful */
+	RES_ERROR,		/* 1: R/W Error */
+	RES_WRPRT,		/* 2: Write Protected */
+	RES_NOTRDY,		/* 3: Not Ready */
+	RES_PARERR		/* 4: Invalid Parameter */
+} DRESULT;
+
+
+/*---------------------------------------*/
+/* Prototypes for disk control functions */
+
+DSTATUS disk_initialize (BYTE);
+DSTATUS disk_status (BYTE);
+DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
+#if	_READONLY == 0
+DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
+#endif
+DRESULT disk_ioctl (BYTE, BYTE, void*);
+void	disk_timerproc (void);
+
+#ifdef __cplusplus
+};
+#endif
+
+
+/* Disk Status Bits (DSTATUS) */
+
+#define STA_NOINIT		0x01	/* Drive not initialized */
+#define STA_NODISK		0x02	/* No medium in the drive */
+#define STA_PROTECT		0x04	/* Write protected */
+
+
+/* Command code for disk_ioctrl() */
+
+/* Generic command */
+#define CTRL_SYNC			0	/* Mandatory for read/write configuration */
+#define GET_SECTOR_COUNT	1	/* Mandatory for only f_mkfs() */
+#define GET_SECTOR_SIZE		2
+#define GET_BLOCK_SIZE		3	/* Mandatory for only f_mkfs() */
+#define CTRL_POWER			4
+#define CTRL_LOCK			5
+#define CTRL_EJECT			6
+/* MMC/SDC command */
+#define MMC_GET_TYPE		10
+#define MMC_GET_CSD			11
+#define MMC_GET_CID			12
+#define MMC_GET_OCR			13
+#define MMC_GET_SDSTAT		14
+/* ATA/CF command */
+#define ATA_GET_REV			20
+#define ATA_GET_MODEL		21
+#define ATA_GET_SN			22
+
+
+#define _DISKIO
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/FatFileSystem/ff.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,344 @@
+/*--------------------------------------------------------------------------/
+/  FatFs - FAT file system module include file  R0.06        (C)ChaN, 2008
+/---------------------------------------------------------------------------/
+/ FatFs module is an experimenal project to implement FAT file system to
+/ cheap microcontrollers. This is a free software and is opened for education,
+/ research and development under license policy of following trems.
+/
+/  Copyright (C) 2008, ChaN, all right reserved.
+/
+/ * The FatFs module is a free software and there is no warranty.
+/ * You can use, modify and/or redistribute it for personal, non-profit or
+/   commercial use without any restriction under your responsibility.
+/ * Redistributions of source code must retain the above copyright notice.
+/
+/---------------------------------------------------------------------------*/
+
+#ifndef _FATFS
+
+#define _MCU_ENDIAN		2
+/* The _MCU_ENDIAN defines which access method is used to the FAT structure.
+/  1: Enable word access.
+/  2: Disable word access and use byte-by-byte access instead.
+/  When the architectural byte order of the MCU is big-endian and/or address
+/  miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
+/  If it is not the case, it can also be set to 1 for good code efficiency. */
+
+#define _FS_READONLY	0
+/* Setting _FS_READONLY to 1 defines read only configuration. This removes
+/  writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
+/  f_truncate and useless f_getfree. */
+
+#define _FS_MINIMIZE	0
+/* The _FS_MINIMIZE option defines minimization level to remove some functions.
+/  0: Full function.
+/  1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
+/  2: f_opendir and f_readdir are removed in addition to level 1.
+/  3: f_lseek is removed in addition to level 2. */
+
+#define	_USE_STRFUNC	0
+/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
+
+#define	_USE_MKFS	1
+/* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is
+/  enabled. */
+
+#define _DRIVES		4
+/* Number of logical drives to be used. This affects the size of internal table. */
+
+#define	_MULTI_PARTITION	0
+/* When _MULTI_PARTITION is set to 0, each logical drive is bound to same
+/  physical drive number and can mount only 1st primaly partition. When it is
+/  set to 1, each logical drive can mount a partition listed in Drives[]. */
+
+#define _USE_FSINFO	0
+/* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */
+
+#define	_USE_SJIS	1
+/* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
+/  only US-ASCII(7bit) code can be accepted as file/directory name. */
+
+#define	_USE_NTFLAG	1
+/* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
+/  Note that the files are always accessed in case insensitive. */
+
+
+#include "integer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Definitions corresponds to multiple sector size (not tested) */
+#define	S_MAX_SIZ	512U			/* Do not change */
+#if S_MAX_SIZ > 512U
+#define	SS(fs)	((fs)->s_size)
+#else
+#define	SS(fs)	512U
+#endif
+
+
+/* File system object structure */
+typedef struct _FATFS {
+	WORD	id;				/* File system mount ID */
+	WORD	n_rootdir;		/* Number of root directory entries */
+	DWORD	winsect;		/* Current sector appearing in the win[] */
+	DWORD	sects_fat;		/* Sectors per fat */
+	DWORD	max_clust;		/* Maximum cluster# + 1 */
+	DWORD	fatbase;		/* FAT start sector */
+	DWORD	dirbase;		/* Root directory start sector (cluster# for FAT32) */
+	DWORD	database;		/* Data start sector */
+#if !_FS_READONLY
+	DWORD	last_clust;		/* Last allocated cluster */
+	DWORD	free_clust;		/* Number of free clusters */
+#if _USE_FSINFO
+	DWORD	fsi_sector;		/* fsinfo sector */
+	BYTE	fsi_flag;		/* fsinfo dirty flag (1:must be written back) */
+	BYTE	pad2;
+#endif
+#endif
+	BYTE	fs_type;		/* FAT sub type */
+	BYTE	csize;			/* Number of sectors per cluster */
+#if S_MAX_SIZ > 512U
+	WORD	s_size;			/* Sector size */
+#endif
+	BYTE	n_fats;			/* Number of FAT copies */
+	BYTE	drive;			/* Physical drive number */
+	BYTE	winflag;		/* win[] dirty flag (1:must be written back) */
+	BYTE	pad1;
+	BYTE	win[S_MAX_SIZ];	/* Disk access window for Directory/FAT */
+} FATFS;
+
+
+/* Directory object structure */
+typedef struct _DIR {
+	WORD	id;			/* Owner file system mount ID */
+	WORD	index;		/* Current index */
+	FATFS*	fs;			/* Pointer to the owner file system object */
+	DWORD	sclust;		/* Start cluster */
+	DWORD	clust;		/* Current cluster */
+	DWORD	sect;		/* Current sector */
+} FATFS_DIR;
+
+
+/* File object structure */
+typedef struct _FIL {
+	WORD	id;				/* Owner file system mount ID */
+	BYTE	flag;			/* File status flags */
+	BYTE	csect;			/* Sector address in the cluster */
+	FATFS*	fs;				/* Pointer to the owner file system object */
+	DWORD	fptr;			/* File R/W pointer */
+	DWORD	fsize;			/* File size */
+	DWORD	org_clust;		/* File start cluster */
+	DWORD	curr_clust;		/* Current cluster */
+	DWORD	curr_sect;		/* Current sector */
+#if _FS_READONLY == 0
+	DWORD	dir_sect;		/* Sector containing the directory entry */
+	BYTE*	dir_ptr;		/* Ponter to the directory entry in the window */
+#endif
+	BYTE	buffer[S_MAX_SIZ];	/* File R/W buffer */
+} FIL;
+
+
+/* File status structure */
+typedef struct _FILINFO {
+	DWORD fsize;			/* Size */
+	WORD fdate;				/* Date */
+	WORD ftime;				/* Time */
+	BYTE fattrib;			/* Attribute */
+	char fname[8+1+3+1];	/* Name (8.3 format) */
+} FILINFO;
+
+
+
+/* Definitions corresponds to multi partition */
+
+#if _MULTI_PARTITION != 0	/* Multiple partition cfg */
+
+typedef struct _PARTITION {
+	BYTE pd;	/* Physical drive # (0-255) */
+	BYTE pt;	/* Partition # (0-3) */
+} PARTITION;
+extern
+const PARTITION Drives[];			/* Logical drive# to physical location conversion table */
+#define LD2PD(drv) (Drives[drv].pd)	/* Get physical drive# */
+#define LD2PT(drv) (Drives[drv].pt)	/* Get partition# */
+
+#else						/* Single partition cfg */
+
+#define LD2PD(drv) (drv)		/* Physical drive# is equal to logical drive# */
+#define LD2PT(drv) 0			/* Always mounts the 1st partition */
+
+#endif
+
+
+/* File function return code (FRESULT) */
+
+typedef enum {
+	FR_OK = 0,			/* 0 */
+	FR_NOT_READY,		/* 1 */
+	FR_NO_FILE,			/* 2 */
+	FR_NO_PATH,			/* 3 */
+	FR_INVALID_NAME,	/* 4 */
+	FR_INVALID_DRIVE,	/* 5 */
+	FR_DENIED,			/* 6 */
+	FR_EXIST,			/* 7 */
+	FR_RW_ERROR,		/* 8 */
+	FR_WRITE_PROTECTED,	/* 9 */
+	FR_NOT_ENABLED,		/* 10 */
+	FR_NO_FILESYSTEM,	/* 11 */
+	FR_INVALID_OBJECT,	/* 12 */
+	FR_MKFS_ABORTED		/* 13 */
+} FRESULT;
+
+
+
+/*-----------------------------------------------------*/
+/* FatFs module application interface                  */
+
+FRESULT f_mount (BYTE, FATFS*);						/* Mount/Unmount a logical drive */
+FRESULT f_open (FIL*, const char*, BYTE);			/* Open or create a file */
+FRESULT f_read (FIL*, void*, UINT, UINT*);			/* Read data from a file */
+FRESULT f_write (FIL*, const void*, UINT, UINT*);	/* Write data to a file */
+FRESULT f_lseek (FIL*, DWORD);						/* Move file pointer of a file object */
+FRESULT f_close (FIL*);								/* Close an open file object */
+FRESULT f_opendir (FATFS_DIR*, const char*);				/* Open an existing directory */
+FRESULT f_readdir (FATFS_DIR*, FILINFO*);					/* Read a directory item */
+FRESULT f_stat (const char*, FILINFO*);				/* Get file status */
+FRESULT f_getfree (const char*, DWORD*, FATFS**);	/* Get number of free clusters on the drive */
+FRESULT f_truncate (FIL*);							/* Truncate file */
+FRESULT f_sync (FIL*);								/* Flush cached data of a writing file */
+FRESULT f_unlink (const char*);						/* Delete an existing file or directory */
+FRESULT	f_mkdir (const char*);						/* Create a new directory */
+FRESULT f_chmod (const char*, BYTE, BYTE);			/* Change file/dir attriburte */
+FRESULT f_utime (const char*, const FILINFO*);		/* Change file/dir timestamp */
+FRESULT f_rename (const char*, const char*);		/* Rename/Move a file or directory */
+FRESULT f_mkfs (BYTE, BYTE, WORD);					/* Create a file system on the drive */
+#if _USE_STRFUNC
+#define feof(fp) ((fp)->fptr == (fp)->fsize)
+#define EOF -1
+int fputc (int, FIL*);								/* Put a character to the file */
+int fputs (const char*, FIL*);						/* Put a string to the file */
+int fprintf (FIL*, const char*, ...);				/* Put a formatted string to the file */
+char* fgets (char*, int, FIL*);						/* Get a string from the file */
+#endif
+
+/* User defined function to give a current time to fatfs module */
+
+DWORD get_fattime (void);	/* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
+							/* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
+
+
+
+/* File access control and file status flags (FIL.flag) */
+
+#define	FA_READ				0x01
+#define	FA_OPEN_EXISTING	0x00
+#if _FS_READONLY == 0
+#define	FA_WRITE			0x02
+#define	FA_CREATE_NEW		0x04
+#define	FA_CREATE_ALWAYS	0x08
+#define	FA_OPEN_ALWAYS		0x10
+#define FA__WRITTEN			0x20
+#define FA__DIRTY			0x40
+#endif
+#define FA__ERROR			0x80
+
+
+/* FAT sub type (FATFS.fs_type) */
+
+#define FS_FAT12	1
+#define FS_FAT16	2
+#define FS_FAT32	3
+
+
+/* File attribute bits for directory entry */
+
+#define	AM_RDO	0x01	/* Read only */
+#define	AM_HID	0x02	/* Hidden */
+#define	AM_SYS	0x04	/* System */
+#define	AM_VOL	0x08	/* Volume label */
+#define AM_LFN	0x0F	/* LFN entry */
+#define AM_DIR	0x10	/* Directory */
+#define AM_ARC	0x20	/* Archive */
+
+
+
+/* Offset of FAT structure members */
+
+#define BS_jmpBoot			0
+#define BS_OEMName			3
+#define BPB_BytsPerSec		11
+#define BPB_SecPerClus		13
+#define BPB_RsvdSecCnt		14
+#define BPB_NumFATs			16
+#define BPB_RootEntCnt		17
+#define BPB_TotSec16		19
+#define BPB_Media			21
+#define BPB_FATSz16			22
+#define BPB_SecPerTrk		24
+#define BPB_NumHeads		26
+#define BPB_HiddSec			28
+#define BPB_TotSec32		32
+#define BS_55AA				510
+
+#define BS_DrvNum			36
+#define BS_BootSig			38
+#define BS_VolID			39
+#define BS_VolLab			43
+#define BS_FilSysType		54
+
+#define BPB_FATSz32			36
+#define BPB_ExtFlags		40
+#define BPB_FSVer			42
+#define BPB_RootClus		44
+#define BPB_FSInfo			48
+#define BPB_BkBootSec		50
+#define BS_DrvNum32			64
+#define BS_BootSig32		66
+#define BS_VolID32			67
+#define BS_VolLab32			71
+#define BS_FilSysType32		82
+
+#define	FSI_LeadSig			0
+#define	FSI_StrucSig		484
+#define	FSI_Free_Count		488
+#define	FSI_Nxt_Free		492
+
+#define MBR_Table			446
+
+#define	DIR_Name			0
+#define	DIR_Attr			11
+#define	DIR_NTres			12
+#define	DIR_CrtTime			14
+#define	DIR_CrtDate			16
+#define	DIR_FstClusHI		20
+#define	DIR_WrtTime			22
+#define	DIR_WrtDate			24
+#define	DIR_FstClusLO		26
+#define	DIR_FileSize		28
+
+
+
+/* Multi-byte word access macros  */
+
+#if _MCU_ENDIAN == 1	/* Use word access */
+#define	LD_WORD(ptr)		(WORD)(*(WORD*)(BYTE*)(ptr))
+#define	LD_DWORD(ptr)		(DWORD)(*(DWORD*)(BYTE*)(ptr))
+#define	ST_WORD(ptr,val)	*(WORD*)(BYTE*)(ptr)=(WORD)(val)
+#define	ST_DWORD(ptr,val)	*(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
+#elif _MCU_ENDIAN == 2	/* Use byte-by-byte access */
+#define	LD_WORD(ptr)		(WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
+#define	LD_DWORD(ptr)		(DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
+#define	ST_WORD(ptr,val)	*(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
+#define	ST_DWORD(ptr,val)	*(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(volatile BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(volatile BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
+#else
+#error Do not forget to set _MCU_ENDIAN properly!
+#endif
+
+#ifdef __cplusplus
+};
+#endif
+
+#define _FATFS
+#endif /* _FATFS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/FatFileSystem/integer.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,30 @@
+/*-------------------------------------------*/
+/* Integer type definitions for FatFs module */
+/*-------------------------------------------*/
+
+#ifndef _INTEGER
+
+/* These types must be 16-bit, 32-bit or larger integer */
+typedef int				INT;
+typedef unsigned int	UINT;
+
+/* These types must be 8-bit integer */
+typedef signed char		CHAR;
+typedef unsigned char	UCHAR;
+typedef unsigned char	BYTE;
+
+/* These types must be 16-bit integer */
+typedef short			SHORT;
+typedef unsigned short	USHORT;
+typedef unsigned short	WORD;
+
+/* These types must be 32-bit integer */
+typedef long			LONG;
+typedef unsigned long	ULONG;
+typedef unsigned long	DWORD;
+
+/* Boolean type */
+typedef enum { FALSE = 0, TRUE } BOOL;
+
+#define _INTEGER
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/GettingStarted.html	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html lang="en-US">
+    <head>
+        <meta charset="UTF-8">
+        <meta http-equiv="refresh"
+              content="1;url="https://os.mbed.com/docs/latest/tools/exporting.html>
+        <script type="text/javascript">
+            window.location.href = "https://os.mbed.com/docs/latest/tools/exporting.html"
+        </script>
+        <title>Page Redirection</title>
+    </head>
+    <body>
+        If you are not redirected automatically, please follow the
+        <a href='https://os.mbed.com/docs/v5.6/tools/exporting.html/'>link to the online exporter documentation</a>
+    </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/LM75B/LM75B.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,26 @@
+#include "LM75B.h"
+
+LM75B::LM75B(PinName sda, PinName scl) : i2c(sda, scl)
+{
+   char cmd[2];
+   cmd[0]    = LM75B_Conf;
+   cmd[1]    = 0x0;   
+   i2c.write( LM75B_ADDR, cmd, 2);
+}
+
+
+
+LM75B::~LM75B()
+{
+
+}
+
+float LM75B::read()
+{
+    char cmd[2];
+    cmd[0] = LM75B_Temp;
+   
+    i2c.write( LM75B_ADDR, cmd, 1); // Send command string
+    i2c.read( LM75B_ADDR, cmd, 2); // Send command string    
+    return (   float((cmd[0]<<8)|cmd[1]) / 256.0   );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/LM75B/LM75B.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,64 @@
+/* Copyright (c) 2012 cstyles, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
+ * and associated documentation files (the "Software"), to deal in the Software without restriction, 
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or 
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef LM75B_H
+#define LM75B_H
+
+#include "mbed.h"
+
+//  LM75B IIC address
+#define    LM75B_ADDR 0x90
+
+//  LM75B registers
+#define    LM75B_Conf        0x01
+#define    LM75B_Temp        0x00
+#define    LM75B_Tos         0x03
+#define    LM75B_Thyst       0x02
+
+//!Library for the LM75B temperature sensor.
+/*!
+The LM75B is an I2C digital temperature sensor, with a range of -55C to +125C and a 0.125C resolution.
+*/
+class LM75B
+{
+public:
+  //!Creates an instance of the class.
+  /*!
+  Connect module at I2C address addr using I2C port pins sda and scl.
+  LM75B
+  */
+  LM75B(PinName sda, PinName scl);
+  
+  /*!
+  Destroys instance.
+  */ 
+  ~LM75B();
+  
+  //!Reads the current temperature.
+  /*!
+  Reads the temperature register of the LM75B and converts it to a useable value.
+  */
+  float read();
+  
+private:
+  
+  I2C i2c;
+
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MMA7660/MMA7660.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,194 @@
+#include "MMA7660.h"
+
+MMA7660::MMA7660(PinName sda, PinName scl, bool active) : _i2c(sda, scl)
+{
+    setActive(active);
+    samplerate = 64;
+}
+
+//Since the MMA lacks a WHO_AM_I register, we can only check if there is a device that answers to the I2C address
+bool MMA7660::testConnection( void )
+{
+    if (_i2c.write(MMA7660_ADDRESS, NULL, 0) == 0 )
+        return true;
+    else
+        return false;
+}
+
+void MMA7660::setActive(bool state)
+{
+    active = state;
+    char modereg = read(MMA7660_MODE_R);
+    modereg &= ~(1<<0);
+
+    //If it somehow was in testmode, disable that
+    if (modereg && (1<<2)) {
+        modereg &= ~(1<<2);
+        write(MMA7660_MODE_R, modereg);
+    }
+
+    modereg += state;
+    write(MMA7660_MODE_R, modereg);
+}
+
+void MMA7660::readData(int *data)
+{
+    bool active_old = active;
+    if (!active) {
+        setActive(true);
+        wait(0.012 + 1/samplerate); //Wait until new sample is ready, my experience is that 1/samplerate isnt needed, but datasheet says so
+    }
+
+    char temp[3];
+    bool alert;
+
+    do {
+        alert = false;
+        read(MMA7660_XOUT_R, temp, 3);
+        for (int i = 0; i<3; i++) {
+            if (temp[i] > 63)
+                alert = true;
+            if (temp[i] > 31)
+                temp[i] += 128+64;
+            data[i] = (signed char)temp[i];
+        }
+    } while (alert);
+
+    if (!active_old)
+        setActive(false);
+}
+
+
+void MMA7660::readData(float *data)
+{
+    int intdata[3];
+    readData(intdata);
+    for (int i = 0; i<3; i++)
+        data[i] = intdata[i]/MMA7660_SENSITIVITY;
+}
+
+float MMA7660::x( void )
+{
+    return getSingle(0);
+}
+
+float MMA7660::y( void )
+{
+    return getSingle(1);
+}
+
+float MMA7660::z( void )
+{
+    return getSingle(2);
+}
+
+
+void MMA7660::setSampleRate(int samplerate)
+{
+    bool active_old = active;
+    setActive(false);                               //Not allowed to be active to change anything
+    int rates[] = {120, 64, 32, 16, 8, 4, 2, 1};    //Alowed samplerates (and their number in array is also number required for MMA)
+    int sampleLoc = 0, sampleError = 10000, temp;
+    for (int i = 0; i<8; i++) {
+        temp = abs( rates[i] - samplerate );
+        if (temp<sampleError) {
+            sampleLoc = i;
+            sampleError=temp;
+        }
+    }
+
+    //Update the samplerate reg
+    temp = read(MMA7660_SR_R);
+    temp &= ~0x07;                                  //Awake sample rate are lowest 3 bit
+    temp |= sampleLoc;
+    write(MMA7660_SR_R, temp);
+    this->samplerate = rates[sampleLoc];
+    setActive(active_old);                              //Restore previous active state
+}
+
+
+MMA7660::Orientation MMA7660::getSide( void )
+{
+    char tiltreg = read(MMA7660_TILT_R);
+    //We care about 2 LSBs
+    tiltreg &= 0x03;
+    if (tiltreg == 0x01)
+        return MMA7660::Front;
+    if (tiltreg == 0x02)
+        return MMA7660::Back;
+    return MMA7660::Unknown;
+}
+
+MMA7660::Orientation MMA7660::getOrientation( void )
+{
+    char tiltreg = read(MMA7660_TILT_R);
+
+    //We care about bit 2, 3 and 4 (counting from zero)
+    tiltreg &= 0x07<<2;
+    tiltreg >>= 2;
+    if (tiltreg == 0x01)
+        return MMA7660::Left;
+    if (tiltreg == 0x02)
+        return MMA7660::Right;
+    if (tiltreg == 0x05)
+        return MMA7660::Down;
+    if (tiltreg == 0x06)
+        return MMA7660::Up;
+    return MMA7660::Unknown;
+}
+
+
+
+//////////////////////////////////////////////
+///////////////PRIVATE////////////////////////
+//////////////////////////////////////////////
+
+
+void MMA7660::write(char address, char data)
+{
+    char temp[2];
+    temp[0]=address;
+    temp[1]=data;
+
+    _i2c.write(MMA7660_ADDRESS, temp, 2);
+}
+
+char MMA7660::read(char address)
+{
+    char retval;
+    _i2c.write(MMA7660_ADDRESS, &address, 1, true);
+    _i2c.read(MMA7660_ADDRESS, &retval, 1);
+    return retval;
+}
+
+void MMA7660::read(char address, char *data, int length)
+{
+    _i2c.write(MMA7660_ADDRESS, &address, 1, true);
+    _i2c.read(MMA7660_ADDRESS, data, length);
+}
+
+float MMA7660::getSingle( int number )
+{
+    bool active_old = active;
+    if (!active) {
+        setActive(true);
+        wait(0.012 + 1/samplerate); //Wait until new sample is ready
+    }
+
+    signed char temp;
+    bool alert;
+
+    do {
+        alert = false;
+        temp = read(MMA7660_XOUT_R + number);
+        if (temp > 63)
+            alert = true;
+        if (temp > 31)
+            temp += 128+64;
+    } while (alert);
+
+    if (!active_old)
+        setActive(false);
+
+    return temp / MMA7660_SENSITIVITY;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MMA7660/MMA7660.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,207 @@
+/* Copyright (c) <year> <copyright holders>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "mbed.h"
+
+
+#ifndef MMA7660_H
+#define MMA7660_H
+
+#define MMA7660_ADDRESS     0x98
+#define MMA7660_SENSITIVITY 21.33
+
+#define MMA7660_XOUT_R      0x00
+#define MMA7660_YOUT_R      0x01
+#define MMA7660_ZOUT_R      0x02
+#define MMA7660_TILT_R      0x03
+#define MMA7660_INT_R       0x06
+#define MMA7660_MODE_R      0x07
+#define MMA7660_SR_R        0x08
+
+
+/** An interface for the MMA7660 triple axis accelerometer
+ *
+ * @code
+ * //Uses the measured z-acceleration to drive leds 2 and 3 of the mbed
+ *
+ * #include "mbed.h"
+ * #include "MMA7660.h"
+ *
+ * MMA7660 MMA(p28, p27);
+ *
+ * DigitalOut connectionLed(LED1);
+ * PwmOut Zaxis_p(LED2);
+ * PwmOut Zaxis_n(LED3);
+ *
+ * int main() {
+ *     if (MMA.testConnection())
+ *         connectionLed = 1;
+ *
+ *     while(1) {
+ *         Zaxis_p = MMA.z();
+ *         Zaxis_n = -MMA.z();
+ *     }
+ *
+ * }
+ * @endcode
+ */
+class MMA7660
+{
+public:
+    /**
+    * The 6 different orientations and unknown
+    *
+    * Up & Down = X-axis
+    * Right & Left = Y-axis
+    * Back & Front = Z-axis
+    *
+    */
+    enum Orientation {Up, Down,
+                      Right, Left,
+                      Back, Front,
+                      Unknown
+                     };
+
+    /**
+    * Creates a new MMA7660 object
+    *
+    * @param sda - I2C data pin
+    * @param scl - I2C clock pin
+    * @param active - true (default) to enable the device, false to keep it standby
+    */
+    MMA7660(PinName sda, PinName scl, bool active = true);
+
+    /**
+    * Tests if communication is possible with the MMA7660
+    *
+    * Because the MMA7660 lacks a WHO_AM_I register, this function can only check
+    * if there is an I2C device that responds to the MMA7660 address
+    *
+    * @param return - true for successfull connection, false for no connection
+    */
+    bool testConnection( void );
+
+    /**
+    * Sets the active state of the MMA7660
+    *
+    * Note: This is unrelated to awake/sleep mode
+    *
+    * @param state - true for active, false for standby
+    */
+    void setActive( bool state);
+
+    /**
+    * Reads acceleration data from the sensor
+    *
+    * When the parameter is a pointer to an integer array it will be the raw data.
+    * When it is a pointer to a float array it will be the acceleration in g's
+    *
+    * @param data - pointer to array with length 3 where the acceleration data will be stored, X-Y-Z
+    */
+    void readData( int *data);
+    void readData( float *data);
+
+    /**
+    * Get X-data
+    *
+    * @param return - X-acceleration in g's
+    */
+    float x( void );
+
+    /**
+    * Get Y-data
+    *
+    * @param return - Y-acceleration in g's
+    */
+    float y( void );
+
+    /**
+    * Get Z-data
+    *
+    * @param return - Z-acceleration in g's
+    */
+    float z( void );
+
+    /**
+    * Sets the active samplerate
+    *
+    * The entered samplerate will be rounded to nearest supported samplerate.
+    * Supported samplerates are: 120 - 64 - 32 - 16 - 8 - 4 - 2 - 1 samples/second.
+    *
+    * @param samplerate - the samplerate that will be set
+    */
+    void setSampleRate(int samplerate);
+
+    /**
+    * Returns if it is on its front, back, or unknown side
+    *
+    * This is read from MMA7760s registers, page 12 of datasheet
+    *
+    * @param return - Front, Back or Unknown orientation
+    */
+    Orientation getSide( void );
+
+    /**
+    * Returns if it is on it left, right, down or up side
+    *
+    * This is read from MMA7760s registers, page 12 of datasheet
+    *
+    * @param return - Left, Right, Down, Up or Unknown orientation
+    */
+    Orientation getOrientation ( void );
+
+
+private:
+
+    /**
+    * Writes data to the device
+    *
+    * @param adress - register address to write to
+    * @param data - data to write
+    */
+    void write( char address, char data);
+
+    /**
+    * Read data from the device
+    *
+    * @param adress - register address to write to
+    * @return - data from the register specified by RA
+    */
+    char read( char adress);
+
+    /**
+     * Read multiple regigsters from the device, more efficient than using multiple normal reads.
+     *
+     * @param adress - register address to write to
+     * @param length - number of bytes to read
+     * @param data - pointer where the data needs to be written to
+     */
+    void read( char adress, char *data, int length);
+
+    /**
+    * Reads single axis
+    */
+    float getSingle(int number);
+
+    I2C _i2c;
+    bool active;
+    float samplerate;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/MSCFileSystem.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,113 @@
+/* USB Mass Storage device file system
+ * Copyrigh (c) 2010, Igor Skochinsky
+ * based on SDFileStorage
+ * Copyright (c) 2008-2009, sford
+ */
+ 
+/* Introduction
+ * ------------
+ * TODO: write one
+ * we're basically using NXP's USBHotLite sample code, just plugging in our own FAT library
+ */
+ 
+#include "MSCFileSystem.h"
+#include "usbhost_inc.h"
+
+MSCFileSystem::MSCFileSystem(const char* name) :
+  FATFileSystem(name)
+{
+}
+
+void print_inquiry(USB_INT08U *inqReply)
+{
+    // see USB Mass Storage Class – UFI Command Specification,
+    // 4.2 INQUIRY Command
+    printf("Inquiry reply:\n");
+    uint8_t tmp = inqReply[0]&0x1F;
+    printf("Peripheral device type: %02Xh\n", tmp);
+    if ( tmp == 0 )
+        printf("\t- Direct access (floppy)\n");
+    else if ( tmp == 0x1F )
+        printf("\t- none (no FDD connected)\n");
+    else
+        printf("\t- unknown type\n");
+    tmp = inqReply[1] >> 7;
+    printf("Removable Media Bit: %d\n", tmp);
+    tmp = inqReply[2] & 3;
+    printf("ANSI Version: %02Xh\n", tmp);
+    if ( tmp != 0 )
+        printf("\t- warning! must be 0\n");
+    tmp = (inqReply[2]>>3) & 3;
+    printf("ECMA Version: %02Xh\n", tmp);
+    if ( tmp != 0 )
+        printf("\t- warning! should be 0\n");
+    tmp = inqReply[2]>>6;
+    printf("ISO Version: %02Xh\n", tmp);
+    if ( tmp != 0 )
+        printf("\t- warning! should be 0\n");
+    tmp = inqReply[3] & 0xF;
+    printf("Response Data Format: %02Xh\n", tmp);
+    if ( tmp != 1 )
+        printf("\t- warning! should be 1\n");
+    tmp = inqReply[4];
+    printf("Additional length: %02Xh\n", tmp);
+    if ( tmp != 0x1F )
+        printf("\t- warning! should be 1Fh\n");
+    printf("Vendor Information: '%.8s'\n", &inqReply[8]);
+    printf("Product Identification: '%.16s'\n", &inqReply[16]);
+    printf("Product Revision: '%.4s'\n", &inqReply[32]);        
+}
+
+int MSCFileSystem::initialise_msc()
+{
+    USB_INT32S  rc;
+    USB_INT08U  inquiryResult[INQUIRY_LENGTH];
+    
+    //print_clock();
+    Host_Init();               /* Initialize the  host controller                                    */
+    rc = Host_EnumDev();       /* Enumerate the device connected                                            */
+    if (rc != OK)
+    {
+        fprintf(stderr, "Could not enumerate device: %d\n", rc);
+        return rc;
+    }
+        
+    
+    /* Initialize the mass storage and scsi interfaces */
+    rc = MS_Init( &_blkSize, &_numBlks, inquiryResult );
+    if (rc != OK)
+    {
+        fprintf(stderr, "Could not initialize mass storage interface: %d\n", rc);
+        return rc;
+    }
+    printf("Successfully initialized mass storage interface; %d blocks of size %d\n", _numBlks, _blkSize);
+    print_inquiry(inquiryResult);
+    // FATFileSystem supports only 512-byte blocks
+    return _blkSize == 512 ? OK : 1;
+}
+
+int MSCFileSystem::disk_initialize()
+{
+    if ( initialise_msc() != OK )
+        return 1;
+        
+    return 0;
+}
+
+int MSCFileSystem::disk_write(const char *buffer, int block_number)
+{
+    if ( OK == MS_BulkSend(block_number, 1, (USB_INT08U *)buffer) )
+        return 0;
+    return 1;
+}
+
+int MSCFileSystem::disk_read(char *buffer, int block_number)
+{
+    if ( OK == MS_BulkRecv(block_number, 1, (USB_INT08U *)buffer) )
+        return 0;
+    return 1;
+}
+
+int MSCFileSystem::disk_status() { return 0; }
+int MSCFileSystem::disk_sync() { return 0; }
+int MSCFileSystem::disk_sectors() { return _numBlks; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/MSCFileSystem.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,49 @@
+/* USB Mass Storage device file system
+ * Copyrigh (c) 2010, Igor Skochinsky
+ * based on SDFileStorage
+ * Copyright (c) 2008-2009, sford
+ */
+ 
+#ifndef MSCFILESYSTEM_H
+#define MSCFILESYSTEM_H
+
+#include "mbed.h"
+#include "FATFileSystem.h"
+
+/* Class: MSCFileSystem
+ *  Access the filesystem on an attached USB mass storage device (e.g. a memory stick)
+ *
+ * Example:
+ * > MSCFileSystem msc("msc");
+ * > 
+ * > int main() {
+ * >     FILE *fp = fopen("/msc/myfile.txt", "w");
+ * >     fprintf(fp, "Hello World!\n");
+ * >     fclose(fp);
+ * > }
+ */
+class MSCFileSystem : public FATFileSystem {
+public:
+
+    /* Constructor: MSCFileSystem
+     *  Create the File System for accessing a USB mass storage device
+     *
+     * Parameters:
+     *  name - The name used to access the filesystem
+     */
+    MSCFileSystem(const char* name);
+    virtual int disk_initialize();
+    virtual int disk_write(const char *buffer, int block_number);
+    virtual int disk_read(char *buffer, int block_number);    
+    virtual int disk_status();
+    virtual int disk_sync();
+    virtual int disk_sectors();
+
+protected:
+
+    int initialise_msc();
+    uint32_t _numBlks;
+    uint32_t _blkSize;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_cpu.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,35 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_cpu.h
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+
+#ifndef  USBHOST_CPU_H
+#define  USBHOST_CPU_H
+
+/*
+**************************************************************************************************************
+*                                           TYPE DEFINITIONS OF DATA TYPES
+**************************************************************************************************************
+*/
+
+typedef  unsigned int    USB_INT32U;
+typedef  signed   int    USB_INT32S;
+typedef  unsigned short  USB_INT16U;
+typedef  signed   short  USB_INT16S;
+typedef  unsigned char   USB_INT08U;
+typedef  signed   char   USB_INT08S;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_err.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,63 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_err.h
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+
+#ifndef  USBHOST_ERR_H
+#define  USBHOST_ERR_H
+
+
+/*
+**************************************************************************************************************
+*                                        GENERAL DEFINITIONS
+**************************************************************************************************************
+*/
+
+#define  OK                        0
+#define  MATCH_FOUND               0
+
+/*
+**************************************************************************************************************
+*                                HOST CONTROLLER SPECIFIC ERROR CODES
+**************************************************************************************************************
+*/
+
+#define  ERR_TD_FAIL              -1
+
+/*
+**************************************************************************************************************
+*                                  MASS STORAGE SPECIFIC ERROR CODES
+**************************************************************************************************************
+*/
+
+#define  ERR_MS_CMD_FAILED       -10
+#define  ERR_BAD_CONFIGURATION   -11
+#define  ERR_NO_MS_INTERFACE     -12
+
+/*
+**************************************************************************************************************
+*                                      FAT SPECIFIC ERROR CODES
+**************************************************************************************************************
+*/
+
+#define  MATCH_NOT_FOUND         -20
+#define  ERR_FAT_NOT_SUPPORTED   -21
+#define  ERR_OPEN_LIMIT_REACHED  -22
+#define  ERR_INVALID_BOOT_SIG    -23
+#define  ERR_INVALID_BOOT_SEC    -24
+#define  ERR_ROOT_DIR_FULL       -25
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_inc.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,39 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_inc.h
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+
+#ifndef  USBHOST_INC_H
+#define  USBHOST_INC_H
+
+/*
+**************************************************************************************************************
+*                                       INCLUDE HEADER FILES
+**************************************************************************************************************
+*/
+
+#include  "usbhost_cpu.h"
+#include  "usbhost_err.h"
+#include  "usbhost_lpc17xx.h"
+#include  "usbhost_ms.h"
+#include  "mbed.h"
+
+
+#ifdef TARGET_LPC2368
+#error "There is no USB host on the LPC2368!"
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_lpc17xx.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,827 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_lpc17xx.c
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+ 
+/*
+**************************************************************************************************************
+*                                            INCLUDE HEADER FILES
+**************************************************************************************************************
+*/
+
+#include  "usbhost_lpc17xx.h"
+
+/*
+**************************************************************************************************************
+*                                              GLOBAL VARIABLES
+**************************************************************************************************************
+*/
+int gUSBConnected;
+
+volatile  USB_INT32U   HOST_RhscIntr = 0;         /* Root Hub Status Change interrupt                       */
+volatile  USB_INT32U   HOST_WdhIntr  = 0;         /* Semaphore to wait until the TD is submitted            */
+volatile  USB_INT08U   HOST_TDControlStatus = 0;
+volatile  HCED        *EDCtrl;                    /* Control endpoint descriptor structure                  */
+volatile  HCED        *EDBulkIn;                  /* BulkIn endpoint descriptor  structure                  */
+volatile  HCED        *EDBulkOut;                 /* BulkOut endpoint descriptor structure                  */
+volatile  HCTD        *TDHead;                    /* Head transfer descriptor structure                     */
+volatile  HCTD        *TDTail;                    /* Tail transfer descriptor structure                     */
+volatile  HCCA        *Hcca;                      /* Host Controller Communications Area structure          */ 
+          USB_INT16U  *TDBufNonVol;               /* Identical to TDBuffer just to reduce compiler warnings */
+volatile  USB_INT08U  *TDBuffer;                  /* Current Buffer Pointer of transfer descriptor          */
+
+// USB host structures
+// AHB SRAM block 1
+#define HOSTBASEADDR 0x2007C000
+// reserve memory for the linker
+static USB_INT08U HostBuf[0x200] __attribute__((at(HOSTBASEADDR)));
+/*
+**************************************************************************************************************
+*                                         DELAY IN MILLI SECONDS
+*
+* Description: This function provides a delay in milli seconds
+*
+* Arguments  : delay    The delay required
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  Host_DelayMS (USB_INT32U  delay)
+{
+    volatile  USB_INT32U  i;
+
+
+    for (i = 0; i < delay; i++) {
+        Host_DelayUS(1000);
+    }
+}
+
+/*
+**************************************************************************************************************
+*                                         DELAY IN MICRO SECONDS
+*
+* Description: This function provides a delay in micro seconds
+*
+* Arguments  : delay    The delay required
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  Host_DelayUS (USB_INT32U  delay)
+{
+    volatile  USB_INT32U  i;
+
+
+    for (i = 0; i < (4 * delay); i++) {    /* This logic was tested. It gives app. 1 micro sec delay        */
+        ;
+    }
+}
+
+// bits of the USB/OTG clock control register
+#define HOST_CLK_EN     (1<<0)
+#define DEV_CLK_EN      (1<<1)
+#define PORTSEL_CLK_EN  (1<<3)
+#define AHB_CLK_EN      (1<<4)
+
+// bits of the USB/OTG clock status register
+#define HOST_CLK_ON     (1<<0)
+#define DEV_CLK_ON      (1<<1)
+#define PORTSEL_CLK_ON  (1<<3)
+#define AHB_CLK_ON      (1<<4)
+
+// we need host clock, OTG/portsel clock and AHB clock
+#define CLOCK_MASK (HOST_CLK_EN | PORTSEL_CLK_EN | AHB_CLK_EN)
+
+/*
+**************************************************************************************************************
+*                                         INITIALIZE THE HOST CONTROLLER
+*
+* Description: This function initializes lpc17xx host controller
+*
+* Arguments  : None
+*
+* Returns    : 
+*
+**************************************************************************************************************
+*/
+void  Host_Init (void)
+{
+    PRINT_Log("In Host_Init\n");
+    NVIC_DisableIRQ(USB_IRQn);                           /* Disable the USB interrupt source           */
+    
+    // turn on power for USB
+    LPC_SC->PCONP       |= (1UL<<31);
+    // Enable USB host clock, port selection and AHB clock
+    LPC_USB->USBClkCtrl |= CLOCK_MASK;
+    // Wait for clocks to become available
+    while ((LPC_USB->USBClkSt & CLOCK_MASK) != CLOCK_MASK)
+        ;
+    
+    // it seems the bits[0:1] mean the following
+    // 0: U1=device, U2=host
+    // 1: U1=host, U2=host
+    // 2: reserved
+    // 3: U1=host, U2=device
+    // NB: this register is only available if OTG clock (aka "port select") is enabled!!
+    // since we don't care about port 2, set just bit 0 to 1 (U1=host)
+    LPC_USB->OTGStCtrl |= 1;
+    
+    // now that we've configured the ports, we can turn off the portsel clock
+    LPC_USB->USBClkCtrl &= ~PORTSEL_CLK_EN;
+    
+    // power pins are not connected on mbed, so we can skip them
+    /* P1[18] = USB_UP_LED, 01 */
+    /* P1[19] = /USB_PPWR,     10 */
+    /* P1[22] = USB_PWRD, 10 */
+    /* P1[27] = /USB_OVRCR, 10 */
+    /*LPC_PINCON->PINSEL3 &= ~((3<<4) | (3<<6) | (3<<12) | (3<<22));  
+    LPC_PINCON->PINSEL3 |=  ((1<<4)|(2<<6) | (2<<12) | (2<<22));   // 0x00802080
+    */
+
+    // configure USB D+/D- pins
+    /* P0[29] = USB_D+, 01 */
+    /* P0[30] = USB_D-, 01 */
+    LPC_PINCON->PINSEL1 &= ~((3<<26) | (3<<28));  
+    LPC_PINCON->PINSEL1 |=  ((1<<26)|(1<<28));     // 0x14000000
+        
+    PRINT_Log("Initializing Host Stack\n");
+
+    Hcca       = (volatile  HCCA       *)(HostBuf+0x000);
+    TDHead     = (volatile  HCTD       *)(HostBuf+0x100);
+    TDTail     = (volatile  HCTD       *)(HostBuf+0x110);
+    EDCtrl     = (volatile  HCED       *)(HostBuf+0x120); 
+    EDBulkIn   = (volatile  HCED       *)(HostBuf+0x130);
+    EDBulkOut  = (volatile  HCED       *)(HostBuf+0x140);
+    TDBuffer   = (volatile  USB_INT08U *)(HostBuf+0x150);
+    
+    /* Initialize all the TDs, EDs and HCCA to 0  */
+    Host_EDInit(EDCtrl);
+    Host_EDInit(EDBulkIn);
+    Host_EDInit(EDBulkOut);
+    Host_TDInit(TDHead);
+    Host_TDInit(TDTail);
+    Host_HCCAInit(Hcca);
+    
+    Host_DelayMS(50);                                   /* Wait 50 ms before apply reset              */
+    LPC_USB->HcControl       = 0;                       /* HARDWARE RESET                             */
+    LPC_USB->HcControlHeadED = 0;                       /* Initialize Control list head to Zero       */
+    LPC_USB->HcBulkHeadED    = 0;                       /* Initialize Bulk list head to Zero          */
+    
+                                                        /* SOFTWARE RESET                             */
+    LPC_USB->HcCommandStatus = OR_CMD_STATUS_HCR;
+    LPC_USB->HcFmInterval    = DEFAULT_FMINTERVAL;      /* Write Fm Interval and Largest Data Packet Counter */
+
+                                                        /* Put HC in operational state                */
+    LPC_USB->HcControl  = (LPC_USB->HcControl & (~OR_CONTROL_HCFS)) | OR_CONTROL_HC_OPER;
+    LPC_USB->HcRhStatus = OR_RH_STATUS_LPSC;            /* Set Global Power                           */
+    
+    LPC_USB->HcHCCA = (USB_INT32U)Hcca;
+    LPC_USB->HcInterruptStatus |= LPC_USB->HcInterruptStatus;                   /* Clear Interrrupt Status                    */
+
+
+    LPC_USB->HcInterruptEnable  = OR_INTR_ENABLE_MIE |
+                         OR_INTR_ENABLE_WDH |
+                         OR_INTR_ENABLE_RHSC;
+
+    NVIC_SetPriority(USB_IRQn, 0);       /* highest priority */
+    /* Enable the USB Interrupt */
+    NVIC_EnableIRQ(USB_IRQn);
+    PRINT_Log("Host Initialized\n");
+}
+
+/*
+**************************************************************************************************************
+*                                         INTERRUPT SERVICE ROUTINE
+*
+* Description: This function services the interrupt caused by host controller
+*
+* Arguments  : None
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void USB_IRQHandler (void) __irq
+{
+    USB_INT32U   int_status;
+    USB_INT32U   ie_status;
+
+    int_status    = LPC_USB->HcInterruptStatus;                          /* Read Interrupt Status                */
+    ie_status     = LPC_USB->HcInterruptEnable;                          /* Read Interrupt enable status         */
+ 
+    if (!(int_status & ie_status)) {
+        return;
+    } else {
+
+        int_status = int_status & ie_status;
+        if (int_status & OR_INTR_STATUS_RHSC) {                 /* Root hub status change interrupt     */
+            if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CSC) {
+                if (LPC_USB->HcRhStatus & OR_RH_STATUS_DRWE) {
+                    /*
+                     * When DRWE is on, Connect Status Change
+                     * means a remote wakeup event.
+                    */
+                    HOST_RhscIntr = 1;// JUST SOMETHING FOR A BREAKPOINT
+                }
+                else {
+                    /*
+                     * When DRWE is off, Connect Status Change
+                     * is NOT a remote wakeup event
+                    */
+                    if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_CCS) {
+                        if (!gUSBConnected) {
+                            HOST_TDControlStatus = 0;
+                            HOST_WdhIntr = 0;
+                            HOST_RhscIntr = 1;
+                            gUSBConnected = 1;
+                        }
+                        else
+                            PRINT_Log("Spurious status change (connected)?\n");
+                    } else {
+                        if (gUSBConnected) {
+                            LPC_USB->HcInterruptEnable = 0; // why do we get multiple disc. rupts???
+                            HOST_RhscIntr = 0;
+                            gUSBConnected = 0;
+                        }
+                        else
+                            PRINT_Log("Spurious status change (disconnected)?\n");
+                    }
+                }
+                LPC_USB->HcRhPortStatus1 = OR_RH_PORT_CSC;
+            }
+            if (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_PRSC) {
+                LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC;
+            }
+        }
+        if (int_status & OR_INTR_STATUS_WDH) {                  /* Writeback Done Head interrupt        */
+            HOST_WdhIntr = 1;
+            HOST_TDControlStatus = (TDHead->Control >> 28) & 0xf;
+        }            
+        LPC_USB->HcInterruptStatus = int_status;                         /* Clear interrupt status register      */
+    }
+    return;
+}
+
+/*
+**************************************************************************************************************
+*                                     PROCESS TRANSFER DESCRIPTOR
+*
+* Description: This function processes the transfer descriptor
+*
+* Arguments  : ed            Endpoint descriptor that contains this transfer descriptor
+*              token         SETUP, IN, OUT
+*              buffer        Current Buffer Pointer of the transfer descriptor
+*              buffer_len    Length of the buffer
+*
+* Returns    : OK       if TD submission is successful
+*              ERROR    if TD submission fails
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  Host_ProcessTD (volatile  HCED       *ed,
+                            volatile  USB_INT32U  token,
+                            volatile  USB_INT08U *buffer,
+                                      USB_INT32U  buffer_len)
+{
+    volatile  USB_INT32U   td_toggle;
+
+
+    if (ed == EDCtrl) {
+        if (token == TD_SETUP) {
+            td_toggle = TD_TOGGLE_0;
+        } else {
+            td_toggle = TD_TOGGLE_1;
+        }
+    } else {
+        td_toggle = 0;
+    }
+    TDHead->Control = (TD_ROUNDING    |
+                      token           |
+                      TD_DELAY_INT(0) |                           
+                      td_toggle       |
+                      TD_CC);
+    TDTail->Control = 0;
+    TDHead->CurrBufPtr   = (USB_INT32U) buffer;
+    TDTail->CurrBufPtr   = 0;
+    TDHead->Next         = (USB_INT32U) TDTail;
+    TDTail->Next         = 0;
+    TDHead->BufEnd       = (USB_INT32U)(buffer + (buffer_len - 1));
+    TDTail->BufEnd       = 0;
+
+    ed->HeadTd  = (USB_INT32U)TDHead | ((ed->HeadTd) & 0x00000002);
+    ed->TailTd  = (USB_INT32U)TDTail;
+    ed->Next    = 0;
+
+    if (ed == EDCtrl) {
+        LPC_USB->HcControlHeadED = (USB_INT32U)ed;
+        LPC_USB->HcCommandStatus = LPC_USB->HcCommandStatus | OR_CMD_STATUS_CLF;
+        LPC_USB->HcControl       = LPC_USB->HcControl       | OR_CONTROL_CLE;
+    } else {
+        LPC_USB->HcBulkHeadED    = (USB_INT32U)ed;
+        LPC_USB->HcCommandStatus = LPC_USB->HcCommandStatus | OR_CMD_STATUS_BLF;
+        LPC_USB->HcControl       = LPC_USB->HcControl       | OR_CONTROL_BLE;
+    }    
+
+    Host_WDHWait();
+
+//    if (!(TDHead->Control & 0xF0000000)) {
+    if (!HOST_TDControlStatus) {
+        return (OK);
+    } else {      
+        return (ERR_TD_FAIL);
+    }
+}
+
+/*
+**************************************************************************************************************
+*                                       ENUMERATE THE DEVICE
+*
+* Description: This function is used to enumerate the device connected
+*
+* Arguments  : None
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  Host_EnumDev (void)
+{
+    USB_INT32S  rc;
+
+    PRINT_Log("Connect a Mass Storage device\n");
+    while (!HOST_RhscIntr)
+        __WFI();
+    Host_DelayMS(100);                             /* USB 2.0 spec says atleast 50ms delay beore port reset */
+    LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRS; // Initiate port reset
+    while (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_PRS)
+        __WFI(); // Wait for port reset to complete...
+    LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC; // ...and clear port reset signal
+    Host_DelayMS(200);                                                 /* Wait for 100 MS after port reset  */
+
+    EDCtrl->Control = 8 << 16;                                         /* Put max pkt size = 8              */
+                                                                       /* Read first 8 bytes of device desc */
+    rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_DEVICE, 0, TDBuffer, 8);
+    if (rc != OK) {
+        PRINT_Err(rc);
+        return (rc);
+    }
+    EDCtrl->Control = TDBuffer[7] << 16;                               /* Get max pkt size of endpoint 0    */
+    rc = HOST_SET_ADDRESS(1);                                          /* Set the device address to 1       */
+    if (rc != OK) {
+        PRINT_Err(rc);
+        return (rc);
+    }
+    Host_DelayMS(2);
+    EDCtrl->Control = (EDCtrl->Control) | 1;                          /* Modify control pipe with address 1 */
+                                                                      /* Get the configuration descriptor   */
+    rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_CONFIGURATION, 0, TDBuffer, 9);
+    if (rc != OK) {
+        PRINT_Err(rc);
+        return (rc);
+    }
+                                                                       /* Get the first configuration data  */
+    rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_CONFIGURATION, 0, TDBuffer, ReadLE16U(&TDBuffer[2]));
+    if (rc != OK) {
+        PRINT_Err(rc);
+        return (rc);
+    }
+    rc = MS_ParseConfiguration();                                      /* Parse the configuration           */
+    if (rc != OK) {
+        PRINT_Err(rc);
+        return (rc);
+    }
+    rc = USBH_SET_CONFIGURATION(1);                                    /* Select device configuration 1     */
+    if (rc != OK) {
+        PRINT_Err(rc);
+    }
+    Host_DelayMS(100);                                               /* Some devices may require this delay */
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                        RECEIVE THE CONTROL INFORMATION
+*
+* Description: This function is used to receive the control information
+*
+* Arguments  : bm_request_type
+*              b_request
+*              w_value
+*              w_index
+*              w_length
+*              buffer
+*
+* Returns    : OK       if Success
+*              ERROR    if Failed
+*
+**************************************************************************************************************
+*/
+   
+USB_INT32S  Host_CtrlRecv (         USB_INT08U   bm_request_type,
+                                    USB_INT08U   b_request,
+                                    USB_INT16U   w_value,
+                                    USB_INT16U   w_index,
+                                    USB_INT16U   w_length,
+                          volatile  USB_INT08U  *buffer)
+{
+    USB_INT32S  rc;
+
+
+    Host_FillSetup(bm_request_type, b_request, w_value, w_index, w_length);
+    rc = Host_ProcessTD(EDCtrl, TD_SETUP, TDBuffer, 8);
+    if (rc == OK) {
+        if (w_length) {
+            rc = Host_ProcessTD(EDCtrl, TD_IN, TDBuffer, w_length);
+        }
+        if (rc == OK) {
+            rc = Host_ProcessTD(EDCtrl, TD_OUT, NULL, 0);
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                         SEND THE CONTROL INFORMATION
+*
+* Description: This function is used to send the control information
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  Host_CtrlSend (          USB_INT08U   bm_request_type,
+                                     USB_INT08U   b_request,
+                                     USB_INT16U   w_value,
+                                     USB_INT16U   w_index,
+                                     USB_INT16U   w_length,
+                           volatile  USB_INT08U  *buffer)
+{
+    USB_INT32S  rc;
+
+
+    Host_FillSetup(bm_request_type, b_request, w_value, w_index, w_length);
+
+    rc = Host_ProcessTD(EDCtrl, TD_SETUP, TDBuffer, 8);
+    if (rc == OK) {
+        if (w_length) {
+            rc = Host_ProcessTD(EDCtrl, TD_OUT, TDBuffer, w_length);
+        }
+        if (rc == OK) {
+            rc = Host_ProcessTD(EDCtrl, TD_IN, NULL, 0);
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                          FILL SETUP PACKET
+*
+* Description: This function is used to fill the setup packet
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+void  Host_FillSetup (USB_INT08U   bm_request_type,
+                      USB_INT08U   b_request,
+                      USB_INT16U   w_value,
+                      USB_INT16U   w_index,
+                      USB_INT16U   w_length)
+{
+    int i;
+    for (i=0;i<w_length;i++)
+        TDBuffer[i] = 0;
+    
+    TDBuffer[0] = bm_request_type;
+    TDBuffer[1] = b_request;
+    WriteLE16U(&TDBuffer[2], w_value);
+    WriteLE16U(&TDBuffer[4], w_index);
+    WriteLE16U(&TDBuffer[6], w_length);
+}
+
+
+
+/*
+**************************************************************************************************************
+*                                         INITIALIZE THE TRANSFER DESCRIPTOR
+*
+* Description: This function initializes transfer descriptor
+*
+* Arguments  : Pointer to TD structure
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  Host_TDInit (volatile  HCTD *td)
+{
+
+    td->Control    = 0;
+    td->CurrBufPtr = 0;
+    td->Next       = 0;
+    td->BufEnd     = 0;
+}
+
+/*
+**************************************************************************************************************
+*                                         INITIALIZE THE ENDPOINT DESCRIPTOR
+*
+* Description: This function initializes endpoint descriptor
+*
+* Arguments  : Pointer to ED strcuture
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  Host_EDInit (volatile  HCED *ed)
+{
+
+    ed->Control = 0;
+    ed->TailTd  = 0;
+    ed->HeadTd  = 0;
+    ed->Next    = 0;
+}
+
+/*
+**************************************************************************************************************
+*                                 INITIALIZE HOST CONTROLLER COMMUNICATIONS AREA
+*
+* Description: This function initializes host controller communications area
+*
+* Arguments  : Pointer to HCCA
+*
+* Returns    : 
+*
+**************************************************************************************************************
+*/
+
+void  Host_HCCAInit (volatile  HCCA  *hcca)
+{
+    USB_INT32U  i;
+
+
+    for (i = 0; i < 32; i++) {
+
+        hcca->IntTable[i] = 0;
+        hcca->FrameNumber = 0;
+        hcca->DoneHead    = 0;
+    }
+
+}
+
+/*
+**************************************************************************************************************
+*                                         WAIT FOR WDH INTERRUPT
+*
+* Description: This function is infinite loop which breaks when ever a WDH interrupt rises
+*
+* Arguments  : None
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  Host_WDHWait (void)
+{
+  while (!HOST_WdhIntr) {
+    ;
+  }
+  HOST_WdhIntr = 0;
+}
+
+
+
+
+
+
+
+
+/*
+**************************************************************************************************************
+*                                         READ LE 32U
+*
+* Description: This function is used to read an unsigned integer from a character buffer in the platform
+*              containing little endian processor
+*
+* Arguments  : pmem    Pointer to the character buffer
+*
+* Returns    : val     Unsigned integer
+*
+**************************************************************************************************************
+*/
+
+USB_INT32U  ReadLE32U (volatile  USB_INT08U  *pmem)
+{
+    USB_INT32U val = *(USB_INT32U*)pmem;
+#ifdef __BIG_ENDIAN
+    return __REV(val);
+#else
+    return val;
+#endif    
+}
+
+/*
+**************************************************************************************************************
+*                                        WRITE LE 32U
+*
+* Description: This function is used to write an unsigned integer into a charecter buffer in the platform 
+*              containing little endian processor.
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*              val     Integer value to be placed in the charecter buffer
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  WriteLE32U (volatile  USB_INT08U  *pmem,
+                            USB_INT32U   val)
+{
+#ifdef __BIG_ENDIAN
+    *(USB_INT32U*)pmem = __REV(val);
+#else
+    *(USB_INT32U*)pmem = val;
+#endif
+}
+
+/*
+**************************************************************************************************************
+*                                          READ LE 16U
+*
+* Description: This function is used to read an unsigned short integer from a charecter buffer in the platform
+*              containing little endian processor
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*
+* Returns    : val     Unsigned short integer
+*
+**************************************************************************************************************
+*/
+
+USB_INT16U  ReadLE16U (volatile  USB_INT08U  *pmem)
+{
+    USB_INT16U val = *(USB_INT16U*)pmem;
+#ifdef __BIG_ENDIAN
+    return __REV16(val);
+#else
+    return val;
+#endif    
+}
+
+/*
+**************************************************************************************************************
+*                                         WRITE LE 16U
+*
+* Description: This function is used to write an unsigned short integer into a charecter buffer in the
+*              platform containing little endian processor
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*              val     Value to be placed in the charecter buffer
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  WriteLE16U (volatile  USB_INT08U  *pmem,
+                            USB_INT16U   val)
+{
+#ifdef __BIG_ENDIAN
+    *(USB_INT16U*)pmem = (__REV16(val) & 0xFFFF);
+#else
+    *(USB_INT16U*)pmem = val;
+#endif
+}
+
+/*
+**************************************************************************************************************
+*                                         READ BE 32U
+*
+* Description: This function is used to read an unsigned integer from a charecter buffer in the platform
+*              containing big endian processor
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*
+* Returns    : val     Unsigned integer
+*
+**************************************************************************************************************
+*/
+
+USB_INT32U  ReadBE32U (volatile  USB_INT08U  *pmem)
+{
+    USB_INT32U val = *(USB_INT32U*)pmem;
+#ifdef __BIG_ENDIAN
+    return val;
+#else
+    return __REV(val);
+#endif
+}
+
+/*
+**************************************************************************************************************
+*                                         WRITE BE 32U
+*
+* Description: This function is used to write an unsigned integer into a charecter buffer in the platform
+*              containing big endian processor
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*              val     Value to be placed in the charecter buffer
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  WriteBE32U (volatile  USB_INT08U  *pmem,
+                            USB_INT32U   val)
+{
+#ifdef __BIG_ENDIAN
+    *(USB_INT32U*)pmem = val;
+#else
+    *(USB_INT32U*)pmem = __REV(val);
+#endif
+}
+
+/*
+**************************************************************************************************************
+*                                         READ BE 16U
+*
+* Description: This function is used to read an unsigned short integer from a charecter buffer in the platform
+*              containing big endian processor
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*
+* Returns    : val     Unsigned short integer
+*
+**************************************************************************************************************
+*/
+
+USB_INT16U  ReadBE16U (volatile  USB_INT08U  *pmem)
+{
+    USB_INT16U val = *(USB_INT16U*)pmem;
+#ifdef __BIG_ENDIAN
+    return val;
+#else
+    return __REV16(val);
+#endif    
+}
+
+/*
+**************************************************************************************************************
+*                                         WRITE BE 16U
+*
+* Description: This function is used to write an unsigned short integer into the charecter buffer in the
+*              platform containing big endian processor
+*
+* Arguments  : pmem    Pointer to the charecter buffer
+*              val     Value to be placed in the charecter buffer
+*
+* Returns    : None
+*
+**************************************************************************************************************
+*/
+
+void  WriteBE16U (volatile  USB_INT08U  *pmem,
+                            USB_INT16U   val)
+{
+#ifdef __BIG_ENDIAN
+    *(USB_INT16U*)pmem = val;
+#else
+    *(USB_INT16U*)pmem = (__REV16(val) & 0xFFFF);
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_lpc17xx.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,254 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_lpc17xx.h
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+
+#ifndef USBHOST_LPC17xx_H
+#define USBHOST_LPC17xx_H
+
+/*
+**************************************************************************************************************
+*                                       INCLUDE HEADER FILES
+**************************************************************************************************************
+*/
+
+#include    "usbhost_inc.h"
+
+/*
+**************************************************************************************************************
+*                                        PRINT CONFIGURATION
+**************************************************************************************************************
+*/
+
+#define  PRINT_ENABLE         1
+
+#if PRINT_ENABLE
+#define  PRINT_Log(...)       printf(__VA_ARGS__)
+#define  PRINT_Err(rc)        printf("ERROR: In %s at Line %u - rc = %d\n", __FUNCTION__, __LINE__, rc)
+
+#else 
+#define  PRINT_Log(...)       do {} while(0)
+#define  PRINT_Err(rc)        do {} while(0)
+
+#endif
+
+/*
+**************************************************************************************************************
+*                                        GENERAL DEFINITIONS
+**************************************************************************************************************
+*/
+
+#define  DESC_LENGTH(x)  x[0]
+#define  DESC_TYPE(x)    x[1]
+
+
+#define  HOST_GET_DESCRIPTOR(descType, descIndex, data, length)                      \
+         Host_CtrlRecv(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR,    \
+         (descType << 8)|(descIndex), 0, length, data)
+
+#define  HOST_SET_ADDRESS(new_addr)                                                  \
+         Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_ADDRESS,       \
+         new_addr, 0, 0, NULL)
+
+#define  USBH_SET_CONFIGURATION(configNum)                                           \
+         Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_CONFIGURATION, \
+         configNum, 0, 0, NULL)
+
+#define  USBH_SET_INTERFACE(ifNum, altNum)                                           \
+         Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE, SET_INTERFACE,  \
+         altNum, ifNum, 0, NULL)
+
+/*
+**************************************************************************************************************
+*                                  OHCI OPERATIONAL REGISTER FIELD DEFINITIONS
+**************************************************************************************************************
+*/
+
+                                            /* ------------------ HcControl Register ---------------------  */
+#define  OR_CONTROL_CLE                 0x00000010
+#define  OR_CONTROL_BLE                 0x00000020
+#define  OR_CONTROL_HCFS                0x000000C0
+#define  OR_CONTROL_HC_OPER             0x00000080
+                                            /* ----------------- HcCommandStatus Register ----------------- */
+#define  OR_CMD_STATUS_HCR              0x00000001
+#define  OR_CMD_STATUS_CLF              0x00000002
+#define  OR_CMD_STATUS_BLF              0x00000004
+                                            /* --------------- HcInterruptStatus Register ----------------- */
+#define  OR_INTR_STATUS_WDH             0x00000002
+#define  OR_INTR_STATUS_RHSC            0x00000040
+                                            /* --------------- HcInterruptEnable Register ----------------- */
+#define  OR_INTR_ENABLE_WDH             0x00000002
+#define  OR_INTR_ENABLE_RHSC            0x00000040
+#define  OR_INTR_ENABLE_MIE             0x80000000
+                                            /* ---------------- HcRhDescriptorA Register ------------------ */
+#define  OR_RH_STATUS_LPSC              0x00010000
+#define  OR_RH_STATUS_DRWE              0x00008000
+                                            /* -------------- HcRhPortStatus[1:NDP] Register -------------- */
+#define  OR_RH_PORT_CCS                 0x00000001
+#define  OR_RH_PORT_PRS                 0x00000010
+#define  OR_RH_PORT_CSC                 0x00010000
+#define  OR_RH_PORT_PRSC                0x00100000
+
+
+/*
+**************************************************************************************************************
+*                                               FRAME INTERVAL
+**************************************************************************************************************
+*/
+
+#define  FI                     0x2EDF           /* 12000 bits per frame (-1)                               */
+#define  DEFAULT_FMINTERVAL     ((((6 * (FI - 210)) / 7) << 16) | FI)
+
+/*
+**************************************************************************************************************
+*                                       TRANSFER DESCRIPTOR CONTROL FIELDS
+**************************************************************************************************************
+*/
+
+#define  TD_ROUNDING        (USB_INT32U) (0x00040000)        /* Buffer Rounding                             */
+#define  TD_SETUP           (USB_INT32U)(0)                  /* Direction of Setup Packet                   */
+#define  TD_IN              (USB_INT32U)(0x00100000)         /* Direction In                                */
+#define  TD_OUT             (USB_INT32U)(0x00080000)         /* Direction Out                               */
+#define  TD_DELAY_INT(x)    (USB_INT32U)((x) << 21)          /* Delay Interrupt                             */
+#define  TD_TOGGLE_0        (USB_INT32U)(0x02000000)         /* Toggle 0                                    */
+#define  TD_TOGGLE_1        (USB_INT32U)(0x03000000)         /* Toggle 1                                    */
+#define  TD_CC              (USB_INT32U)(0xF0000000)         /* Completion Code                             */
+
+/*
+**************************************************************************************************************
+*                                       USB STANDARD REQUEST DEFINITIONS
+**************************************************************************************************************
+*/
+
+#define  USB_DESCRIPTOR_TYPE_DEVICE                     1
+#define  USB_DESCRIPTOR_TYPE_CONFIGURATION              2
+#define  USB_DESCRIPTOR_TYPE_INTERFACE                  4
+#define  USB_DESCRIPTOR_TYPE_ENDPOINT                   5
+                                                    /*  ----------- Control RequestType Fields  ----------- */
+#define  USB_DEVICE_TO_HOST         0x80
+#define  USB_HOST_TO_DEVICE         0x00
+#define  USB_REQUEST_TYPE_CLASS     0x20
+#define  USB_RECIPIENT_DEVICE       0x00
+#define  USB_RECIPIENT_INTERFACE    0x01
+                                                    /* -------------- USB Standard Requests  -------------- */
+#define  SET_ADDRESS                 5
+#define  GET_DESCRIPTOR              6
+#define  SET_CONFIGURATION           9
+#define  SET_INTERFACE              11
+
+/*
+**************************************************************************************************************
+*                                       TYPE DEFINITIONS
+**************************************************************************************************************
+*/
+
+typedef struct hcEd {                       /* ----------- HostController EndPoint Descriptor ------------- */
+    volatile  USB_INT32U  Control;              /* Endpoint descriptor control                              */
+    volatile  USB_INT32U  TailTd;               /* Physical address of tail in Transfer descriptor list     */
+    volatile  USB_INT32U  HeadTd;               /* Physcial address of head in Transfer descriptor list     */
+    volatile  USB_INT32U  Next;                 /* Physical address of next Endpoint descriptor             */
+} HCED;
+
+typedef struct hcTd {                       /* ------------ HostController Transfer Descriptor ------------ */
+    volatile  USB_INT32U  Control;              /* Transfer descriptor control                              */
+    volatile  USB_INT32U  CurrBufPtr;           /* Physical address of current buffer pointer               */
+    volatile  USB_INT32U  Next;                 /* Physical pointer to next Transfer Descriptor             */
+    volatile  USB_INT32U  BufEnd;               /* Physical address of end of buffer                        */
+} HCTD;
+
+typedef struct hcca {                       /* ----------- Host Controller Communication Area ------------  */
+    volatile  USB_INT32U  IntTable[32];         /* Interrupt Table                                          */
+    volatile  USB_INT32U  FrameNumber;          /* Frame Number                                             */
+    volatile  USB_INT32U  DoneHead;             /* Done Head                                                */
+    volatile  USB_INT08U  Reserved[116];        /* Reserved for future use                                  */
+    volatile  USB_INT08U  Unknown[4];           /* Unused                                                   */
+} HCCA;
+
+/*
+**************************************************************************************************************
+*                                     EXTERN DECLARATIONS
+**************************************************************************************************************
+*/
+
+extern  volatile  HCED        *EDBulkIn;        /* BulkIn endpoint descriptor  structure                    */
+extern  volatile  HCED        *EDBulkOut;       /* BulkOut endpoint descriptor structure                    */
+extern  volatile  HCTD        *TDHead;          /* Head transfer descriptor structure                       */
+extern  volatile  HCTD        *TDTail;          /* Tail transfer descriptor structure                       */
+extern  volatile  USB_INT08U  *TDBuffer;        /* Current Buffer Pointer of transfer descriptor            */
+
+/*
+**************************************************************************************************************
+*                                       FUNCTION PROTOTYPES
+**************************************************************************************************************
+*/
+
+void        Host_Init     (void);
+
+extern "C" void USB_IRQHandler(void)  __irq;
+
+USB_INT32S  Host_EnumDev  (void);
+
+USB_INT32S  Host_ProcessTD(volatile  HCED       *ed,
+                           volatile  USB_INT32U  token,
+                           volatile  USB_INT08U *buffer,
+                                     USB_INT32U  buffer_len);
+
+void        Host_DelayUS  (          USB_INT32U    delay);
+void        Host_DelayMS  (          USB_INT32U    delay);
+
+
+void        Host_TDInit   (volatile  HCTD *td);
+void        Host_EDInit   (volatile  HCED *ed);
+void        Host_HCCAInit (volatile  HCCA  *hcca);
+
+USB_INT32S  Host_CtrlRecv (          USB_INT08U   bm_request_type,
+                                     USB_INT08U   b_request,
+                                     USB_INT16U   w_value,
+                                     USB_INT16U   w_index,
+                                     USB_INT16U   w_length,
+                           volatile  USB_INT08U  *buffer);
+
+USB_INT32S  Host_CtrlSend (          USB_INT08U   bm_request_type,
+                                     USB_INT08U   b_request,
+                                     USB_INT16U   w_value,
+                                     USB_INT16U   w_index,
+                                     USB_INT16U   w_length,
+                           volatile  USB_INT08U  *buffer);
+
+void        Host_FillSetup(          USB_INT08U   bm_request_type,
+                                     USB_INT08U   b_request,
+                                     USB_INT16U   w_value,
+                                     USB_INT16U   w_index,
+                                     USB_INT16U   w_length);
+
+
+void        Host_WDHWait  (void);
+
+
+USB_INT32U  ReadLE32U     (volatile  USB_INT08U  *pmem);
+void        WriteLE32U    (volatile  USB_INT08U  *pmem,
+                                     USB_INT32U   val);
+USB_INT16U  ReadLE16U     (volatile  USB_INT08U  *pmem);
+void        WriteLE16U    (volatile  USB_INT08U  *pmem,
+                                     USB_INT16U   val);
+USB_INT32U  ReadBE32U     (volatile  USB_INT08U  *pmem);
+void        WriteBE32U    (volatile  USB_INT08U  *pmem,
+                                     USB_INT32U   val);
+USB_INT16U  ReadBE16U     (volatile  USB_INT08U  *pmem);
+void        WriteBE16U    (volatile  USB_INT08U  *pmem,
+                                     USB_INT16U   val);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_ms.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,455 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_ms.c
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+
+/*
+**************************************************************************************************************
+*                                       INCLUDE HEADER FILES
+**************************************************************************************************************
+*/
+
+#include  "usbhost_ms.h"
+
+/*
+**************************************************************************************************************
+*                                         GLOBAL VARIABLES
+**************************************************************************************************************
+*/
+
+USB_INT32U  MS_BlkSize;
+
+/*
+**************************************************************************************************************
+*                                      INITIALIZE MASS STORAGE INTERFACE
+*
+* Description: This function initializes the mass storage interface
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S MS_Init (USB_INT32U *blkSize, USB_INT32U *numBlks, USB_INT08U *inquiryResult)
+{
+    USB_INT08U  retry;
+    USB_INT32S  rc;
+
+    MS_GetMaxLUN();                                                    /* Get maximum logical unit number   */
+    retry  = 80;
+    while(retry) {
+        rc = MS_TestUnitReady();                                       /* Test whether the unit is ready    */
+        if (rc == OK) {
+            break;
+        }
+        MS_GetSenseInfo();                                             /* Get sense information             */
+        retry--;
+    }
+    if (rc != OK) {
+        PRINT_Err(rc);
+        return (rc);
+    }
+    rc = MS_ReadCapacity(numBlks, blkSize);                         /* Read capacity of the disk         */
+    MS_BlkSize = *blkSize;                        // Set global
+    rc = MS_Inquire (inquiryResult);
+    return (rc);
+}
+/*
+**************************************************************************************************************
+*                                         PARSE THE CONFIGURATION
+*
+* Description: This function is used to parse the configuration
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  MS_ParseConfiguration (void)
+{
+    volatile  USB_INT08U  *desc_ptr;
+              USB_INT08U   ms_int_found;
+
+
+    desc_ptr     = TDBuffer;
+    ms_int_found = 0;
+
+    if (desc_ptr[1] != USB_DESCRIPTOR_TYPE_CONFIGURATION) {    
+        return (ERR_BAD_CONFIGURATION);
+    }
+    desc_ptr += desc_ptr[0];
+
+    while (desc_ptr != TDBuffer + ReadLE16U(&TDBuffer[2])) {
+
+        switch (desc_ptr[1]) {
+
+            case USB_DESCRIPTOR_TYPE_INTERFACE:                       /* If it is an interface descriptor   */
+                 if (desc_ptr[5] == MASS_STORAGE_CLASS &&             /* check if the class is mass storage */
+                     desc_ptr[6] == MASS_STORAGE_SUBCLASS_SCSI &&     /* check if the subclass is SCSI      */
+                     desc_ptr[7] == MASS_STORAGE_PROTOCOL_BO) {       /* check if the protocol is Bulk only */
+                     ms_int_found = 1;
+                     desc_ptr    += desc_ptr[0];                      /* Move to next descriptor start      */
+                 }
+                 break;
+
+            case USB_DESCRIPTOR_TYPE_ENDPOINT:                        /* If it is an endpoint descriptor    */
+                 if ((desc_ptr[3] & 0x03) == 0x02) {                  /* If it is Bulk endpoint             */
+                     if (desc_ptr[2] & 0x80) {                        /* If it is In endpoint               */
+                         EDBulkIn->Control =  1                             |      /* USB address           */
+                                              ((desc_ptr[2] & 0x7F) << 7)   |      /* Endpoint address      */
+                                              (2 << 11)                     |      /* direction             */
+                                              (ReadLE16U(&desc_ptr[4]) << 16);     /* MaxPkt Size           */
+                         desc_ptr += desc_ptr[0];                     /* Move to next descriptor start      */
+                     } else {                                         /* If it is Out endpoint              */
+                         EDBulkOut->Control = 1                             |      /* USB address           */
+                                              ((desc_ptr[2] & 0x7F) << 7)   |      /* Endpoint address      */
+                                              (1 << 11)                     |      /* direction             */
+                                              (ReadLE16U(&desc_ptr[4]) << 16);     /* MaxPkt Size           */
+                         desc_ptr += desc_ptr[0];                     /* Move to next descriptor start      */
+                     }
+                 } else {                                             /* If it is not bulk end point        */
+                     desc_ptr += desc_ptr[0];                         /* Move to next descriptor start      */
+                 }
+                 break;
+
+            default:                                 /* If the descriptor is neither interface nor endpoint */
+                 desc_ptr += desc_ptr[0];                             /* Move to next descriptor start      */
+                 break;
+        }
+    }
+    if (ms_int_found) {
+        PRINT_Log("Mass Storage device connected\n");
+        return (OK);
+    } else {
+        PRINT_Log("Not a Mass Storage device\n");
+        return (ERR_NO_MS_INTERFACE);
+    }
+}
+
+/*
+**************************************************************************************************************
+*                                         GET MAXIMUM LOGICAL UNIT
+*
+* Description: This function returns the maximum logical unit from the device
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  MS_GetMaxLUN (void)
+{
+    USB_INT32S  rc;
+
+
+    rc = Host_CtrlRecv(USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE,
+                       MS_GET_MAX_LUN_REQ,
+                       0,
+                       0,
+                       1,
+                       TDBuffer);
+    return (rc); 
+}
+
+/*
+**************************************************************************************************************
+*                                          GET SENSE INFORMATION
+*
+* Description: This function is used to get sense information from the device
+*
+* Arguments  : None
+*
+* Returns    : OK       if Success
+*              ERROR    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  MS_GetSenseInfo (void)
+{
+    USB_INT32S  rc;
+
+
+    Fill_MSCommand(0, 0, 0, MS_DATA_DIR_IN, SCSI_CMD_REQUEST_SENSE, 6);
+    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
+    if (rc == OK) {
+        rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, 18);
+        if (rc == OK) {
+            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
+            if (rc == OK) {
+                if (TDBuffer[12] != 0) {
+                    rc = ERR_MS_CMD_FAILED;
+                }
+            }
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                           TEST UNIT READY
+*
+* Description: This function is used to test whether the unit is ready or not
+*
+* Arguments  : None
+*
+* Returns    : OK       if Success
+*              ERROR    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  MS_TestUnitReady (void)
+{
+    USB_INT32S  rc;
+
+
+    Fill_MSCommand(0, 0, 0, MS_DATA_DIR_NONE, SCSI_CMD_TEST_UNIT_READY, 6);
+    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
+    if (rc == OK) {
+        rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
+        if (rc == OK) {        
+            if (TDBuffer[12] != 0) {
+                rc = ERR_MS_CMD_FAILED;
+            }
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                            READ CAPACITY
+*
+* Description: This function is used to read the capacity of the mass storage device
+*
+* Arguments  : None
+*
+* Returns    : OK       if Success
+*              ERROR    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S MS_ReadCapacity (USB_INT32U *numBlks, USB_INT32U *blkSize)
+{
+    USB_INT32S  rc;
+
+
+    Fill_MSCommand(0, 0, 0, MS_DATA_DIR_IN, SCSI_CMD_READ_CAPACITY, 10);
+    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
+    if (rc == OK) {
+        rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, 8);
+        if (rc == OK) {
+            if (numBlks)
+                *numBlks = ReadBE32U(&TDBuffer[0]);
+            if (blkSize)
+                *blkSize = ReadBE32U(&TDBuffer[4]);
+            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
+            if (rc == OK) {
+                if (TDBuffer[12] != 0) {
+                    rc = ERR_MS_CMD_FAILED;
+                }
+            }
+        }
+    }
+    return (rc);
+}
+
+
+
+USB_INT32S MS_Inquire (USB_INT08U *response)
+{
+    USB_INT32S rc;
+    USB_INT32U i;
+
+    Fill_MSCommand(0, 0, 0, MS_DATA_DIR_IN, SCSI_CMD_INQUIRY, 6);
+    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
+    if (rc == OK) {
+        rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, INQUIRY_LENGTH);
+        if (rc == OK) {
+            if (response) {
+                for ( i = 0; i < INQUIRY_LENGTH; i++ )
+                    *response++ = *TDBuffer++;
+#if 0
+                MemCpy (response, TDBuffer, INQUIRY_LENGTH);
+                StrNullTrailingSpace (response->vendorID, SCSI_INQUIRY_VENDORCHARS);
+                StrNullTrailingSpace (response->productID, SCSI_INQUIRY_PRODUCTCHARS);
+                StrNullTrailingSpace (response->productRev, SCSI_INQUIRY_REVCHARS);
+#endif
+            }
+            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
+            if (rc == OK) {
+                if (TDBuffer[12] != 0) {    // bCSWStatus byte
+                    rc = ERR_MS_CMD_FAILED;
+                }
+            }
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                         RECEIVE THE BULK DATA
+*
+* Description: This function is used to receive the bulk data
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+    
+USB_INT32S  MS_BulkRecv (          USB_INT32U   block_number,
+                                   USB_INT16U   num_blocks,
+                         volatile  USB_INT08U  *user_buffer)
+{
+    USB_INT32S  rc;
+    int i;
+    volatile USB_INT08U *c = user_buffer;
+    for (i=0;i<MS_BlkSize*num_blocks;i++)
+        *c++ = 0;
+
+
+    Fill_MSCommand(block_number, MS_BlkSize, num_blocks, MS_DATA_DIR_IN, SCSI_CMD_READ_10, 10);
+
+    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
+    if (rc == OK) {
+        rc = Host_ProcessTD(EDBulkIn, TD_IN, user_buffer, MS_BlkSize * num_blocks);
+        if (rc == OK) {
+            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
+            if (rc == OK) {
+                if (TDBuffer[12] != 0) {
+                    rc = ERR_MS_CMD_FAILED;
+                }
+            }
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                         SEND BULK DATA
+*
+* Description: This function is used to send the bulk data
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+USB_INT32S  MS_BulkSend (          USB_INT32U   block_number,
+                                   USB_INT16U   num_blocks,
+                         volatile  USB_INT08U  *user_buffer)
+{
+    USB_INT32S  rc;
+
+
+    Fill_MSCommand(block_number, MS_BlkSize, num_blocks, MS_DATA_DIR_OUT, SCSI_CMD_WRITE_10, 10);
+
+    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
+    if (rc == OK) {
+        rc = Host_ProcessTD(EDBulkOut, TD_OUT, user_buffer, MS_BlkSize * num_blocks);
+        if (rc == OK) {
+            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
+            if (rc == OK) {
+                if (TDBuffer[12] != 0) {
+                    rc = ERR_MS_CMD_FAILED;
+                }
+            }
+        }
+    }
+    return (rc);
+}
+
+/*
+**************************************************************************************************************
+*                                         FILL MASS STORAGE COMMAND
+*
+* Description: This function is used to fill the mass storage command
+*
+* Arguments  : None
+*
+* Returns    : OK                      if Success
+*              ERR_INVALID_BOOTSIG    if Failed
+*
+**************************************************************************************************************
+*/
+
+void  Fill_MSCommand (USB_INT32U   block_number,
+                      USB_INT32U   block_size,
+                      USB_INT16U   num_blocks,
+                      MS_DATA_DIR  direction,
+                      USB_INT08U   scsi_cmd,
+                      USB_INT08U   scsi_cmd_len)
+{
+            USB_INT32U  data_len;
+    static  USB_INT32U  tag_cnt = 0;
+            USB_INT32U  cnt;
+
+
+    for (cnt = 0; cnt < CBW_SIZE; cnt++) {
+         TDBuffer[cnt] = 0;
+    }
+    switch(scsi_cmd) {
+
+        case SCSI_CMD_TEST_UNIT_READY:
+             data_len = 0;
+             break;
+        case SCSI_CMD_READ_CAPACITY:
+             data_len = 8;
+             break;
+        case SCSI_CMD_REQUEST_SENSE:
+             data_len = 18;
+             break;
+        case SCSI_CMD_INQUIRY:
+             data_len = 36;
+             break;
+        default:
+             data_len = block_size * num_blocks;
+             break;
+    }
+    WriteLE32U(TDBuffer, CBW_SIGNATURE);
+    WriteLE32U(&TDBuffer[4], tag_cnt);
+    WriteLE32U(&TDBuffer[8], data_len);
+    TDBuffer[12]     = (direction == MS_DATA_DIR_NONE) ? 0 : direction;
+    TDBuffer[14]     = scsi_cmd_len;                                   /* Length of the CBW                 */
+    TDBuffer[15]     = scsi_cmd;
+    if ((scsi_cmd     == SCSI_CMD_REQUEST_SENSE)
+     || (scsi_cmd     == SCSI_CMD_INQUIRY)) {
+        TDBuffer[19] = (USB_INT08U)data_len;
+    } else {
+        WriteBE32U(&TDBuffer[17], block_number);
+    }
+    WriteBE16U(&TDBuffer[22], num_blocks);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/MSCFileSystem/USBHostLite/usbhost_ms.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,101 @@
+/*
+**************************************************************************************************************
+*                                                 NXP USB Host Stack
+*
+*                                     (c) Copyright 2008, NXP SemiConductors
+*                                     (c) Copyright 2008, OnChip  Technologies LLC
+*                                                 All Rights Reserved
+*
+*                                                  www.nxp.com
+*                                               www.onchiptech.com
+*
+* File           : usbhost_ms.h
+* Programmer(s)  : Ravikanth.P
+* Version        :
+*
+**************************************************************************************************************
+*/
+
+#ifndef  USBHOST_MS_H
+#define  USBHOST_MS_H
+
+/*
+**************************************************************************************************************
+*                                       INCLUDE HEADER FILES
+**************************************************************************************************************
+*/
+
+#include  "usbhost_inc.h"
+
+/*
+**************************************************************************************************************
+*                               MASS STORAGE SPECIFIC DEFINITIONS
+**************************************************************************************************************
+*/
+
+#define    MS_GET_MAX_LUN_REQ            0xFE
+#define    MASS_STORAGE_CLASS            0x08
+#define    MASS_STORAGE_SUBCLASS_SCSI    0x06
+#define    MASS_STORAGE_PROTOCOL_BO      0x50
+
+#define    INQUIRY_LENGTH                36
+/*
+**************************************************************************************************************
+*                                  SCSI SPECIFIC DEFINITIONS
+**************************************************************************************************************
+*/
+
+#define  CBW_SIGNATURE               0x43425355
+#define  CSW_SIGNATURE               0x53425355
+#define  CBW_SIZE                      31
+#define  CSW_SIZE                      13
+#define  CSW_CMD_PASSED              0x00
+#define  SCSI_CMD_REQUEST_SENSE      0x03
+#define  SCSI_CMD_TEST_UNIT_READY    0x00
+#define  SCSI_CMD_INQUIRY            0x12
+#define  SCSI_CMD_READ_10            0x28
+#define  SCSI_CMD_READ_CAPACITY      0x25
+#define  SCSI_CMD_WRITE_10           0x2A
+
+/*
+**************************************************************************************************************
+*                                       TYPE DEFINITIONS
+**************************************************************************************************************
+*/
+
+typedef enum  ms_data_dir {
+
+    MS_DATA_DIR_IN     = 0x80,
+    MS_DATA_DIR_OUT    = 0x00,
+    MS_DATA_DIR_NONE   = 0x01
+
+} MS_DATA_DIR;
+
+/*
+**************************************************************************************************************
+*                                     FUNCTION PROTOTYPES
+**************************************************************************************************************
+*/
+
+USB_INT32S  MS_BulkRecv          (          USB_INT32U    block_number,
+                                            USB_INT16U    num_blocks,
+                                  volatile  USB_INT08U   *user_buffer);
+
+USB_INT32S  MS_BulkSend          (          USB_INT32U    block_number,
+                                            USB_INT16U    num_blocks,
+                                  volatile  USB_INT08U   *user_buffer);
+USB_INT32S  MS_ParseConfiguration(void);
+USB_INT32S  MS_TestUnitReady     (void);
+USB_INT32S  MS_ReadCapacity (USB_INT32U *numBlks, USB_INT32U *blkSize);
+USB_INT32S  MS_GetMaxLUN         (void);
+USB_INT32S  MS_GetSenseInfo      (void);
+USB_INT32S  MS_Init (USB_INT32U *blkSize, USB_INT32U *numBlks, USB_INT08U *inquiryResult);
+USB_INT32S  MS_Inquire (USB_INT08U *response);
+
+void        Fill_MSCommand       (          USB_INT32U    block_number,
+                                            USB_INT32U    block_size,
+                                            USB_INT16U    num_blocks,
+                                            MS_DATA_DIR   direction,
+                                            USB_INT08U    scsi_cmd,
+                                            USB_INT08U    scsi_cmd_len);
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/NTPClient/NTPClient.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,163 @@
+/* NTPClient.cpp */
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+//Debug is disabled by default
+#if 0
+//Enable debug
+#define __DEBUG__
+#include <cstdio>
+#define DBG(x, ...) std::printf("[NTPClient : DBG]"x"\r\n", ##__VA_ARGS__); 
+#define WARN(x, ...) std::printf("[NTPClient : WARN]"x"\r\n", ##__VA_ARGS__); 
+#define ERR(x, ...) std::printf("[NTPClient : ERR]"x"\r\n", ##__VA_ARGS__); 
+
+#else
+//Disable debug
+#define DBG(x, ...) 
+#define WARN(x, ...)
+#define ERR(x, ...) 
+
+#endif
+
+#include "NTPClient.h"
+
+#include "UDPSocket.h"
+
+#include "mbed.h" //time() and set_time()
+
+#define NTP_PORT 123
+#define NTP_CLIENT_PORT 0 //Random port
+#define NTP_TIMESTAMP_DELTA 2208988800ull //Diff btw a UNIX timestamp (Starting Jan, 1st 1970) and a NTP timestamp (Starting Jan, 1st 1900)
+
+NTPClient::NTPClient() : m_sock()
+{
+
+
+}
+
+NTPResult NTPClient::setTime(const char* host, uint16_t port, uint32_t timeout)
+{
+#ifdef __DEBUG__
+  time_t ctTime;
+  ctTime = time(NULL);
+  DBG("Time is set to (UTC): %s", ctime(&ctTime));
+#endif
+
+  //Create & bind socket
+  DBG("Binding socket");
+  m_sock.bind(0); //Bind to a random port
+  
+  m_sock.set_blocking(false, timeout); //Set not blocking
+
+  struct NTPPacket pkt;
+
+  //Now ping the server and wait for response
+  DBG("Ping");
+  //Prepare NTP Packet:
+  pkt.li = 0; //Leap Indicator : No warning
+  pkt.vn = 4; //Version Number : 4
+  pkt.mode = 3; //Client mode
+  pkt.stratum = 0; //Not relevant here
+  pkt.poll = 0; //Not significant as well
+  pkt.precision = 0; //Neither this one is
+
+  pkt.rootDelay = 0; //Or this one
+  pkt.rootDispersion = 0; //Or that one
+  pkt.refId = 0; //...
+
+  pkt.refTm_s = 0;
+  pkt.origTm_s = 0;
+  pkt.rxTm_s = 0;
+  pkt.txTm_s = htonl( NTP_TIMESTAMP_DELTA + time(NULL) ); //WARN: We are in LE format, network byte order is BE
+
+  pkt.refTm_f = pkt.origTm_f = pkt.rxTm_f = pkt.txTm_f = 0;
+
+  Endpoint outEndpoint;
+  
+  if( outEndpoint.set_address(host, port) < 0)
+  {
+    m_sock.close();
+    return NTP_DNS;
+  }
+  
+  //Set timeout, non-blocking and wait using select
+  int ret = m_sock.sendTo( outEndpoint, (char*)&pkt, sizeof(NTPPacket) );
+  if (ret < 0 )
+  {
+    ERR("Could not send packet");
+    m_sock.close();
+    return NTP_CONN;
+  }
+
+  //Read response
+  Endpoint inEndpoint;
+
+  DBG("Pong");
+  do
+  {
+    ret = m_sock.receiveFrom( inEndpoint, (char*)&pkt, sizeof(NTPPacket) ); //FIXME need a DNS Resolver to actually compare the incoming address with the DNS name
+    if(ret < 0)
+    {
+      ERR("Could not receive packet");
+      m_sock.close();
+      return NTP_CONN;
+    }
+  } while( strcmp(outEndpoint.get_address(), inEndpoint.get_address()) != 0 );
+
+  if(ret < sizeof(NTPPacket)) //TODO: Accept chunks
+  {
+    ERR("Receive packet size does not match");
+    m_sock.close();
+    return NTP_PRTCL;
+  }
+
+  if( pkt.stratum == 0)  //Kiss of death message : Not good !
+  {
+    ERR("Kissed to death!");
+    m_sock.close();
+    return NTP_PRTCL;
+  }
+
+  //Correct Endianness
+  pkt.refTm_s = ntohl( pkt.refTm_s );
+  pkt.refTm_f = ntohl( pkt.refTm_f );
+  pkt.origTm_s = ntohl( pkt.origTm_s );
+  pkt.origTm_f = ntohl( pkt.origTm_f );
+  pkt.rxTm_s = ntohl( pkt.rxTm_s );
+  pkt.rxTm_f = ntohl( pkt.rxTm_f );
+  pkt.txTm_s = ntohl( pkt.txTm_s );
+  pkt.txTm_f = ntohl( pkt.txTm_f );
+
+  //Compute offset, see RFC 4330 p.13
+  uint32_t destTm_s = (NTP_TIMESTAMP_DELTA + time(NULL));
+  int64_t offset = ( (int64_t)( pkt.rxTm_s - pkt.origTm_s ) + (int64_t) ( pkt.txTm_s - destTm_s ) ) / 2; //Avoid overflow
+  DBG("Sent @%ul", pkt.txTm_s);
+  DBG("Offset: %lld", offset);
+  //Set time accordingly
+  set_time( time(NULL) + offset );
+
+#ifdef __DEBUG__
+  ctTime = time(NULL);
+  DBG("Time is now (UTC): %s", ctime(&ctTime));
+#endif
+
+  m_sock.close();
+
+  return NTP_OK;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/NTPClient/NTPClient.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,102 @@
+/* NTPClient.h */
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/** \file
+NTP Client header file
+*/
+
+#ifndef NTPCLIENT_H_
+#define NTPCLIENT_H_
+
+#include <cstdint>
+
+using std::uint8_t;
+using std::uint16_t;
+using std::uint32_t;
+
+#include "UDPSocket.h"
+
+#define NTP_DEFAULT_PORT 123
+#define NTP_DEFAULT_TIMEOUT 4000
+
+///NTP client results
+enum NTPResult
+{
+  NTP_DNS, ///<Could not resolve name
+  NTP_PRTCL, ///<Protocol error
+  NTP_TIMEOUT, ///<Connection timeout
+  NTP_CONN, ///<Connection error
+  NTP_OK = 0, ///<Success
+};
+
+/** NTP Client to update the mbed's RTC using a remote time server
+*
+*/
+class NTPClient
+{
+public:
+  /**
+  Instantiate the NTP client
+  */
+  NTPClient();
+
+  /**Get current time (blocking)
+  Update the time using the server host
+  Blocks until completion
+  @param host NTP server IPv4 address or hostname (will be resolved via DNS)
+  @param port port to use; defaults to 123
+  @param timeout waiting timeout in ms (osWaitForever for blocking function, not recommended)
+  @return 0 on success, NTP error code (<0) on failure
+  */
+  NTPResult setTime(const char* host, uint16_t port = NTP_DEFAULT_PORT, uint32_t timeout = NTP_DEFAULT_TIMEOUT); //Blocking
+
+private:
+  struct NTPPacket //See RFC 4330 for Simple NTP
+  {
+    //WARN: We are in LE! Network is BE!
+    //LSb first
+    unsigned mode : 3;
+    unsigned vn : 3;
+    unsigned li : 2;
+
+    uint8_t stratum;
+    uint8_t poll;
+    uint8_t precision;
+    //32 bits header
+
+    uint32_t rootDelay;
+    uint32_t rootDispersion;
+    uint32_t refId;
+
+    uint32_t refTm_s;
+    uint32_t refTm_f;
+    uint32_t origTm_s;
+    uint32_t origTm_f;
+    uint32_t rxTm_s;
+    uint32_t rxTm_f;
+    uint32_t txTm_s;
+    uint32_t txTm_f;
+  } __attribute__ ((packed));
+  
+  UDPSocket m_sock;
+
+};
+
+
+#endif /* NTPCLIENT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Helper/def.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ 
+#ifndef DEF_H
+#define DEF_H
+
+#include "cmsis.h"
+#define htons(x)      __REV16(x)
+#define ntohs(x)      __REV16(x)
+#define htonl(x)      __REV(x)
+#define ntohl(x)      __REV(x)
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/Endpoint.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,50 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include "Socket/Socket.h"
+#include "Socket/Endpoint.h"
+#include <cstring>
+
+using std::memset;
+
+Endpoint::Endpoint()  {
+    wifly = Wifly::getInstance();
+    if (wifly == NULL)
+        error("Endpoint constructor error: no wifly instance available!\r\n");
+    reset_address();
+}
+Endpoint::~Endpoint() {}
+
+void Endpoint::reset_address(void) {
+    _ipAddress[0] = '\0';
+    _port = 0;
+}
+
+int Endpoint::set_address(const char* host, const int port) {
+    //Resolve DNS address or populate hard-coded IP address
+    wifly->gethostbyname(host, _ipAddress);
+    _port = port;
+    return 0;
+}
+
+char* Endpoint::get_address() {
+    return _ipAddress;
+}
+
+int   Endpoint::get_port() {
+    return _port;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/Endpoint.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,65 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef ENDPOINT_H
+#define ENDPOINT_H
+
+#include "Wifly.h"
+
+class UDPSocket;
+
+/**
+IP Endpoint (address, port)
+*/
+class Endpoint {
+    friend class UDPSocket;
+
+public:
+    /** IP Endpoint (address, port)
+     */
+    Endpoint(void);
+    
+    ~Endpoint(void);
+    
+    /** Reset the address of this endpoint
+     */
+    void reset_address(void);
+    
+    /** Set the address of this endpoint
+    \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
+    \param port The endpoint port
+    \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
+     */
+    int  set_address(const char* host, const int port);
+    
+    /** Get the IP address of this endpoint
+    \return The IP address of this endpoint.
+     */
+    char* get_address(void);
+    
+    /** Get the port of this endpoint
+    \return The port of this endpoint
+     */
+    int get_port(void);
+
+protected:
+    char _ipAddress[16];
+    int _port;
+    Wifly * wifly;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/Socket.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,39 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ 
+#include "Socket.h"
+#include <cstring>
+
+Socket::Socket() : _blocking(true), _timeout(1500) {
+    wifi = Wifly::getInstance();
+    if (wifi == NULL)
+        error("Socket constructor error: no wifly instance available!\r\n");
+}
+
+void Socket::set_blocking(bool blocking, unsigned int timeout) {
+    _blocking = blocking;
+    _timeout = timeout;
+}
+
+int Socket::close() {
+    return (wifi->close()) ? 0 : -1;
+}
+
+Socket::~Socket() {
+    close(); //Don't want to leak
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/Socket.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,51 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef SOCKET_H_
+#define SOCKET_H_
+
+#include "Wifly.h"
+
+/** Socket file descriptor and select wrapper
+  */
+class Socket {
+public:
+    /** Socket
+     */
+    Socket();
+    
+    /** Set blocking or non-blocking mode of the socket and a timeout on
+        blocking socket operations
+    \param blocking  true for blocking mode, false for non-blocking mode.
+    \param timeout   timeout in ms [Default: (1500)ms].
+    */
+    void set_blocking(bool blocking, unsigned int timeout=1500);
+    
+    /** Close the socket file descriptor
+     */
+    int close();
+    
+    ~Socket();
+    
+protected:
+    bool _blocking;
+    int _timeout;
+    Wifly * wifi;
+};
+
+
+#endif /* SOCKET_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/TCPSocketConnection.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,125 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "TCPSocketConnection.h"
+#include <algorithm>
+
+TCPSocketConnection::TCPSocketConnection() {}
+
+int TCPSocketConnection::connect(const char* host, const int port)
+{  
+    if (!wifi->connect(host, port))
+        return -1;
+    wifi->flush();
+    return 0;
+}
+
+bool TCPSocketConnection::is_connected(void)
+{
+    return wifi->is_connected();
+}
+
+int TCPSocketConnection::send(char* data, int length)
+{
+    Timer tmr;
+
+    if (!_blocking) {
+        tmr.start();
+        while (tmr.read_ms() < _timeout) {
+            if (wifi->writeable())
+                break;
+        }
+        if (tmr.read_ms() >= _timeout) {
+            return -1;
+        }
+    }
+    return wifi->send(data, length);
+}
+
+// -1 if unsuccessful, else number of bytes written
+int TCPSocketConnection::send_all(char* data, int length)
+{
+    Timer tmr;
+    int idx = 0;
+    tmr.start();
+
+    while ((tmr.read_ms() < _timeout) || _blocking) {
+
+        idx += wifi->send(data, length);
+
+        if (idx == length)
+            return idx;
+    }
+    return (idx == 0) ? -1 : idx;
+}
+
+// -1 if unsuccessful, else number of bytes received
+int TCPSocketConnection::receive(char* data, int length)
+{
+    Timer tmr;
+    int time = -1;
+    
+    
+    if (!_blocking) {
+        tmr.start();
+        while (time < _timeout + 20) {
+            if (wifi->readable()) {
+                break;
+            }
+            time = tmr.read_ms();
+        }
+        if (time >= _timeout + 20) {
+            return -1;
+        }
+    }
+
+
+    while(!wifi->readable());
+    int nb_available = wifi->readable();
+    for (int i = 0; i < min(nb_available, length); i++) {
+        data[i] = wifi->getc();
+    }
+
+    return min(nb_available, length);
+}
+
+
+// -1 if unsuccessful, else number of bytes received
+int TCPSocketConnection::receive_all(char* data, int length)
+{
+    Timer tmr;
+    int idx = 0;
+    int time = -1;
+
+    tmr.start();
+    
+    while (time < _timeout || _blocking) {
+
+        int nb_available = wifi->readable();
+        for (int i = 0; i < min(nb_available, length); i++) {
+            data[idx++] = wifi->getc();
+        }
+
+        if (idx == length)
+            break;
+
+        time = tmr.read_ms();
+    }
+
+    return (idx == 0) ? -1 : idx;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/TCPSocketConnection.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,76 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TCPSOCKET_H
+#define TCPSOCKET_H
+
+#include "Socket.h"
+#include "Endpoint.h"
+
+/**
+TCP socket connection
+*/
+class TCPSocketConnection: public Socket, public Endpoint {
+    
+public:
+    /** TCP socket connection
+    */
+    TCPSocketConnection();
+    
+    /** Connects this TCP socket to the server
+    \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
+    \param port The host's port to connect to.
+    \return 0 on success, -1 on failure.
+    */
+    int connect(const char* host, const int port);
+    
+    /** Check if the socket is connected
+    \return true if connected, false otherwise.
+    */
+    bool is_connected(void);
+    
+    /** Send data to the remote host.
+    \param data The buffer to send to the host.
+    \param length The length of the buffer to send.
+    \return the number of written bytes on success (>=0) or -1 on failure
+     */
+    int send(char* data, int length);
+    
+    /** Send all the data to the remote host.
+    \param data The buffer to send to the host.
+    \param length The length of the buffer to send.
+    \return the number of written bytes on success (>=0) or -1 on failure
+    */
+    int send_all(char* data, int length);
+    
+    /** Receive data from the remote host.
+    \param data The buffer in which to store the data received from the host.
+    \param length The maximum length of the buffer.
+    \return the number of received bytes on success (>=0) or -1 on failure
+     */
+    int receive(char* data, int length);
+    
+    /** Receive all the data from the remote host.
+    \param data The buffer in which to store the data received from the host.
+    \param length The maximum length of the buffer.
+    \return the number of received bytes on success (>=0) or -1 on failure
+    */
+    int receive_all(char* data, int length);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/TCPSocketServer.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,90 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "TCPSocketServer.h"
+#include <string>
+
+TCPSocketServer::TCPSocketServer() {}
+
+// Server initialization
+int TCPSocketServer::bind(int port) {
+    char cmd[20];
+    
+    // set TCP protocol
+    wifi->setProtocol(TCP);
+    
+    // set local port
+    sprintf(cmd, "set i l %d\r", port);
+    if (!wifi->sendCommand(cmd, "AOK"))
+        return -1;
+    
+    // save
+    if (!wifi->sendCommand("save\r", "Stor"))
+        return -1;
+    
+    // reboot
+    wifi->reboot();
+    
+    // connect the network
+    if (wifi->isDHCP()) {
+        if (!wifi->sendCommand("join\r", "DHCP=ON", NULL, 10000))
+            return -1;
+    } else {
+        if (!wifi->sendCommand("join\r", "Associated", NULL, 10000))
+            return -1;
+    }
+        
+    // exit
+    wifi->exit();
+    
+    wait(0.2);
+    wifi->flush();
+    return 0;
+}
+
+int TCPSocketServer::listen(int backlog) {
+    if (backlog != 1)
+        return -1;
+    return 0;
+}
+
+
+int TCPSocketServer::accept(TCPSocketConnection& connection) {
+    int nb_available = 0, pos = 0;
+    char c;
+    string str;
+    bool o_find = false;
+    while (1) {
+        while(!wifi->readable());
+        nb_available = wifi->readable();
+        for (int i = 0; i < nb_available; i++) {
+            c = wifi->getc();
+            if (c == '*') {
+                o_find = true;
+            }
+            if (o_find && c != '\r' && c != '\n') {
+                str += c;
+                pos = str.find("*OPEN*");
+                if (pos != string::npos) {
+                    wifi->flush();
+                    return 0;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/TCPSocketServer.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,52 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef TCPSOCKETSERVER_H
+#define TCPSOCKETSERVER_H
+
+#include "Socket/Socket.h"
+#include "TCPSocketConnection.h"
+
+/** TCP Server.
+  */
+class TCPSocketServer : public Socket {
+  public:
+    /** Instantiate a TCP Server.
+    */
+    TCPSocketServer();
+    
+    /** Bind a socket to a specific port.
+    \param port The port to listen for incoming connections on.
+    \return 0 on success, -1 on failure.
+    */
+    int bind(int port);
+    
+    /** Start listening for incoming connections.
+    \param backlog number of pending connections that can be queued up at any
+                   one time [Default: 1].
+    \return 0 on success, -1 on failure.
+    */
+    int listen(int backlog=1);
+    
+    /** Accept a new connection.
+    \param connection A TCPSocketConnection instance that will handle the incoming connection.
+    \return 0 on success, -1 on failure.
+    */
+    int accept(TCPSocketConnection& connection);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/UDPSocket.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,185 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "UDPSocket.h"
+
+#include <string>
+#include <algorithm>
+
+UDPSocket::UDPSocket()
+{
+    endpoint_configured = false;
+    endpoint_read = false;
+}
+
+int UDPSocket::init(void)
+{
+    wifi->setProtocol(UDP);
+    wifi->exit();
+    return 0;
+}
+
+// Server initialization
+int UDPSocket::bind(int port)
+{
+    char cmd[17];
+    
+    // set local port
+    sprintf(cmd, "set i l %d\r", port);
+    if (!wifi->sendCommand(cmd, "AOK"))
+        return -1;
+        
+    // save
+    if (!wifi->sendCommand("save\r", "Stor"))
+        return -1;
+    
+    // reboot
+    wifi->reboot();
+    
+    // set udp protocol
+    wifi->setProtocol(UDP);
+    
+    // connect the network
+    if (wifi->isDHCP()) {
+        if (!wifi->sendCommand("join\r", "DHCP=ON", NULL, 10000))
+            return -1;
+    } else {
+        if (!wifi->sendCommand("join\r", "Associated", NULL, 10000))
+            return -1;
+    }
+        
+    // exit
+    wifi->exit();
+    wifi->flush();
+    return 0;
+}
+
+// -1 if unsuccessful, else number of bytes written
+int UDPSocket::sendTo(Endpoint &remote, char *packet, int length)
+{
+    Timer tmr;
+    int idx = 0;
+
+    confEndpoint(remote);
+
+    tmr.start();
+
+    while ((tmr.read_ms() < _timeout) || _blocking) {
+
+        idx += wifi->send(packet, length);
+
+        if (idx == length)
+            return idx;
+    }
+    return (idx == 0) ? -1 : idx;
+}
+
+// -1 if unsuccessful, else number of bytes received
+int UDPSocket::receiveFrom(Endpoint &remote, char *buffer, int length)
+{
+    Timer tmr;
+    int idx = 0;
+    int nb_available = 0;
+    int time = -1;
+
+    if (_blocking) {
+        while (1) {
+            nb_available = wifi->readable();
+            if (nb_available != 0) {
+                break;
+            }
+        }
+    }
+
+    tmr.start();
+
+    while (time < _timeout) {
+
+        nb_available = wifi->readable();
+        for (int i = 0; i < min(nb_available, length); i++) {
+            buffer[idx] = wifi->getc();
+            idx++;
+        }
+
+        if (idx == length) {
+            break;
+        }
+        
+        time = tmr.read_ms();
+    }
+
+    readEndpoint(remote);
+    return (idx == 0) ? -1 : idx;
+}
+
+bool UDPSocket::confEndpoint(Endpoint & ep)
+{
+    char * host;
+    char cmd[30];
+    if (!endpoint_configured) {
+        host = ep.get_address();
+        if (host[0] != '\0') {
+            // set host
+            sprintf(cmd, "set i h %s\r", host);
+            if (!wifi->sendCommand(cmd, "AOK"))
+                return false;
+                
+            // set remote port
+            sprintf(cmd, "set i r %d\r", ep.get_port());
+            if (!wifi->sendCommand(cmd, "AOK"))
+                return false;
+                
+            wifi->exit();
+            endpoint_configured = true;
+            return true;
+        }
+    }
+    return true;
+}
+
+bool UDPSocket::readEndpoint(Endpoint & ep)
+{
+    char recv[256];
+    int begin = 0;
+    int end = 0;
+    string str;
+    string addr;
+    int port;
+    if (!endpoint_read) {
+        if (!wifi->sendCommand("get ip\r", NULL, recv))
+            return false;
+        wifi->exit();
+        str = recv;
+        begin = str.find("HOST=");
+        end = str.find("PROTO=");
+        if (begin != string::npos && end != string::npos) {
+            str = str.substr(begin + 5, end - begin - 5);
+            int pos = str.find(":");
+            if (pos != string::npos) {
+                addr = str.substr(0, pos);
+                port = atoi(str.substr(pos + 1).c_str());
+                ep.set_address(addr.c_str(), port);
+                endpoint_read = true;
+                wifi->flush();
+                return true;
+            }
+        }
+        wifi->flush();
+    }
+    return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Socket/UDPSocket.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef UDPSOCKET_H
+#define UDPSOCKET_H
+
+#include "Endpoint.h"
+#include "Socket.h"
+
+#include <cstdint>
+
+/**
+UDP Socket
+*/
+class UDPSocket: public Socket {
+
+public:
+    /** Instantiate an UDP Socket.
+    */
+    UDPSocket();
+    
+    /** Init the UDP Client Socket without binding it to any specific port
+    \return 0 on success, -1 on failure.
+    */
+    int init(void);
+    
+    /** Bind a UDP Server Socket to a specific port
+    \param port The port to listen for incoming connections on
+    \return 0 on success, -1 on failure.
+    */
+    int bind(int port = -1);
+    
+    /** Send a packet to a remote endpoint
+    \param remote   The remote endpoint
+    \param packet   The packet to be sent
+    \param length   The length of the packet to be sent
+    \return the number of written bytes on success (>=0) or -1 on failure
+    */
+    int sendTo(Endpoint &remote, char *packet, int length);
+    
+    /** Receive a packet from a remote endpoint
+    \param remote   The remote endpoint
+    \param buffer   The buffer for storing the incoming packet data. If a packet
+           is too long to fit in the supplied buffer, excess bytes are discarded
+    \param length   The length of the buffer
+    \return the number of received bytes on success (>=0) or -1 on failure
+    */
+    int receiveFrom(Endpoint &remote, char *buffer, int length);
+    
+private:
+    bool confEndpoint(Endpoint & ep);
+    bool readEndpoint(Endpoint & ep);
+    bool endpoint_configured;
+    bool endpoint_read;
+    
+};
+
+#include "def.h"
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Wifly/CBuffer.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CIRCBUFFER_H_
+#define CIRCBUFFER_H_
+
+template <class T>
+class CircBuffer {
+public:
+    CircBuffer(int length) {
+        write = 0;
+        read = 0;
+        size = length + 1;
+        buf = (T *)malloc(size * sizeof(T));
+    };
+
+    bool isFull() {
+        return (((write + 1) % size) == read);
+    };
+
+    bool isEmpty() {
+        return (read == write);
+    };
+
+    void queue(T k) {
+        if (isFull()) {
+            read++;
+            read %= size;
+        }
+        buf[write++] = k;
+        write %= size;
+    }
+    
+    void flush() {
+        read = 0;
+        write = 0;
+    }
+    
+
+    uint32_t available() {
+        return (write >= read) ? write - read : size - read + write;
+    };
+
+    bool dequeue(T * c) {
+        bool empty = isEmpty();
+        if (!empty) {
+            *c = buf[read++];
+            read %= size;
+        }
+        return(!empty);
+    };
+
+private:
+    volatile uint32_t write;
+    volatile uint32_t read;
+    uint32_t size;
+    T * buf;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Wifly/Wifly.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,546 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "mbed.h"
+#include "Wifly.h"
+#include <string>
+#include <algorithm>
+
+//Debug is disabled by default
+#if (0 && !defined(TARGET_LPC11U24))
+#define DBG(x, ...) std::printf("[Wifly : DBG]"x"\r\n", ##__VA_ARGS__);
+#define WARN(x, ...) std::printf("[Wifly : WARN]"x"\r\n", ##__VA_ARGS__);
+#define ERR(x, ...) std::printf("[Wifly : ERR]"x"\r\n", ##__VA_ARGS__);
+#else
+#define DBG(x, ...)
+#define WARN(x, ...)
+#define ERR(x, ...)
+#endif
+
+#if !defined(TARGET_LPC11U24)
+#define INFO(x, ...) printf("[Wifly : INFO]"x"\r\n", ##__VA_ARGS__);
+#else
+#define INFO(x, ...)
+#endif
+
+#define MAX_TRY_JOIN 3
+
+Wifly * Wifly::inst;
+
+Wifly::Wifly(   PinName tx, PinName rx, PinName _reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec):
+    wifi(tx, rx), reset_pin(_reset), tcp_status(tcp_status), buf_wifly(256)
+{
+    memset(&state, 0, sizeof(state));
+    state.sec = sec;
+
+    // change all ' ' in '$' in the ssid and the passphrase
+    strcpy(this->ssid, ssid);
+    for (int i = 0; i < strlen(ssid); i++) {
+        if (this->ssid[i] == ' ')
+            this->ssid[i] = '$';
+    }
+    strcpy(this->phrase, phrase);
+    for (int i = 0; i < strlen(phrase); i++) {
+        if (this->phrase[i] == ' ')
+            this->phrase[i] = '$';
+    }
+
+    inst = this;
+    attach_rx(false);
+    state.cmd_mode = false;
+}
+
+bool Wifly::join()
+{
+    char cmd[20];
+
+    for (int i= 0; i < MAX_TRY_JOIN; i++) {
+
+        // no auto join
+        if (!sendCommand("set w j 0\r", "AOK"))
+            continue;
+
+        //no echo
+        if (!sendCommand("set u m 1\r", "AOK"))
+            continue;
+
+        // set time
+        if (!sendCommand("set c t 30\r", "AOK"))
+            continue;
+
+        // set size
+        if (!sendCommand("set c s 1024\r", "AOK"))
+            continue;
+
+        // red led on when tcp connection active
+        if (!sendCommand("set s i 0x40\r", "AOK"))
+            continue;
+
+        // no string sent to the tcp client
+        if (!sendCommand("set c r 0\r", "AOK"))
+            continue;
+
+        // tcp protocol
+        if (!sendCommand("set i p 2\r", "AOK"))
+            continue;
+
+        // tcp retry
+        if (!sendCommand("set i f 0x7\r", "AOK"))
+            continue;
+            
+        // set dns server
+        if (!sendCommand("set d n rn.microchip.com\r", "AOK"))
+            continue;
+
+        //dhcp
+        sprintf(cmd, "set i d %d\r", (state.dhcp) ? 1 : 0);
+        if (!sendCommand(cmd, "AOK"))
+            continue;
+
+        // ssid
+        sprintf(cmd, "set w s %s\r", ssid);
+        if (!sendCommand(cmd, "AOK"))
+            continue;
+
+        //auth
+        sprintf(cmd, "set w a %d\r", state.sec);
+        if (!sendCommand(cmd, "AOK"))
+            continue;
+
+        // if no dhcp, set ip, netmask and gateway
+        if (!state.dhcp) {
+            DBG("not dhcp\r");
+
+            sprintf(cmd, "set i a %s\r\n", ip);
+            if (!sendCommand(cmd, "AOK"))
+                continue;
+
+            sprintf(cmd, "set i n %s\r", netmask);
+            if (!sendCommand(cmd, "AOK"))
+                continue;
+
+            sprintf(cmd, "set i g %s\r", gateway);
+            if (!sendCommand(cmd, "AOK"))
+                continue;
+        }
+
+        //key step
+        if (state.sec != NONE) {
+            if (state.sec == WPA)
+                sprintf(cmd, "set w p %s\r", phrase);
+            else if (state.sec == WEP_128)
+                sprintf(cmd, "set w k %s\r", phrase);
+
+            if (!sendCommand(cmd, "AOK"))
+                continue;
+        }
+
+        //join the network (10s timeout)
+        if (state.dhcp) {
+            if (!sendCommand("join\r", "DHCP=ON", NULL, 10000))
+                continue;
+        } else {
+            if (!sendCommand("join\r", "Associated", NULL, 10000))
+                continue;
+        }
+
+        if (!sendCommand("save\r", "Stor"))
+            continue;
+
+        exit();
+
+        state.associated = true;
+        INFO("\r\nssid: %s\r\nphrase: %s\r\nsecurity: %s\r\n\r\n", this->ssid, this->phrase, getStringSecurity());
+        return true;
+    }
+    return false;
+}
+
+
+bool Wifly::setProtocol(Protocol p)
+{
+    // use udp auto pairing
+    char cmd[20];
+    sprintf(cmd, "set i p %d\r", p);
+    if (!sendCommand(cmd, "AOK"))
+        return false;
+
+    switch(p) {
+        case TCP:
+            // set ip flags: tcp retry enabled
+            if (!sendCommand("set i f 0x07\r", "AOK"))
+                return false;
+            break;
+        case UDP:
+            // set ip flags: udp auto pairing enabled
+            if (!sendCommand("set i h 0.0.0.0\r", "AOK"))
+                return false;
+            if (!sendCommand("set i f 0x40\r", "AOK"))
+                return false;
+            break;
+    }
+    state.proto = p;
+    return true;
+}
+
+char * Wifly::getStringSecurity()
+{
+    switch(state.sec) {
+        case NONE:
+            return "NONE";
+        case WEP_128:
+            return "WEP_128";
+        case WPA:
+            return "WPA";
+    }
+    return "UNKNOWN";
+}
+
+bool Wifly::connect(const char * host, int port)
+{
+    char rcv[20];
+    char cmd[20];
+
+    // try to open
+    sprintf(cmd, "open %s %d\r", host, port);
+    if (sendCommand(cmd, "OPEN", NULL, 10000)) {
+        state.tcp = true;
+        state.cmd_mode = false;
+        return true;
+    }
+
+    // if failed, retry and parse the response
+    if (sendCommand(cmd, NULL, rcv, 5000)) {
+        if (strstr(rcv, "OPEN") == NULL) {
+            if (strstr(rcv, "Connected") != NULL) {
+                wait(0.25);
+                if (!sendCommand("close\r", "CLOS"))
+                    return false;
+                wait(0.25);
+                if (!sendCommand(cmd, "OPEN", NULL, 10000))
+                    return false;
+            } else {
+                return false;
+            }
+        }
+    } else {
+        return false;
+    }
+
+    state.tcp = true;
+    state.cmd_mode = false;
+
+    return true;
+}
+
+
+bool Wifly::gethostbyname(const char * host, char * ip)
+{
+    string h = host;
+    char cmd[30], rcv[100];
+    int l = 0;
+    char * point;
+    int nb_digits = 0;
+
+    // no dns needed
+    int pos = h.find(".");
+    if (pos != string::npos) {
+        string sub = h.substr(0, h.find("."));
+        nb_digits = atoi(sub.c_str());
+    }
+    //printf("substrL %s\r\n", sub.c_str());
+    if (count(h.begin(), h.end(), '.') == 3 && nb_digits > 0) {
+        strcpy(ip, host);
+    }
+    // dns needed
+    else {
+        nb_digits = 0;
+        sprintf(cmd, "lookup %s\r", host);
+        if (!sendCommand(cmd, NULL, rcv))
+            return false;
+
+        // look for the ip address
+        char * begin = strstr(rcv, "=") + 1;
+        for (int i = 0; i < 3; i++) {
+            point = strstr(begin + l, ".");
+            DBG("str: %s", begin + l);
+            l += point - (begin + l) + 1;
+        }
+        DBG("str: %s", begin + l);
+        while(*(begin + l + nb_digits) >= '0' && *(begin + l + nb_digits) <= '9') {
+            DBG("digit: %c", *(begin + l + nb_digits));
+            nb_digits++;
+        }
+        memcpy(ip, begin, l + nb_digits);
+        ip[l+nb_digits] = 0;
+        DBG("ip from dns: %s", ip);
+    }
+    return true;
+}
+
+
+void Wifly::flush()
+{
+    buf_wifly.flush();
+}
+
+bool Wifly::sendCommand(const char * cmd, const char * ack, char * res, int timeout)
+{
+    if (!state.cmd_mode) {
+        cmdMode();
+    }
+    if (send(cmd, strlen(cmd), ack, res, timeout) == -1) {
+        ERR("sendCommand: cannot %s\r\n", cmd);
+        exit();
+        return false;
+    }
+    return true;
+}
+
+bool Wifly::cmdMode()
+{
+    // if already in cmd mode, return
+    if (state.cmd_mode)
+        return true;
+
+    if (send("$$$", 3, "CMD") == -1) {
+        ERR("cannot enter in cmd mode\r\n");
+        exit();
+        return false;
+    }
+    state.cmd_mode = true;
+    return true;
+}
+
+bool Wifly::disconnect()
+{
+    // if already disconnected, return
+    if (!state.associated)
+        return true;
+
+    if (!sendCommand("leave\r", "DeAuth"))
+        return false;
+    exit();
+
+    state.associated = false;
+    return true;
+
+}
+
+bool Wifly::is_connected()
+{
+    return (tcp_status.read() ==  1) ? true : false;
+}
+
+
+void Wifly::reset()
+{
+    reset_pin = 0;
+    wait(0.2);
+    reset_pin = 1;
+    wait(0.2);
+}
+
+bool Wifly::reboot()
+{
+    // if already in cmd mode, return
+    if (!sendCommand("reboot\r"))
+        return false;
+    
+    wait(0.3);
+
+    state.cmd_mode = false;
+    return true;
+}
+
+bool Wifly::close()
+{
+    // if not connected, return
+    if (!state.tcp)
+        return true;
+
+    wait(0.25);
+    if (!sendCommand("close\r", "CLOS"))
+        return false;
+    exit();
+
+    state.tcp = false;
+    return true;
+}
+
+
+int Wifly::putc(char c)
+{
+    while (!wifi.writeable());
+    return wifi.putc(c);
+}
+
+
+bool Wifly::exit()
+{
+    flush();
+    if (!state.cmd_mode)
+        return true;
+    if (!sendCommand("exit\r", "EXIT"))
+        return false;
+    state.cmd_mode = false;
+    flush();
+    return true;
+}
+
+
+int Wifly::readable()
+{
+    return buf_wifly.available();
+}
+
+int Wifly::writeable()
+{
+    return wifi.writeable();
+}
+
+char Wifly::getc()
+{
+    char c;
+    while (!buf_wifly.available());
+    buf_wifly.dequeue(&c);
+    return c;
+}
+
+void Wifly::handler_rx(void)
+{
+    //read characters
+    while (wifi.readable())
+        buf_wifly.queue(wifi.getc());
+}
+
+void Wifly::attach_rx(bool callback)
+{
+    if (!callback)
+        wifi.attach(NULL);
+    else
+        wifi.attach(this, &Wifly::handler_rx);
+}
+
+
+int Wifly::send(const char * str, int len, const char * ACK, char * res, int timeout)
+{
+    char read;
+    size_t found = string::npos;
+    string checking;
+    Timer tmr;
+    int result = 0;
+
+    DBG("will send: %s\r\n",str);
+
+    attach_rx(false);
+
+    //We flush the buffer
+    while (wifi.readable())
+        wifi.getc();
+
+    if (!ACK || !strcmp(ACK, "NO")) {
+        for (int i = 0; i < len; i++)
+            result = (putc(str[i]) == str[i]) ? result + 1 : result;
+    } else {
+        //We flush the buffer
+        while (wifi.readable())
+            wifi.getc();
+
+        tmr.start();
+        for (int i = 0; i < len; i++)
+            result = (putc(str[i]) == str[i]) ? result + 1 : result;
+
+        while (1) {
+            if (tmr.read_ms() > timeout) {
+                //We flush the buffer
+                while (wifi.readable())
+                    wifi.getc();
+
+                DBG("check: %s\r\n", checking.c_str());
+
+                attach_rx(true);
+                return -1;
+            } else if (wifi.readable()) {
+                read = wifi.getc();
+                if ( read != '\r' && read != '\n') {
+                    checking += read;
+                    found = checking.find(ACK);
+                    if (found != string::npos) {
+                        wait(0.01);
+
+                        //We flush the buffer
+                        while (wifi.readable())
+                            wifi.getc();
+
+                        break;
+                    }
+                }
+            }
+        }
+        DBG("check: %s\r\n", checking.c_str());
+
+        attach_rx(true);
+        return result;
+    }
+
+    //the user wants the result from the command (ACK == NULL, res != NULL)
+    if ( res != NULL) {
+        int i = 0;
+        Timer timeout;
+        timeout.start();
+        tmr.reset();
+        while (1) {
+            if (timeout.read() > 2) {
+                if (i == 0) {
+                    res = NULL;
+                    break;
+                }
+                res[i] = '\0';
+                DBG("user str 1: %s\r\n", res);
+
+                break;
+            } else {
+                if (tmr.read_ms() > 300) {
+                    res[i] = '\0';
+                    DBG("user str: %s\r\n", res);
+
+                    break;
+                }
+                if (wifi.readable()) {
+                    tmr.start();
+                    read = wifi.getc();
+
+                    // we drop \r and \n
+                    if ( read != '\r' && read != '\n') {
+                        res[i++] = read;
+                    }
+                }
+            }
+        }
+        DBG("user str: %s\r\n", res);
+    }
+
+    //We flush the buffer
+    while (wifi.readable())
+        wifi.getc();
+
+    attach_rx(true);
+    DBG("result: %d\r\n", result)
+    return result;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/Wifly/Wifly.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,238 @@
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * @section DESCRIPTION
+ *
+ * Wifly RN131-C, wifi module
+ *
+ * Datasheet:
+ *
+ * http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wireless/WiFi/WiFly-RN-UM.pdf
+ */
+
+#ifndef WIFLY_H
+#define WIFLY_H
+
+#include "mbed.h"
+#include "CBuffer.h"
+
+#define DEFAULT_WAIT_RESP_TIMEOUT 500
+
+enum Security {
+    NONE = 0,
+    WEP_128 = 1,
+    WPA = 3
+};
+
+enum Protocol {
+    UDP = (1 << 0),
+    TCP = (1 << 1)
+};
+
+class Wifly
+{
+
+public:
+    /*
+    * Constructor
+    *
+    * @param tx mbed pin to use for tx line of Serial interface
+    * @param rx mbed pin to use for rx line of Serial interface
+    * @param reset reset pin of the wifi module ()
+    * @param tcp_status connection status pin of the wifi module (GPIO 6)
+    * @param ssid ssid of the network
+    * @param phrase WEP or WPA key
+    * @param sec Security type (NONE, WEP_128 or WPA)
+    */
+    Wifly(  PinName tx, PinName rx, PinName reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec);
+
+    /*
+    * Connect the wifi module to the ssid contained in the constructor.
+    *
+    * @return true if connected, false otherwise
+    */
+    bool join();
+
+    /*
+    * Disconnect the wifly module from the access point
+    *
+    * @ returns true if successful
+    */
+    bool disconnect();
+
+    /*
+    * Open a tcp connection with the specified host on the specified port
+    *
+    * @param host host (can be either an ip address or a name. If a name is provided, a dns request will be established)
+    * @param port port
+    * @ returns true if successful
+    */
+    bool connect(const char * host, int port);
+
+
+    /*
+    * Set the protocol (UDP or TCP)
+    *
+    * @param p protocol
+    * @ returns true if successful
+    */
+    bool setProtocol(Protocol p);
+
+    /*
+    * Reset the wifi module
+    */
+    void reset();
+    
+    /*
+    * Reboot the wifi module
+    */
+    bool reboot();
+
+    /*
+    * Check if characters are available
+    *
+    * @return number of available characters
+    */
+    int readable();
+
+    /*
+    * Check if characters are available
+    *
+    * @return number of available characters
+    */
+    int writeable();
+
+    /*
+    * Check if a tcp link is active
+    *
+    * @returns true if successful
+    */
+    bool is_connected();
+
+    /*
+    * Read a character
+    *
+    * @return the character read
+    */
+    char getc();
+
+    /*
+    * Flush the buffer
+    */
+    void flush();
+
+    /*
+    * Write a character
+    *
+    * @param the character which will be written
+    */
+    int putc(char c);
+
+
+    /*
+    * To enter in command mode (we can configure the module)
+    *
+    * @return true if successful, false otherwise
+    */
+    bool cmdMode();
+
+    /*
+    * To exit the command mode
+    *
+    * @return true if successful, false otherwise
+    */
+    bool exit();
+
+    /*
+    * Close a tcp connection
+    *
+    * @ returns true if successful
+    */
+    bool close();
+
+    /*
+    * Send a string to the wifi module by serial port. This function desactivates the user interrupt handler when a character is received to analyze the response from the wifi module.
+    * Useful to send a command to the module and wait a response.
+    *
+    *
+    * @param str string to be sent
+    * @param len string length
+    * @param ACK string which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknoledged. (default: "NO")
+    * @param res this field will contain the response from the wifi module, result of a command sent. This field is available only if ACK = "NO" AND res != NULL (default: NULL)
+    *
+    * @return true if ACK has been found in the response from the wifi module. False otherwise or if there is no response in 5s.
+    */
+    int send(const char * str, int len, const char * ACK = NULL, char * res = NULL, int timeout = DEFAULT_WAIT_RESP_TIMEOUT);
+
+    /*
+    * Send a command to the wify module. Check if the module is in command mode. If not enter in command mode
+    *
+    * @param str string to be sent
+    * @param ACK string which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknoledged. (default: "NO")
+    * @param res this field will contain the response from the wifi module, result of a command sent. This field is available only if ACK = "NO" AND res != NULL (default: NULL)
+    *
+    * @returns true if successful
+    */
+    bool sendCommand(const char * cmd, const char * ack = NULL, char * res = NULL, int timeout = DEFAULT_WAIT_RESP_TIMEOUT);
+    
+    /*
+    * Return true if the module is using dhcp
+    *
+    * @returns true if the module is using dhcp
+    */
+    bool isDHCP() {
+        return state.dhcp;
+    }
+
+    bool gethostbyname(const char * host, char * ip);
+
+    static Wifly * getInstance() {
+        return inst;
+    };
+
+protected:
+    Serial wifi;
+    DigitalOut reset_pin;
+    DigitalIn tcp_status;
+    char phrase[30];
+    char ssid[30];
+    const char * ip;
+    const char * netmask;
+    const char * gateway;
+    int channel;
+    CircBuffer<char> buf_wifly;
+
+    static Wifly * inst;
+
+    void attach_rx(bool null);
+    void handler_rx(void);
+
+
+    typedef struct STATE {
+        bool associated;
+        bool tcp;
+        bool dhcp;
+        Security sec;
+        Protocol proto;
+        bool cmd_mode;
+    } State;
+
+    State state;
+    char * getStringSecurity();
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/WiflyInterface.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,62 @@
+#include "WiflyInterface.h"
+
+WiflyInterface::WiflyInterface( PinName tx, PinName rx, PinName reset, PinName tcp_status,
+                                const char * ssid, const char * phrase, Security sec) :
+    Wifly(tx, rx, reset, tcp_status, ssid, phrase, sec)
+{
+    ip_set = false;
+}
+
+int WiflyInterface::init()
+{
+    state.dhcp = true;
+    reset();
+    return 0;
+}
+
+int WiflyInterface::init(const char* ip, const char* mask, const char* gateway)
+{
+    state.dhcp = false;
+    this->ip = ip;
+    strcpy(ip_string, ip);
+    ip_set = true;
+    this->netmask = mask;
+    this->gateway = gateway;
+    reset();
+
+    return 0;
+}
+
+int WiflyInterface::connect()
+{
+    return join();
+}
+
+int WiflyInterface::disconnect()
+{
+    return Wifly::disconnect();
+}
+
+char * WiflyInterface::getIPAddress()
+{
+    char * match = 0;
+    if (!ip_set) {
+        if (!sendCommand("get ip a\r", NULL, ip_string))
+            return NULL;
+        exit();
+        flush();
+        match = strstr(ip_string, "<");
+        if (match != NULL) {
+            *match = '\0';
+        }
+        if (strlen(ip_string) < 6) {
+            match = strstr(ip_string, ">");
+            if (match != NULL) {
+                int len = strlen(match + 1);
+                memcpy(ip_string, match + 1, len);
+            }
+        }
+        ip_set = true;
+    }
+    return ip_string;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/WiflyInterface/WiflyInterface.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,86 @@
+/* WiflyInterface.h */
+/* Copyright (C) 2012 mbed.org, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+ 
+#ifndef WIFLYINTERFACE_H_
+#define WIFLYINTERFACE_H_
+
+#include "Wifly.h"
+
+ /** Interface using Wifly to connect to an IP-based network
+ *
+ */
+class WiflyInterface: public Wifly {
+public:
+
+    /**
+    * Constructor
+    *
+    * \param tx mbed pin to use for tx line of Serial interface
+    * \param rx mbed pin to use for rx line of Serial interface
+    * \param reset reset pin of the wifi module ()
+    * \param tcp_status connection status pin of the wifi module (GPIO 6)
+    * \param ssid ssid of the network
+    * \param phrase WEP or WPA key
+    * \param sec Security type (NONE, WEP_128 or WPA)
+    */
+  WiflyInterface(PinName tx, PinName rx, PinName reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec = NONE);
+
+  /** Initialize the interface with DHCP.
+  * Initialize the interface and configure it to use DHCP (no connection at this point).
+  * \return 0 on success, a negative number on failure
+  */
+  int init(); //With DHCP
+
+  /** Initialize the interface with a static IP address.
+  * Initialize the interface and configure it with the following static configuration (no connection at this point).
+  * \param ip the IP address to use
+  * \param mask the IP address mask
+  * \param gateway the gateway to use
+  * \return 0 on success, a negative number on failure
+  */
+  int init(const char* ip, const char* mask, const char* gateway);
+
+  /** Connect
+  * Bring the interface up, start DHCP if needed.
+  * \return 0 on success, a negative number on failure
+  */
+  int connect();
+  
+  /** Disconnect
+  * Bring the interface down
+  * \return 0 on success, a negative number on failure
+  */
+  int disconnect();
+  
+  /** Get IP address
+  *
+  * @ returns ip address
+  */
+  char* getIPAddress();
+  
+private:
+    char ip_string[20];
+    bool ip_set;
+};
+
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+#include "UDPSocket.h"
+
+#endif /* WIFLYINTERFACE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/gmon.cpp	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,117 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "LM75B.h"
+#include "MMA7660.h"
+#include "C12832.h"
+#include "MSCFileSystem.h"
+#include "NTPClient.h"
+
+
+/* wifly interface:
+*     - p9 and p10 are for the serial communication
+*     - p30 is for the reset pin
+*     - p29 is for the connection status
+*     - "mbed" is the ssid of the network
+*     - "password" is the password
+*     - WPA is the security
+*/
+WiflyInterface wifly(p9, p10, p30, p29, "mbed", "password", WPA);
+NTPClient ntp; // Don't move this line
+MSCFileSystem fs("fs");
+C12832 lcd(p5, p7, p6, p8, p11);
+DigitalIn my_abort(p14);
+
+// accelerometer
+MMA7660 MMA(p28, p27);
+
+// temperature sensor
+LM75B tmp(p28,p27);
+
+float x,y,z;
+int temp;
+char filename[50];
+
+int main()
+{
+    time_t ctTime;
+
+    // Display welcoming message
+    lcd.cls();
+    lcd.printf("mbed g monitor\n");
+
+    // Connect to local wifi network
+    wifly.init(); //Use DHCP
+    while (!wifly.connect());
+    lcd.printf("IP Address is %s\n", wifly.getIPAddress());
+
+    // Get current time (UTC) through internet
+    lcd.printf("Trying to update time...\n");
+    if (ntp.setTime("0.pool.ntp.org") == 0) {
+        ctTime = time(NULL);
+        set_time(ctTime);
+        
+        // Display current time (UTC) on the LCD
+        lcd.cls();
+        lcd.printf("Time (UTC): \n%s\n", ctime(&ctTime));
+    } else {
+        // Problem setting the current time
+        // FIXME allow user to set time and date manually
+        lcd.printf("NTP Error, press reset to retry\n");
+        while(1);
+    }
+
+    wait(3);
+    lcd.cls(); // Clear the LCD screen
+
+    // Check for the accelerometer's presence
+    if (MMA.testConnection()) {
+        for (int j = 0; j < 36; j++) {
+            sprintf(filename,"/fs/gmon%d.csv",j);
+            lcd.printf("Opening file #%d\n",j);
+            
+            FILE *fp = fopen(filename,"w");
+            // Check if file was properly opened
+            if (fp != NULL) {
+                printf("Create filehandle for %s\r\n",filename);
+                printf("Writing to file\r\n");
+        
+                // Take 100000 samples per file
+                for (int i = 0; i < 100000; i++) {
+                    // Read the accelerometer
+                    x = MMA.x();
+                    y = MMA.y();
+                    z = MMA.z();
+                    
+                    // Read the temperature
+                    temp = (int)tmp.read();
+                    
+                    // Get current time
+                    ctTime = time(NULL);
+                    
+                    // Write the data to file
+                    fprintf(fp,"%0.5f, %0.5f, %0.5f, %d, %s",x,y,z,temp, ctime(&ctTime));
+                    
+                    // If something goes wrong/was not right press on the joystick button
+                    if (my_abort){
+                        // Close the currently opened file to prevent corrupt data
+                        fclose(fp);
+                        lcd.cls();
+                        lcd.printf("Aborting, USB Flash can be removed\n");
+                        
+                        // infinite loop
+                        while(1);
+                    }
+                    
+                    // take one sample every 30 seconds                        
+                    wait(30);
+                }
+                fclose(fp);
+                printf("Close the handle\n");
+            } else {
+                printf("Can't open %s\r\n",filename);
+            }
+        }
+    }
+    lcd.cls(); // Clear the LCD screen
+    lcd.printf("End of data acquisition\n");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/mbed.bld	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gmon/mbed_config.h	Mon Nov 18 06:09:14 2019 +0000
@@ -0,0 +1,34 @@
+/*
+ * mbed SDK
+ * Copyright (c) 2017 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Automatically generated configuration file.
+// DO NOT EDIT, content will be overwritten.
+
+#ifndef __MBED_CONFIG_DATA__
+#define __MBED_CONFIG_DATA__
+
+// Configuration parameters
+#define MBED_CONF_TARGET_BOOT_STACK_SIZE                0x1000     // set by target:Target
+#define MBED_CONF_TARGET_CONSOLE_UART                   1          // set by target:Target
+#define MBED_CONF_TARGET_DEEP_SLEEP_LATENCY             0          // set by target:Target
+#define MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT         0          // set by target:Target
+#define MBED_CONF_TARGET_MPU_ROM_END                    0x0fffffff // set by target:Target
+#define MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE ETHERNET   // set by target:LPC1768
+#define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER        0          // set by target:Target
+#define MBED_CONF_TARGET_US_TICKER_TIMER                3          // set by target:LPC1768
+
+#endif