This is basic stuff, but I can't quite see how to set values on the I/O pins for a expansion board. I have the TS-DOI24
mated to the TS-7240-V2
The DIO24 manual mentions BASE+5 for say, the PortA register and I have jumpers off so address selection I/O address is "Base+0x100". Is Base the PC/104 base for 7250? I've noticed for EVGPIO documentation, say I/O 9 is PC104_A1... does that have anything to do with TS-DIO24's A1?
I'd love to use evgpio.c or tshwctl.c. I've tried compiling these with the first few lines changed to use a new address. Like changing the syscon address from 0x80004000 to 0x80004100, but that seems wrong (and doesn't work!).
So any pointers? I'd imagine this is a one-line code change, or there's already a .c program out there to toggle a pin?
Good morning Rick,
I see your confusion. There are two PC104 chapters in the TS-7250-V2 manual. I think you're looking for this section here:
The default PC104 base address for an 8-bit peripheral (such as the DIO24) is 0x81008000.
Note this is different from tshwctl and does not use the evgpio core. The PC104 peripheral's registers will be accessed in code using some form of mmap()... for example:
This code will set up a memory map to the 16-bit PC104 space, read and output the Board ID at offset 0x100, and exit.
int id = 0;
volatile uint16_t *membase = NULL;
int mem = 0;
const int offset = 0x100;
mem = open("/dev/mem", O_RDWR|O_SYNC);
membase = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_SHARED, mem, 0x80008000);
id = membase[offset/2];
I appreciate the code! I'm making progress but got stuck for most of the day on this now: I think I'm missing something that I'm sure you can clear up - it may be related to that comment you made about the bus cycles. It looks like I'm only reading even registers, and I can't seem to set any permanently (note output line A is different than line C, but it's the same code). Is there a specific wait I need to do?
I really appreciate your time - I'm sure this is a quick fix. And your example code had 0x80008000, so I'm using that, if I use 0x81008000 (the DIO being 8 bit...) the results are the same except that 0xF6 is always just a mirror of the lower byte (so Base+0 = 0x5454, e.g.)
Image is output with JP4 set to on, so we expect 0x18 in Base+2 and 0x02 in Base+4.
Ah, I think I got it. I changed the code to use uint8_t instead of uint16_t and stopped dividing by 2.