mbed2 zad 5b

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Funkcje_UART/FunkcjeUART.cpp

Committer:
krzysiek99
Date:
2020-06-08
Revision:
4:7855d3ab4c15
Child:
5:cafab5a4d1c9

File content as of revision 4:7855d3ab4c15:

#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;
}