Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | pj | 1 | /* |
2 | * |
||
3 | * Project: |
||
4 | * Parallel Port S.Ha.R.K. Project |
||
5 | * |
||
6 | * Module: |
||
7 | * ppPinDrv.c |
||
8 | * |
||
9 | * Description: |
||
10 | * file contents description |
||
11 | * |
||
12 | * Coordinators: |
||
13 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
14 | * Paolo Gai <pj@gandalf.sssup.it> |
||
15 | * |
||
16 | * Authors: |
||
17 | * Andrea Battistotti <btandrea@libero.it> |
||
18 | * Armando Leggio <a_leggio@hotmail.com> |
||
19 | * |
||
20 | * |
||
21 | * http://www.sssup.it |
||
22 | * http://retis.sssup.it |
||
23 | * http://shark.sssup.it |
||
24 | * |
||
25 | */ |
||
26 | |||
27 | /******************************************************************************************* |
||
28 | * Module : ppPinDrv.c |
||
29 | * Author : Andrea Battistotti , Armando Leggio |
||
30 | * Description: Set On/Off single pin of LPT1... |
||
31 | * 2002 @ Pavia - GNU Copyrights |
||
32 | *******************************************************************************************/ |
||
33 | |||
34 | /* |
||
35 | * Copyright (C) 2002 Andrea Battistotti , Armando Leggio |
||
36 | * |
||
37 | * This program is free software; you can redistribute it and/or modify |
||
38 | * it under the terms of the GNU General Public License as published by |
||
39 | * the Free Software Foundation; either version 2 of the License, or |
||
40 | * (at your option) any later version. |
||
41 | * |
||
42 | * This program is distributed in the hope that it will be useful, |
||
43 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
44 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
45 | * GNU General Public License for more details. |
||
46 | * |
||
47 | * You should have received a copy of the GNU General Public License |
||
48 | * along with this program; if not, write to the Free Software |
||
49 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
50 | * |
||
51 | * CVS : $Id: pppindrv.c,v 1.1 2002-10-28 08:03:55 pj Exp $ |
||
52 | */ |
||
53 | |||
54 | |||
55 | /******************************************************************************************* |
||
56 | * A standard PC provides for three printer ports, at the following base addresses: |
||
57 | * |
||
58 | * LPT1 = 0x0378 or 0x03BC |
||
59 | * LPT2 = 0x0278 or 0x0378 |
||
60 | * LPT3 = 0x0278 |
||
61 | * |
||
62 | * This module assumes that LPT1 is at 0x0378. |
||
63 | * |
||
64 | * The printer port has three 8-bit registers: |
||
65 | * |
||
66 | * Data Register (base + 0) ........ outputs |
||
67 | * |
||
68 | * 7 6 5 4 3 2 1 0 |
||
69 | * . . . . . . . * D0 ........... (pin 2), 1=High, 0=Low (true) |
||
70 | * . . . . . . * . D1 ........... (pin 3), 1=High, 0=Low (true) |
||
71 | * . . . . . * . . D2 ........... (pin 4), 1=High, 0=Low (true) |
||
72 | * . . . . * . . . D3 ........... (pin 5), 1=High, 0=Low (true) |
||
73 | * . . . * . . . . D4 ........... (pin 6), 1=High, 0=Low (true) |
||
74 | * . . * . . . . . D5 ........... (pin 7), 1=High, 0=Low (true) |
||
75 | * . * . . . . . . D6 ........... (pin 8), 1=High, 0=Low (true) |
||
76 | * * . . . . . . . D7 ........... (pin 9), 1=High, 0=Low (true) |
||
77 | * |
||
78 | * Status Register (base + 1) ...... inputs |
||
79 | * |
||
80 | * 7 6 5 4 3 2 1 0 |
||
81 | * . . . . . * * * Undefined |
||
82 | * . . . . * . . . Error ........ (pin 15), high=1, low=0 (true) |
||
83 | * . . . * . . . . Selected ..... (pin 13), high=1, low=0 (true) |
||
84 | * . . * . . . . . No paper ..... (pin 12), high=1, low=0 (true) |
||
85 | * . * . . . . . . Ack .......... (pin 10), high=1, low=0 (true) |
||
86 | * * . . . . . . . Busy ......... (pin 11), high=0, low=1 (inverted) |
||
87 | * |
||
88 | * Control Register (base + 2) ..... outputs |
||
89 | * |
||
90 | * 7 6 5 4 3 2 1 0 |
||
91 | * . . . . . . . * Strobe ....... (pin 1), 1=low, 0=high (inverted) |
||
92 | * . . . . . . * . Auto Feed .... (pin 14), 1=low, 0=high (inverted) |
||
93 | * . . . . . * . . Initialize ... (pin 16), 1=high, 0=low (true) |
||
94 | * . . . . * . . . Select ....... (pin 17), 1=low, 0=high (inverted) |
||
95 | * * * * * . . . . Unused |
||
96 | * |
||
97 | * Pins 18-25 are ground. |
||
98 | ********************************************************************************************/ |
||
99 | |||
100 | #include <drivers/parport.h> |
||
101 | |||
102 | |||
103 | void ppSetDataPin(int state, PIN_MASK pin) |
||
104 | { |
||
105 | BYTE port; |
||
106 | port=ppReadDataByte(); |
||
107 | switch (state) |
||
108 | { |
||
109 | case PIN_OFF: port &= ~pin; |
||
110 | case PIN_ON: port |= pin; |
||
111 | } |
||
112 | ppSetDataByte(port); |
||
113 | } |
||
114 | |||
115 | |||
116 | void ppSetCtrlPin(int state, PIN_MASK pin) |
||
117 | { |
||
118 | BYTE port; |
||
119 | port=ppReadCtrlByte(); |
||
120 | switch (state) |
||
121 | { |
||
122 | case PIN_OFF: port &= ~pin; |
||
123 | case PIN_ON: port |= pin; |
||
124 | } |
||
125 | ppSetCtrlByte(port); |
||
126 | } |
||
127 |