Reply by Jacob Christ November 4, 20022002-11-04
No, it's still disturbing, but for a different reason now. Thanks
for the insight.

Jacob

--- In motoroladsp@y..., "Leonard N. Elevich"
<leonard.n.elevich@m...> wrote:
> There is nothing disturbing about it. Most of the SDK APIs are
optimized
> with preprocessor (macros). Unfortunately, unless you have tools
> support, it is very difficult to follow and debug preprocessor
code. In
> GPIO driver case:
>
> ioctl(FileDesc, GPIO_TOGGLE, gpioPin(B,0))
>
> will be translated into:
>
> ioctlGPIO_TOGGLE(FD, gpio(B,0)) (see io.h header file)
>
> which translates to:
>
> gpioIoctl(FD, GPIO_TOGGLE, gpio(B,0)) (see gpiodrvIO.h)
>
> which translates to:
>
> gpioIoctlGPIO_TOGGLE(gpio(B,0)) (see gpiodrv.h)
>
> which translates to:
>
> periphBitChagne(...code...)
>
> which will be translated into a single asm instruction. > From the above sequence you can see that File Descriptor for the
GPIO
> driver is not needed by the driver's optimized implementation, so
it is
> dropped in one of the macro translations. In this case all of the
useful
> information is encoded in the gpioPin() macro, which is propagated
> through all macro expansions.
>
> Leonard
>
> -----Original Message-----
> From: Jacob Christ [mailto:jacob@p...]
> Sent: Friday, November 01, 2002 4:26 PM
> To: motoroladsp@y...
> Subject: [motoroladsp] Scope Problem
>
> CodeWarrior 5.02 for DSP56800
>
> I noticed something quite disturbing today. The following code
> compiles and works!
>
> ///////////////////////////////////////////////////////////
> #include "bsp.h"
> #include "gpio.h"
>
> ///////////////////////////////////////////////////////////
> void foo(void);
> void foo(void)
> {
> ioctl(I_should_case_an_error_becuase_Im_undefined, GPIO_TOGGLE,
> gpioPin(B,0));
> }
>
> ///////////////////////////////////////////////////////////
> int main()
> {
> int PortB;
>
> PortB = open(BSP_DEVICE_NAME_GPIO_B, NULL);
>
> ioctl(PortB, GPIO_SETAS_GPIO, gpioPin(B,0));
> ioctl(PortB, GPIO_SETAS_OUTPUT, gpioPin(B,0));
>
> foo();
>
> close(PortB);
> } >



Reply by Leonard N. Elevich November 4, 20022002-11-04
There is nothing disturbing about it. Most of the SDK APIs are optimized
with preprocessor (macros). Unfortunately, unless you have tools
support, it is very difficult to follow and debug preprocessor code. In
GPIO driver case:

ioctl(FileDesc, GPIO_TOGGLE, gpioPin(B,0))

will be translated into:

ioctlGPIO_TOGGLE(FD, gpio(B,0)) (see io.h header file)

which translates to:

gpioIoctl(FD, GPIO_TOGGLE, gpio(B,0)) (see gpiodrvIO.h)

which translates to:

gpioIoctlGPIO_TOGGLE(gpio(B,0)) (see gpiodrv.h)

which translates to:

periphBitChagne(...code...)

which will be translated into a single asm instruction. From the above sequence you can see that File Descriptor for the GPIO
driver is not needed by the driver's optimized implementation, so it is
dropped in one of the macro translations. In this case all of the useful
information is encoded in the gpioPin() macro, which is propagated
through all macro expansions.

Leonard

-----Original Message-----
From: Jacob Christ [mailto:]
Sent: Friday, November 01, 2002 4:26 PM
To:
Subject: [motoroladsp] Scope Problem

CodeWarrior 5.02 for DSP56800

I noticed something quite disturbing today. The following code
compiles and works!

///////////////////////////////////////////////////////////
#include "bsp.h"
#include "gpio.h"

///////////////////////////////////////////////////////////
void foo(void);
void foo(void)
{
ioctl(I_should_case_an_error_becuase_Im_undefined, GPIO_TOGGLE,
gpioPin(B,0));
}

///////////////////////////////////////////////////////////
int main()
{
int PortB;

PortB = open(BSP_DEVICE_NAME_GPIO_B, NULL);

ioctl(PortB, GPIO_SETAS_GPIO, gpioPin(B,0));
ioctl(PortB, GPIO_SETAS_OUTPUT, gpioPin(B,0));

foo();

close(PortB);
}
_____________________________________
Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all"
if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/



Reply by Johnson, Jerry November 4, 20022002-11-04
I have also previously noticed that some of the macros involved in decoding the Ioctl functions do not use the file handle.  I am not sure when this "Error" showed up in the SDK code, or perhaps it has always been there.
 
Jerry.
-----Original Message-----
From: Jacob Christ [mailto:j...@pontech.com]
Sent: Friday, November 01, 2002 5:26 PM
To: m...@yahoogroups.com
Subject: [motoroladsp] Scope Problem

CodeWarrior 5.02 for DSP56800

I noticed something quite disturbing today.  The following code
compiles and works!

///////////////////////////////////////////////////////////
#include "bsp.h"
#include "gpio.h"

///////////////////////////////////////////////////////////
void foo(void);
void foo(void)
{
   ioctl(I_should_case_an_error_becuase_Im_undefined, GPIO_TOGGLE,
gpioPin(B,0));
}

///////////////////////////////////////////////////////////
int main()
{
   int            PortB;

   PortB = open(BSP_DEVICE_NAME_GPIO_B, NULL);

   ioctl(PortB, GPIO_SETAS_GPIO, gpioPin(B,0));
   ioctl(PortB, GPIO_SETAS_OUTPUT, gpioPin(B,0));

   foo();

   close(PortB);
}


_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:  m...@yahoogroups.com

To Post:  m...@yahoogroups.com

To Leave: m...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3


">Yahoo! Terms of Service.


Reply by Jacob Christ November 2, 20022002-11-02
CodeWarrior 5.02 for DSP56800

I noticed something quite disturbing today. The following code
compiles and works!

///////////////////////////////////////////////////////////
#include "bsp.h"
#include "gpio.h"

///////////////////////////////////////////////////////////
void foo(void);
void foo(void)
{
ioctl(I_should_case_an_error_becuase_Im_undefined, GPIO_TOGGLE,
gpioPin(B,0));
}

///////////////////////////////////////////////////////////
int main()
{
int PortB;

PortB = open(BSP_DEVICE_NAME_GPIO_B, NULL);

ioctl(PortB, GPIO_SETAS_GPIO, gpioPin(B,0));
ioctl(PortB, GPIO_SETAS_OUTPUT, gpioPin(B,0));

foo();

close(PortB);
}