a

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Committer:
matis755
Date:
Fri May 22 07:30:59 2020 +0000
Revision:
6:06ff453bb16e
Parent:
4:e48aee3e8d09
Use standard C functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matis755 4:e48aee3e8d09 1 #include "uart.h"
matis755 4:e48aee3e8d09 2
matis755 4:e48aee3e8d09 3 Uart::Uart() : MySerial(USBTX, USBRX){
matis755 4:e48aee3e8d09 4
matis755 4:e48aee3e8d09 5 };
matis755 4:e48aee3e8d09 6
matis755 4:e48aee3e8d09 7 char Uart::gets(char *pStr, unsigned char ucSize){
matis755 4:e48aee3e8d09 8 unsigned char ucStrPtr = 0;
matis755 4:e48aee3e8d09 9 while(ucStrPtr < ucSize) {
matis755 4:e48aee3e8d09 10 pStr[ucStrPtr] = MySerial.getc();
matis755 4:e48aee3e8d09 11 if(pStr[ucStrPtr] == '\r') {
matis755 4:e48aee3e8d09 12 pStr[ucStrPtr] = NULL;
matis755 4:e48aee3e8d09 13 return 0;
matis755 4:e48aee3e8d09 14 }
matis755 4:e48aee3e8d09 15 ucStrPtr ++;
matis755 4:e48aee3e8d09 16 }
matis755 4:e48aee3e8d09 17 return 1;
matis755 4:e48aee3e8d09 18 }
matis755 4:e48aee3e8d09 19
matis755 4:e48aee3e8d09 20 char Uart::puts(char *pStr, unsigned char ucSize){
matis755 4:e48aee3e8d09 21 unsigned char ucNullPtr;
matis755 4:e48aee3e8d09 22 for(ucNullPtr = 0; ucNullPtr <= ucSize; ucNullPtr++){
matis755 4:e48aee3e8d09 23 if(pStr[ucNullPtr] == NULL) {
matis755 4:e48aee3e8d09 24 break;
matis755 4:e48aee3e8d09 25 }
matis755 4:e48aee3e8d09 26 else {}
matis755 4:e48aee3e8d09 27 }
matis755 4:e48aee3e8d09 28 if (ucNullPtr == ucSize) {
matis755 4:e48aee3e8d09 29 return 1;
matis755 4:e48aee3e8d09 30 }
matis755 4:e48aee3e8d09 31
matis755 4:e48aee3e8d09 32 for(unsigned char ucIdx = 0; ucIdx < ucNullPtr; ucIdx ++) {
matis755 4:e48aee3e8d09 33 MySerial.putc(pStr[ucIdx]);
matis755 4:e48aee3e8d09 34 }
matis755 4:e48aee3e8d09 35 MySerial.putc('\r');
matis755 4:e48aee3e8d09 36 return 0;
matis755 4:e48aee3e8d09 37 }