Question
Troubles at receive more than one character (RTOS-RL-ARM)
Posted on March 02, 2012 at 12:34
How to send and receive data using RTOS (RL-ARM) with tasks?
(Without generating an interruption?) Using this functions below:TO SEND
/*---------------------------------------------------------------------------- Write character to Serial Port *----------------------------------------------------------------------------*/ int sendchar (int c) {if (c == '\n') {
while (!(USARTx->SR & USART_FLAG_TXE)); USARTx->DR = 0x0D; } while (!(USARTx->SR & USART_FLAG_TXE)); USARTx->DR = (c & 0x1FF);return (c);
}TO RECEIVE
/*---------------------------------------------------------------------------- * Line Editor *---------------------------------------------------------------------------*/ void getline (char *line, int n) { int cnt = 0; char c;do {
if ((c = getkey ()) == CR) c = LF; /* read character */ if (c == BACKSPACE || c == DEL) { /* process backspace */ if (cnt != 0) { cnt--; /* decrement count */ line--; /* and line pointer */ putchar (BACKSPACE); /* echo backspace */ putchar (' '); putchar (BACKSPACE); } } else if (c != CNTLQ && c != CNTLS) { /* ignore Control S/Q */ putchar (*line = c); /* echo and store character */ line++; /* increment line pointer */ cnt++; /* and count */ } } while (cnt < n - 1 && c != LF); /* check limit and line feed */ *(line - 1) = 0; /* mark end of string */ } #rtos-rlarm-usart-send-receive