How to configure FILE * to point to USART?

Discussions about all user software around SAM Series.

Moderator: nferre

Posts: 9
Joined: Tue Jun 18, 2013 9:47 pm

How to configure FILE * to point to USART?

Tue May 06, 2014 11:54 pm

I have a similar problem as stated here:

discussions/viewtopic.php/f,29/t,22075/ ... tml#p41228

I am developing on a SAMD20J18, but believe this issue is generic to the Atmel Toolchain (ARM).

I currently have functions written to put a char out the UART:

Code: Select all

void uart3_putc(char c) {
	SERCOM3->USART.DATA.reg = c;	
	if(c == '\n') {

Code: Select all

void uart3_puts(char *s) {
	//String must be null terminated!!
	while(*s) {
Obviously, these simple functions lack the formatting capability of fprintf/printf.

On an AVR, I would create a FILE variable, and use FDEVSETUP to configure it to point to my usart_putchar/getchar functions. Unfortunately, I cannot find a similar way to do so using arm-gcc. Is it possible to do something similar? If so, how?

Return to “Software”

Who is online

Users browsing this forum: No registered users and 1 guest