Created
July 23, 2018 19:29
-
-
Save technoAl/ca06e8eb4a8b197c8936f4cbd10e8ad3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ======================================== | |
* | |
* Copyright YOUR COMPANY, THE YEAR | |
* All Rights Reserved | |
* UNPUBLISHED, LICENSED SOFTWARE. | |
* | |
* CONFIDENTIAL AND PROPRIETARY INFORMATION | |
* WHICH IS THE PROPERTY OF your company. | |
* | |
* ======================================== | |
*/ | |
#include <project.h> | |
uint8 getValidByte(){ | |
uint8 retval = 0u; | |
while(UART_SpiUartGetRxBufferSize() < 1); | |
retval = UART_UartGetByte(); | |
return retval; | |
} | |
void reverseText(){ | |
char str[100]; | |
int i = 0; | |
while(1){ | |
uint8 b = getValidByte(); | |
if(b != '!'){ | |
str[i] = b; | |
i++; | |
}else{ | |
char reverse[i]; | |
int k = i; | |
for(int j = 0; j < k; j++){ | |
reverse[j] = str[i-1]; | |
i--; | |
} | |
UART_UartPutString(reverse); | |
memset(&str, 0, 100); | |
i = 0; | |
break; | |
} | |
} | |
} | |
void printFlag(){ | |
UART_UartPutString("YOU WIN"); | |
} | |
int main (void) | |
{ | |
CyGlobalIntEnable; /* Enable global interrupts */ | |
volatile int dummy[1]; | |
*dummy = 0; | |
/* Place your initialization/startup code here (e.g. MyInst_Start()) */ | |
UART_Start(); | |
for(;;) | |
{ | |
/* Place your application code here */ | |
reverseText(); | |
if (*dummy) break; | |
} | |
printFlag(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment