diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sw/libserial/setbaud.c	Tue Aug 22 02:44:23 2023 +0000
@@ -0,0 +1,33 @@
+/*
+ * This module implements the termios/ioctl setting of the baud rate.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <asm/ioctls.h>
+#include <asm/termbits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern int target_fd;
+
+set_serial_baudrate(br)
+	unsigned br;
+{
+	struct termios2 target_termios;
+
+	target_termios.c_iflag = IGNBRK;
+	target_termios.c_oflag = 0;
+	target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8;
+	target_termios.c_lflag = 0;
+	target_termios.c_cc[VMIN] = 1;
+	target_termios.c_cc[VTIME] = 0;
+	target_termios.c_ispeed = br;
+	target_termios.c_ospeed = br;
+	if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) {
+		perror("TCSETSF2");
+		exit(1);
+	}
+	return 0;
+}