FreeCalypso > hg > freecalypso-tools
annotate libpwon/duart28c.c @ 904:5041bcb8140f
tchtools/fc-vm2hex.c: update header comment for new situation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 28 Dec 2022 08:41:57 +0000 |
parents | 7d1df6d831e4 |
children |
rev | line source |
---|---|
736
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <sys/ioctl.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <stdio.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <stdlib.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <string.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <strings.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <unistd.h> |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 extern int target_fd; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 int bootctrl_duart28c_mode; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static int mctl_arg; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 bootctrl_check_duart28c(bc_name) |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 char *bc_name; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (!strcmp(bc_name, "dtr")) { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 bootctrl_duart28c_mode = 1; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 mctl_arg = TIOCM_DTR; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 return 1; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (!strcmp(bc_name, "rts")) { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 bootctrl_duart28c_mode = 1; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 mctl_arg = TIOCM_RTS; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return 1; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return 0; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 void |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 fork_duart28c_pulse() |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 int i; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 i = fork(); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (i < 0) { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 perror("fork"); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 exit(1); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (i) |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return; |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 ioctl(target_fd, TIOCMBIS, &mctl_arg); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 usleep(50000); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ioctl(target_fd, TIOCMBIC, &mctl_arg); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 exit(0); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |