| Subject: SPIO control(586) |
Author:
Woonsig
|
[
Next Thread |
Previous Thread |
Next Message |
Previous Message
]
Date Posted: 00:12:19 07/12/03 Sat
To test controlling SPIO ports, I have made a simple program based on the gpio-sio.c in the 586-code-apps.zip file from Compulab site.
But I got 'Segmentation fault' at outb command step.
Do I need to make a module level program to control SPIO port ?
If I do, is there any good example for that ?
<<< To test controlling SPIO >>>
#include
#include
#include
void outportb(unsigned short addr, unsigned char val)
{
outb(val, addr);
}
unsigned char inportb(unsigned short addr)
{
return inb(addr);
}
void entercfg()
{
printf("enter: entercfg()\n");
outportb(0x3f0, 0x87);
outportb(0x3f0, 0x87)
printf("exit : entercfg()\n");
}
void exitcfg()
{
printf("enter: exitcfg()\n");
outportb(0x3f0, 0xaa);
printf("exit : exitcfg()\n");
}
void writeSIO(unsigned char ldev, unsigned char reg, unsigned char val)
{
printf("enter: writeSIO(3)\n");
outportb(0x3f0, 0x07);
outportb(0x3f1, ldev);
outportb(0x3f0, reg);
outportb(0x3f1, val);
printf("exit : writeSIO(3)\n");
}
unsigned char writeSIO(unsigned char ldev, unsigned char reg)
{
printf("enter: writeSIO(2)\n");
outportb(0x3f0, 0x07);
outportb(0x3f1, ldev);
outportb(0x3f0, reg);
printf("exit : writeSIO(2)\n");
return inportb(0x3f1);
}
void initSIOcfg()
{
printf("enter: initSIOcfg(0)\n");
entercfg();
writeSIO(7, 0x2a, 0xd8);
writeSIO(7, 0x2b, 0x69);
writeSIO(7, 0x2c, 0x55);
writeSIO(7, 0x60, 0x02);
writeSIO(7, 0x61, 0x90);
writeSIO(7, 0xe1, 0x0);
writeSIO(7, 0xe2, 0x0);
writeSIO(7, 0xe3, 0x0);
writeSIO(7, 0xe4, 0x0);
writeSIO(7, 0xe5, 0x0);
exitcfg();
printf("exit : initSIOcfg(0)\n");
}
int main()
{
initSIOcfg();
while(1)
{
printf("set LSB...");
outportb(0x290, (inportb(0x290) | 0x2));
sleep(1);
printf(" reset LSB\n");
outportb(0x290, (inportb(0x290) & 0xfd));
sleep(1);
}
return 0;
}
[
Next Thread |
Previous Thread |
Next Message |
Previous Message
]
| |