franta-hg@44
|
1 |
/**
|
franta-hg@44
|
2 |
* LPT signal generator
|
franta-hg@44
|
3 |
* Copyright © 2017 František Kučera (frantovo.cz)
|
franta-hg@44
|
4 |
*
|
franta-hg@44
|
5 |
* This program is free software: you can redistribute it and/or modify
|
franta-hg@44
|
6 |
* it under the terms of the GNU General Public License as published by
|
franta-hg@44
|
7 |
* the Free Software Foundation, either version 3 of the License, or
|
franta-hg@44
|
8 |
* (at your option) any later version.
|
franta-hg@44
|
9 |
*
|
franta-hg@44
|
10 |
* This program is distributed in the hope that it will be useful,
|
franta-hg@44
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
franta-hg@44
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
franta-hg@44
|
13 |
* GNU General Public License for more details.
|
franta-hg@44
|
14 |
*
|
franta-hg@44
|
15 |
* You should have received a copy of the GNU General Public License
|
franta-hg@44
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
franta-hg@44
|
17 |
*/
|
franta-hg@44
|
18 |
|
franta-hg@44
|
19 |
#include <stdlib.h>
|
franta-hg@44
|
20 |
#include <iostream>
|
franta-hg@44
|
21 |
#include <stdio.h>
|
franta-hg@44
|
22 |
#include <math.h>
|
franta-hg@44
|
23 |
#include <sys/io.h>
|
franta-hg@44
|
24 |
#include <unistd.h>
|
franta-hg@44
|
25 |
|
franta-hg@44
|
26 |
using namespace std;
|
franta-hg@44
|
27 |
|
franta-hg@44
|
28 |
// g++ lpt.cpp && ./a.out
|
franta-hg@44
|
29 |
|
franta-hg@44
|
30 |
int main() {
|
franta-hg@44
|
31 |
cout << "LPT!" << endl;
|
franta-hg@44
|
32 |
|
franta-hg@44
|
33 |
//int addr = 0x378; // parport0
|
franta-hg@44
|
34 |
|
franta-hg@44
|
35 |
int addr = 0xe400; // parport1
|
franta-hg@44
|
36 |
|
franta-hg@44
|
37 |
//int addr = 0x278;
|
franta-hg@44
|
38 |
|
franta-hg@44
|
39 |
//int addr = 0xc800;
|
franta-hg@44
|
40 |
|
franta-hg@44
|
41 |
|
franta-hg@44
|
42 |
if (ioperm(addr,1,1)) { fprintf(stderr, "Access denied to %x\n", addr), exit(1); }
|
franta-hg@44
|
43 |
|
franta-hg@44
|
44 |
|
franta-hg@44
|
45 |
for (int i = 0; i < 30; i++) {
|
franta-hg@44
|
46 |
cout << "cyklus" << endl;
|
franta-hg@44
|
47 |
usleep(100*1000);
|
franta-hg@44
|
48 |
outb(0b11111111, addr);
|
franta-hg@44
|
49 |
usleep(10*1000);
|
franta-hg@44
|
50 |
outb(0b00000000, addr);
|
franta-hg@44
|
51 |
}
|
franta-hg@44
|
52 |
|
franta-hg@44
|
53 |
|
franta-hg@44
|
54 |
cout << "hotovo" << endl;
|
franta-hg@44
|
55 |
|
franta-hg@44
|
56 |
|
franta-hg@44
|
57 |
}
|