a

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Revision:
4:e48aee3e8d09
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uart.cpp	Thu May 21 11:03:32 2020 +0000
@@ -0,0 +1,37 @@
+#include "uart.h"
+
+Uart::Uart() : MySerial(USBTX, USBRX){
+
+};
+
+char Uart::gets(char *pStr, unsigned char ucSize){
+    unsigned char ucStrPtr = 0;
+    while(ucStrPtr < ucSize) {
+        pStr[ucStrPtr] = MySerial.getc();
+        if(pStr[ucStrPtr] == '\r') {
+            pStr[ucStrPtr] = NULL;
+            return 0;
+        }
+        ucStrPtr ++;    
+    }
+    return 1;
+}
+
+char Uart::puts(char *pStr, unsigned char ucSize){   
+    unsigned char ucNullPtr;
+    for(ucNullPtr = 0; ucNullPtr <= ucSize; ucNullPtr++){
+        if(pStr[ucNullPtr] == NULL) {
+            break;
+        }
+        else {}
+    }
+    if (ucNullPtr == ucSize) {
+        return 1;
+    }
+
+    for(unsigned char ucIdx = 0; ucIdx < ucNullPtr; ucIdx ++) {
+        MySerial.putc(pStr[ucIdx]);
+    }
+    MySerial.putc('\r');
+    return 0;
+}
\ No newline at end of file