mbed2 zad 5b
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
Diff: Funkcje_UART/FunkcjeUART.cpp
- Revision:
- 4:7855d3ab4c15
- Child:
- 5:cafab5a4d1c9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Funkcje_UART/FunkcjeUART.cpp Mon Jun 08 21:49:36 2020 +0000 @@ -0,0 +1,45 @@ +#include "FunkcjeUART.h" + +extern Serial pc; + +bool puts(char *pString, int iLength) +{ + bool bResult; + int iNullPosition = iLength; + for(int iCounter = 0; iCounter < iLength; iCounter++) + { + if(pString[iCounter] == 0) + { + bResult = 0; + iNullPosition = iCounter; + break; + } + } + for(int iCounter = 0; iCounter < iNullPosition; iCounter++) + pc.putc(pString[iCounter]); + if(bResult) + { + pc.putc(13); + pc.putc(10); + } + return bResult; +} + +bool gets(char *pString, int iLength) +{ + bool bResult = 1; + for(unsigned int uiCounter = 0; uiCounter < iLength; uiCounter++, pString++) + { + *pString = pc.getc(); + if(*pString == 10) + { + if(*(pString-1) == 13) + { + bResult = 0; + *(--pString) = 0; + break; + } + } + } + return bResult; +}