@Phil93:
Du könntest diese Funktionen zur Eingabe von Zeichen nehmen:
Code:
// Reception buffer for the function getInputLine():
char receiveBuffer[UART_RECEIVE_BUFFER_SIZE + 1];
/**
* Get chars of an input line from the UART.
*
* Returns 0 (false), if the UART receive buffer is empty
* OR a character of the input line has been received.
* Returns 1, if the whole input line has been received
* (with a "new line" character at the end).
* Returns 2, if the UART receive buffer overflows.
* The input line is stored in the receiveBuffer array.
*
*/
uint8_t getInputLine(void)
{static uint8_t buffer_pos = 0;
if(getBufferLength()) {
receiveBuffer[buffer_pos] = readChar();
if(receiveBuffer[buffer_pos] == '\n') {
receiveBuffer[buffer_pos] = '\0';
buffer_pos = 0;
return 1;
}
else if(buffer_pos >= UART_RECEIVE_BUFFER_SIZE) {
receiveBuffer[UART_RECEIVE_BUFFER_SIZE] = '\0';
buffer_pos = 0;
return 2;
}
buffer_pos++;
}
return 0;
}
/**
* Get a complete input line from the UART.
*
* This function waits for a whole input line from the UART.
* The input line is stored in the receiveBuffer array.
* The function is blocking until one of the two following
* conditions occurs:
* - A "new line" character has been received at the end of
* the input line.
* - The UART receive buffer overflows.
*
*/
void enterString(void)
{
while(!getInputLine());
}
Gruß Dirk
Lesezeichen