comparison sw/libserial/setbaud.c @ 21:c4346cdc9641

sw/libserial: based on FC host tools version
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 22 Aug 2023 02:44:23 +0000
parents
children
comparison
equal deleted inserted replaced
20:f6579cef76e1 21:c4346cdc9641
1 /*
2 * This module implements the termios/ioctl setting of the baud rate.
3 */
4
5 #include <sys/types.h>
6 #include <sys/ioctl.h>
7 #include <asm/ioctls.h>
8 #include <asm/termbits.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12
13 extern int target_fd;
14
15 set_serial_baudrate(br)
16 unsigned br;
17 {
18 struct termios2 target_termios;
19
20 target_termios.c_iflag = IGNBRK;
21 target_termios.c_oflag = 0;
22 target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8;
23 target_termios.c_lflag = 0;
24 target_termios.c_cc[VMIN] = 1;
25 target_termios.c_cc[VTIME] = 0;
26 target_termios.c_ispeed = br;
27 target_termios.c_ospeed = br;
28 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) {
29 perror("TCSETSF2");
30 exit(1);
31 }
32 return 0;
33 }