stdio_serial.h
Go to the documentation of this file.
1 
37 /*
38  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
39  */
40 
41 
42 #ifndef _STDIO_SERIAL_H_
43 #define _STDIO_SERIAL_H_
44 
55 #include <stdio.h>
56 #include "compiler.h"
57 #ifndef SAMD20
58 # include "sysclk.h"
59 #endif
60 #include "serial.h"
61 
62 #if (XMEGA || MEGA_RF) && defined(__GNUC__)
63  extern int _write (char c, int *f);
64  extern int _read (int *f);
65 #endif
66 
67 
69 extern volatile void *volatile stdio_base;
71 extern int (*ptr_put)(void volatile*, char);
72 
74 extern void (*ptr_get)(void volatile*, char*);
75 
82 static inline void stdio_serial_init(volatile void *usart, const usart_serial_options_t *opt)
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 }
114 
119 #endif // _STDIO_SERIAL_H_
static void stdio_serial_init(volatile void *usart, const usart_serial_options_t *opt)
Initializes the stdio in Serial Mode.
Definition: stdio_serial.h:82
Usart hardware registers.
#define NULL
Definition: nm_bsp.h:52
static int usart_serial_putchar(usart_if p_usart, const uint8_t c)
Sends a character with the USART.
Definition: uart_serial.h:376
Commonly used includes, types and macros.
volatile void *volatile stdio_base
Pointer to the base of the USART module instance to use for stdio.
Definition: write.c:46
void(* ptr_get)(void volatile *, char *)
Pointer to the external low level read function.
Definition: read.c:50
static void usart_serial_getchar(usart_if p_usart, uint8_t *data)
Waits until a character is received, and returns it.
Definition: uart_serial.h:476
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
int(* ptr_put)(void volatile *, char)
Pointer to the external low level write function.
Definition: write.c:47


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58