SAM4SD32 (SAM4S-EK2)
Loading...
Searching...
No Matches
Standard serial I/O (stdio)

Common standard serial I/O management driver that implements a stdio serial interface on AVR and SAM devices. More...

Functions

static void stdio_serial_init (volatile void *usart, const usart_serial_options_t *opt)
 Initializes the stdio in Serial Mode.

Variables

void(* ptr_get )(void volatile *, char *)
 Pointer to the external low level read function.
int(* ptr_put )(void volatile *, char)
 Pointer to the external low level write function.
volatile void *volatile stdio_base
 Pointer to the base of the USART module instance to use for stdio.

Detailed Description

Common standard serial I/O management driver that implements a stdio serial interface on AVR and SAM devices.

Function Documentation

◆ stdio_serial_init()

void stdio_serial_init ( volatile void * usart,
const usart_serial_options_t * opt )
inlinestatic

Initializes the stdio in Serial Mode.

Parameters
usartBase address of the USART instance.
optOptions needed to set up RS232 communication (see usart_serial_options_t).

Definition at line 82 of file stdio_serial.h.

83{
84 stdio_base = (void *)usart;
85 ptr_put = (int (*)(void volatile*,char))&usart_serial_putchar;
86 ptr_get = (void (*)(void volatile*,char*))&usart_serial_getchar;
87# if (XMEGA || MEGA_RF)
88 usart_serial_init((USART_t *)usart,opt);
89# elif UC3
91# elif SAM
93# else
94# error Unsupported chip type
95# endif
96
97# if defined(__GNUC__)
98# if (XMEGA || MEGA_RF)
99 // For AVR GCC libc print redirection uses fdevopen.
100 fdevopen((int (*)(char, FILE*))(_write),(int (*)(FILE*))(_read));
101# endif
102# if UC3 || SAM
103 // For AVR32 and SAM GCC
104 // Specify that stdout and stdin should not be buffered.
105 setbuf(stdout, NULL);
106 setbuf(stdin, NULL);
107 // Note: Already the case in IAR's Normal DLIB default configuration
108 // and AVR GCC library:
109 // - printf() emits one character at a time.
110 // - getchar() requests only 1 byte to exit.
111# endif
112# endif
113}
int(* ptr_put)(void volatile *, char)
Pointer to the external low level write function.
void(* ptr_get)(void volatile *, char *)
Pointer to the external low level read function.
volatile void *volatile stdio_base
Pointer to the base of the USART module instance to use for stdio.
Usart hardware registers.
static int usart_serial_putchar(usart_if p_usart, const uint8_t c)
Sends a character with the USART.
static void usart_serial_init(usart_if p_usart, usart_serial_options_t *opt)
Initializes the Usart in master mode.
Definition uart_serial.h:87
static void usart_serial_getchar(usart_if p_usart, uint8_t *data)
Waits until a character is received, and returns it.
usart_rs232_options_t usart_serial_options_t
Definition uart_serial.h:76

References ptr_get, ptr_put, stdio_base, usart_serial_getchar(), usart_serial_init(), and usart_serial_putchar().

Variable Documentation

◆ ptr_get

void(* ptr_get) (void volatile *, char *) ( void volatile * ,
char *  )
extern

Pointer to the external low level read function.

Referenced by stdio_serial_init().

◆ ptr_put

int(* ptr_put) (void volatile *, char) ( void volatile * ,
char  )
extern

Pointer to the external low level write function.

Referenced by stdio_serial_init().

◆ stdio_base

volatile void* volatile stdio_base
extern

Pointer to the base of the USART module instance to use for stdio.

Referenced by stdio_serial_init().