ts-7000
[Top] [All Lists]

[ts-7000] TS-7500 xuart & sbus_peek16/sbus_poke16 (segfault fix)

To:
Subject: [ts-7000] TS-7500 xuart & sbus_peek16/sbus_poke16 (segfault fix)
From: "denimskater" <>
Date: Thu, 11 Mar 2010 22:09:28 -0000
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/

<Prev in Thread] Current Thread [Next in Thread>
  • [ts-7000] TS-7500 xuart & sbus_peek16/sbus_poke16 (segfault fix), denimskater <=
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU