>>This includes 20 DIOs and that is what I want to know about. How would
>>I go about writting c++ code to access the DIOs.
>>
>>I'm new to C++ and perhaps I ought not bo worried about this end of
>>the field yet but I am. I'm guessing I can use fscan to read info and
>>maybe fprint to write data.
The I/O ports are mapped into memory area. You "open" /dev/mem, then read
and write using pointers. Here's a snippet from button.c which I believe is
in the Files section.
unsigned char *start;
int fd = open("/dev/mem", O_RDWR);
start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE,
MAP_SHARED, fd, 0x80840000);
PBDR = (unsigned int *)(start + 0x04); // port b
PBDDR = (unsigned int *)(start + 0x14); // port b dir. register
PEDR = (unsigned int *)(start + 0x20); // port e data
PEDDR = (unsigned int *)(start + 0x24); // port e dir. register
GPIOBDB = (unsigned int *)(start + 0xC4); // debounce on port b
*PBDDR = 0xf0; // upper nibble output, lower nibble input
*PEDDR = 0xff; // all output (just 2 bits)
*GPIOBDB = 0x01; // enable debounce on bit 0
state = *PBDR; // read initial state
while (state & 0x01) // wait until button goes low
{
state = *PBDR; // remember bit 0 is pulled up with 4.7k ohm
}
There's more; you have to include some header files. So grab the entire
file and see what you can make it do.
Mike
------
Mike Dodd - Montpelier, VA
http://www.mdodd.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/CFFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|