-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialio.h
More file actions
39 lines (33 loc) · 1.33 KB
/
serialio.h
File metadata and controls
39 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* serialio.h
*
* Author: Peter Sutton
*
* Module to allow standard input/output routines to be used via
* serial port 0. The init_serial_stdio() method must be called before
* any standard IO methods (e.g. printf). We use interrupt-based serial
* IO and a circular buffer to store output messages. (This allows us
* to print many characters at once to the buffer and have them
* output by the UART as speed permits.) Interrupts must be enabled
* globally for this module to work (after init_serial_stdio() is called).
*
*/
#ifndef SERIALIO_H_
#define SERIALIO_H_
#include <stdint.h>
/* Initialise serial IO using the UART. baudrate specifies the desired
* baudrate (e.g. 19200) and echo determines whether incoming characters
* are echoed back to the UART output as they are received (zero means no
* echo, non-zero means echo)
*/
void init_serial_stdio(long baudrate, int8_t echo);
/* Test if input is available from the serial port. Return 0 if not,
* non-zero otherwise. If there is input available then it can be read
* with a suitable standard IO library function, e.g. fgetc().
*/
int8_t serial_input_available(void);
/* Discard any input waiting to be read from the serial port. (Characters may
* have been typed when we didn't want them - clear them.
*/
void clear_serial_input_buffer(void);
#endif /* SERIALIO_H_ */