Hi Craig,
> I have been going through the sample programs and
> documentation for the TS-7xxx boards while writing
> code to access the ADC and GPIO pins of the TS7400.
> Some of the sample programs use pointers to access
> the ports, others use PEEK and POKE routines from
> peekpoke.h
>
> It looks like the ADC access is all 32-bit, and
> the GPIO is all 8-bit. Is there any reason to use
> PEEK/POKE, or will pointer access work reliably?
Pointer access will most likely work.
The PEEK/POKE routines are the most conservative
approach. They ensure exactly the right processor
instruction is used.
Be wary of bit-fields though. For example, I had an
experience where I'd taken some existing code for
a TI DSP that used bit-fields, and ran it through
gcc for an x86. Even though bit-fields use the
int type in their definition gcc ends up using
byte assembly instructions. In this application,
the registers were 32-bits PCI registers, and
so 8-bit writes caused the 3 upper bytes to contain
garbage.
In Linux drivers, you'll never see a pointer access.
The accesses are either readl()/writel() little-endian
PCI accesses, or out_le32()/in_le32(), out_be32/in_be32()
etc for I/O accesses.
So if you are writing drivers from user-space that might
migrate into kernel space, I'd recommend not using
PEEK/POKE, but renaming them consistent with the
Linux kernel functions, and then working with those.
However, when just hacking code use of pointers is
fine, just remember to check the assembly if you're
getting weird problems.
Dave
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|