Ejemplo n.º 1
0
 int uart0_receiveString( char* string)
 {
	 int stop = 0; // boolean for stop value
	 char ch;
	 while (!stop) // while contunie
	 {
		 ch = uart0_receiveChar(); // read ch
		 if ( ch == LF ) // stop at LF
		 stop = 1;
		 else
		 *string++ = ch; // else fill buffer
	 }
	 *string = '\0'; // string terminator
	 return 0;
 }
Ejemplo n.º 2
0
// Main program: USART0: send & receive
int main( void )
{
	DDRB = 0xFF;							// set PORTB for output, for testing
	DDRA = 0xFF;							// set PORTA for output, for testing
	usart0_init();							// initialize USART0
	usart0_start();							// uart0: start send & receive

	while (1)
	{
		wait(50);							// every 50 ms (busy waiting)
		PORTB ^= BIT(7);					// toggle bit 7 for testing

		character = uart0_receiveChar();	// read char
		PORTA = character;					// show read character, for testing

		uart0_sendChar(character);			// send back
	}
}