It's been quite a long time since we first posted code for 'Abstract USART'. We've improved it considerably in the meantime,
so we thought we'd share it with you now.
We now call it simply 'stdio_usart'. Its purpose is to have a serial terminal ready to go when main() begins, enabling the
application to immediately use stdio functions, such as printf() and scanf(), without having to first write code for intitializing
the usart, buffering characters, handling interrupts & etc. Just #include "stdio_usart.h" and you're ready to go.
- Buffered, interrupt driven
- You can choose differing sizes for transmit and receive buffers
- Plain C header file
- Works with the atmega328 and atmega 1284 families
- Easily adaptable to other families
The default buffer sizes are 16 bytes each. You can choose smaller or larger buffer sizes separately, using...
#define STD_USART_INSIZE X
The default baud rate is 9600, which can be changed simply by defining BAUD. The frame format is 8 N 1.
#define STD_USART_OUTSIZE Y
#define BAUD 38400
#define STD_USART_INSIZE 32
#define STD_USART_OUTSIZE 128
sei(); // interrupts need to be enabled at main()
printf("This AVRs clock rate is %ld cycles per second",F_CPU);
Get it here.