-
Notifications
You must be signed in to change notification settings - Fork 52
/
serial.h
51 lines (43 loc) · 1.04 KB
/
serial.h
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
/*
* Interface to serial port.
*
* Copyright (C) 2015 Serge Vakulenko
*
* This file is part of PIC32PROG project, which is distributed
* under the terms of the GNU General Public License (GPL).
* See the accompanying file "COPYING" for more details.
*/
#ifndef _SERIAL_H
#define _SERIAL_H
/*
* Open the serial port with the specified baud rate and
* receive timeout (in milliseconds).
* Return -1 on error.
*/
int serial_open(const char *devname, int baud_rate);
/*
* Change the serial baud rate
* Return -1 on error.
*/
int serial_baud(int baud_rate);
/*
* Close the serial port.
*/
void serial_close(void);
/*
* Send data to device.
* Return number of bytes, or -1 on error.
*/
int serial_write(unsigned char *data, int len);
/*
* Receive data from device.
* Return number of bytes, or -1 on error.
*/
int serial_read(unsigned char *data, int len, int timeout_msec);
/*
* Check whether the given speed in bits per second
* is supported by the system.
* Return 0 when not supported.
*/
int serial_speed_valid(int bps);
#endif