VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 123[4] ]
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 ]


[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.