If you try to mix code from the xuartctl sample and the sbus sample, and use
sbus_peek16 and sbus_poke16 instead of the cvpeek16/cvpoke16 functions, you'll
get a segfault.
Here's the trouble: xuartctl sets the two high address lines and then carefully
doesn't touch them; sbus_peek/poke modifies them. You need to add 0x20 to all
the addresses before calling sbus_peek/poke.
So, replace the xxupeek16, xpeek16, xxupoke16, and xpoke16 functions with these
(and either put the #defines before the #include "xuartcore.c", or replace them
with these #defines):
static void
xxupoke16(struct xuartcore *xu, unsigned int adr, unsigned short val) {
adr += 0x20;
sbus_poke16(adr, val);
}
static unsigned short
xxupeek16(struct xuartcore *xu, unsigned int adr) {
adr += 0x20;
return(sbus_peek16(adr));
}
static unsigned int memwindow_adr = 0;
static void xpoke16(volatile unsigned short *adr, unsigned short val) {
if (memwindow_adr != (unsigned int)adr) {
sbus_poke16(0x3c, (unsigned int)adr);
}
memwindow_adr = (unsigned int)adr + 2;
sbus_poke16(0x3e, val);
}
static unsigned short xpeek16(volatile unsigned short *adr) {
if (memwindow_adr != (unsigned int)adr) {
sbus_poke16(0x3c, (unsigned int)adr);
}
memwindow_adr = (unsigned int)adr + 2;
return sbus_peek16(0x3e);
}
#define XUPOKE16(x, y, z) xxupoke16((x), (y), (z))
#define XUPEEK16(x, y) xxupeek16((x), (y))
#define PEEK16(x) xpeek16((x))
#define POKE16(x, y) xpoke16((x), (y))
--DTVZ
------------------------------------
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/
|