File: serial.h

package info (click to toggle)
crust-firmware 0.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,900 kB
  • sloc: ansic: 19,341; yacc: 596; lex: 479; makefile: 334; asm: 215; sh: 136; python: 42
file content (66 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright © 2017-2022 The Crust Firmware Authors.
 * SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only
 */

#ifndef DRIVERS_SERIAL_H
#define DRIVERS_SERIAL_H

#include <stdbool.h>

#if CONFIG(SERIAL)

/**
 * Read a character from the UART.
 *
 * @return The character read, or 0 if no character is available.
 */
char serial_getc(void);
void serial_putc(char c);
void serial_puts(const char *s);

/**
 * Initialize the UART.
 */
void serial_init(void);

/**
 * Verify that the UART is ready to use.
 *
 * This function must be called before performing any I/O. Other serial I/O
 * functions may only be called if this function returns true.
 */
bool serial_ready(void);

#else

static inline char
serial_getc(void)
{
	return 0;
}

static inline void
serial_putc(char c UNUSED)
{
}

static inline void
serial_puts(const char *s UNUSED)
{
}

static inline void
serial_init(void)
{
}

static inline bool
serial_ready(void)
{
	return false;
}

#endif

#endif /* DRIVERS_SERIAL_H */