mbed2_5

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Committer:
wolve265
Date:
Sun May 24 18:45:14 2020 +0000
Revision:
0:edf190717f4f
final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolve265 0:edf190717f4f 1 #include "Uart.h"
wolve265 0:edf190717f4f 2 #include "mbed.h"
wolve265 0:edf190717f4f 3 Serial uart(USBTX, USBRX); // tx, rx
wolve265 0:edf190717f4f 4
wolve265 0:edf190717f4f 5 void Uart::print(char *pcString){
wolve265 0:edf190717f4f 6 uart.printf(pcString);
wolve265 0:edf190717f4f 7 }
wolve265 0:edf190717f4f 8
wolve265 0:edf190717f4f 9 bool Uart::puts(char *pTransmitWord, unsigned char ucWordSize){
wolve265 0:edf190717f4f 10 if(NULL != pTransmitWord[ucWordSize]){
wolve265 0:edf190717f4f 11 return 1;
wolve265 0:edf190717f4f 12 }
wolve265 0:edf190717f4f 13 else{
wolve265 0:edf190717f4f 14 unsigned char ucCharacterCounter;
wolve265 0:edf190717f4f 15 for(ucCharacterCounter = 0; ucCharacterCounter < ucWordSize; ucCharacterCounter++){
wolve265 0:edf190717f4f 16 uart.putc(pTransmitWord[ucCharacterCounter]);
wolve265 0:edf190717f4f 17 }
wolve265 0:edf190717f4f 18 uart.putc(13);
wolve265 0:edf190717f4f 19 return 0;
wolve265 0:edf190717f4f 20 }
wolve265 0:edf190717f4f 21 }
wolve265 0:edf190717f4f 22
wolve265 0:edf190717f4f 23 bool Uart::gets(char *pReceivedWord, unsigned char ucWordSize){
wolve265 0:edf190717f4f 24 unsigned char ucCharacterCounter;
wolve265 0:edf190717f4f 25
wolve265 0:edf190717f4f 26 for(ucCharacterCounter = 0; ucCharacterCounter <= ucWordSize; ucCharacterCounter++){
wolve265 0:edf190717f4f 27 unsigned char ucCurrentChar = uart.getc();
wolve265 0:edf190717f4f 28 if(ucCharacterCounter > ucWordSize){
wolve265 0:edf190717f4f 29 return 1;
wolve265 0:edf190717f4f 30 }
wolve265 0:edf190717f4f 31 else{
wolve265 0:edf190717f4f 32 if(13 == ucCurrentChar){
wolve265 0:edf190717f4f 33 pReceivedWord[ucCharacterCounter] = NULL;
wolve265 0:edf190717f4f 34 return 0;
wolve265 0:edf190717f4f 35 }
wolve265 0:edf190717f4f 36 else{
wolve265 0:edf190717f4f 37 pReceivedWord[ucCharacterCounter] = ucCurrentChar;
wolve265 0:edf190717f4f 38 }
wolve265 0:edf190717f4f 39 }
wolve265 0:edf190717f4f 40 }
wolve265 0:edf190717f4f 41 return 0;
wolve265 0:edf190717f4f 42 }