Esempio n. 1
0
void main()
{
	// Enable UART with baud rate 9600
	uart_init(9600);

	// Functions from `stream.h` will work with any stream
	// "uart" is a pointer to the UART stream

	put_str(uart, "UART is 1337");
	put_nl(uart);
	put_str_P(uart, PSTR("String from program memory!!!"));
	put_nl(uart);

	put_u16f(uart, 31416, 4);

	put_i32(uart, 123456789L);

	put_nl(uart);

	put_x16(uart, 0xAC01);
	put_nl(uart);
	put_x64(uart, 0xABAD1DEADEADBEEF);

	while(1);
}
Esempio n. 2
0
// Our custom key handler function
void key_handler(uint8_t code, bool special)
{
	put_str_P(uart, special ? PSTR("Special: ") : PSTR("Char: "));
	put_c(uart, code); // the actual character
	put_c(uart, ' '); // space
	put_u8(uart, code); // as number
	put_nl(uart); // crlf
}
Esempio n. 3
0
void main()
{
	uart_init(9600);  // set BAUD-rate
	uart_isr_rx(1);  // enable the ISR
	vt_init();  // initialize uart_ansi library

	vt_set_key_handler(&key_handler);  // assign our custom handler

	sei();

	put_str_P(uart, PSTR("UART key handler test!\r\n"));

	while(1);
}