Skip to content

Instantly share code, notes, and snippets.

@kwahoo2
Created January 14, 2015 19:48
Show Gist options
  • Save kwahoo2/972c1668f81695ceeb4b to your computer and use it in GitHub Desktop.
Save kwahoo2/972c1668f81695ceeb4b to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <sys/io.h>
#include <sys/perm.h>
#define BASEPORT 0x378
int main(void)
{
int even = 0;
int inp, oldinp;
int i;
ioperm(BASEPORT+1,1,1); //rejestr statusu
for (i=0; i<10000000; i++)
{
inp = inb(BASEPORT+1);
//inp = (uint8_t)inpr << 1; //bity 6:3 są mają być wykorzystywane
if (even == 0)
{
oldinp = (inp & 0b01111000) >> 3;
even = 1;
}
else // składanie do kupy przy parzystych odczytach, nowy odczyt to 4 najbardziej znaczace bity, stary 4 najmniej
{
inp = (inp & 0b01111000) << 1;
inp = inp | oldinp;
printf("%c",inp);
even = 0;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment