List Info

Thread: Strange shifting variables




Strange shifting variables
country flaguser name
United States
2008-03-28 11:38:49

Sorry ... here is my actual code snippet (if you didn't like the
previous post). As you can see, the printf in the switch statement
and the printf out side the switch statement.

Thank you!
Eric

/* System related include files */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dscsup.h"

typedef struct Reg Reg;
typedef struct Port Port;

/* Declare register info structure */
struct Reg
{
int isConn;
int cfgIdx;
int cfgOff;
int regOff;
int regNum;
int regDir;
};

static asynStatus create(void* ppvt,asynUser* pasynUser,const char*
drvInfo, const char** pptypeName,size_t* psize)
{
int addr;
Reg* preg;
Port* pport = (Port*)ppvt;

asynPrint(pasynUser,ASYN_TRACE_FLOW,"drvDio::create
%s:n&quot;,pport->name);

if( pasynManager->getAddr(pasynUser,&addr) == asynSuccess )
preg = &pport->regs[addr];
else
{ asynPrint(pasynUser,ASYN_TRACE_ERROR,&quot;drvDio::create %s:
getAddr failuren&quot;,pport->name);
return( asynError ); }
asynPrint(pasynUser,ASYN_TRACEIO_FILTER,&quot;drvDio::create %s: asyn -
0x%8.8X, addr - %dn",pport->name,(int)pasynUser,(int)addr);
preg->cfgIdx = addr/COM_DIO_REGS;
switch( pport->type )
{
case DSC_ATHENA:
preg->cfgOff = ATH_OUTB_DIOCR;
if( addr == 0 ){
preg->regOff = ATH_OUTB_DPORT_A;
printf(&quot;preg-&gt;cfgOff=%dn",preg->cfgOff);
printf(&quot;preg-&gt;regOff=%dn",preg->regOff);}
else if( addr == 1 )
preg->regOff = ATH_OUTB_DPORT_B; else if( addr == 2 )
preg->regOff = ATH_OUTB_DPORT_C;
else
{
asynPrint(pasynUser,ASYN_TRACEIO_FILTER,"drvDio::create %s: invalid
register number %dn",pport->name,addr); return( asynError
);
}
break;
}

printf("preg->cfgOff=%dn&quot;,preg-&gt;cfgOff);
printf(&quot;preg-&gt;regOff=%dn",preg->regOff);

__._,_.___
.

__,_._,___
Re: Strange shifting variables
country flaguser name
United States
2008-03-28 12:02:16

Eric,

Are you using -mcpu=arm9 as part of your compiler options?

BTW, It makes a big difference that you're accessing hardware so the
answer to the question is completely different.... This may have
something to do with the TS board. As you probably now know, your
initial posting of code was completely misleading. Help us help you. ;)

HTH

----
Andy

--- In ts-7000%40yahoogroups.com">ts-7000yahoogroups.com, "berryma4" <berryma4...> wrote:
&gt;
> Sorry ... here is my actual code snippet (if you didn't like the
> previous post). As you can see, the printf in the switch statement
> and the printf out side the switch statement.
>
> Thank you!
>; Eric
>;
> /* System related include files */
> #include <math.h>
> #include <stdio.h>
>; #include <stdlib.h>
&gt; #include <string.h>
&gt; #include "dscsup.h"
>
>
>
> typedef struct Reg Reg;
>; typedef struct Port Port;
&gt;
>
> /* Declare register info structure */
> struct Reg
> {
> int isConn;
> int cfgIdx;
> int cfgOff;
> int regOff;
> int regNum;
> int regDir;
> };
>
> static asynStatus create(void* ppvt,asynUser* pasynUser,const char*
&gt; drvInfo, const char** pptypeName,size_t* psize)
&gt; {
> int addr;
&gt; Reg* preg;
&gt; Port* pport = (Port*)ppvt;
>
> asynPrint(pasynUser,ASYN_TRACE_FLOW,";drvDio::create
>; %s:n",pport->;name);
&gt;
> if( pasynManager->getAddr(pasynUser,&addr) == asynSuccess )
> preg = &pport->regs[addr];
&gt; else
>; { asynPrint(pasynUser,ASYN_TRACE_ERROR,&quot;drvDio::create %s:
> getAddr failuren&quot;,pport->name);
> return( asynError ); }
> asynPrint(pasynUser,ASYN_TRACEIO_FILTER,&quot;drvDio::create %s: asyn -
> 0x%8.8X, addr - %dn",pport->name,(int)pasynUser,(int)addr);
> preg->cfgIdx = addr/COM_DIO_REGS;
> switch( pport->type )
> {
> case DSC_ATHENA:
> preg->cfgOff = ATH_OUTB_DIOCR;
>; if( addr == 0 ){
> preg->regOff = ATH_OUTB_DPORT_A;
> printf(&quot;preg-&gt;cfgOff=%dn",preg->cfgOff);
>; printf(&quot;preg-&gt;regOff=%dn",preg->regOff);}
&gt; else if( addr == 1 )
> preg->regOff = ATH_OUTB_DPORT_B; else if( addr == 2 )
> preg->regOff = ATH_OUTB_DPORT_C;
> else
>; {
> asynPrint(pasynUser,ASYN_TRACEIO_FILTER,&quot;drvDio::create %s: invalid
> register number %dn",pport->name,addr); return( asynError
> );
> }
> break;
&gt; }
>
> printf(&quot;preg-&gt;cfgOff=%dn",preg->cfgOff);
>; printf(&quot;preg-&gt;regOff=%dn",preg->regOff);
>;

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )