Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

Re: static uchar usbIsReset; /* = 0; USB bus is in reset p

$
0
0
blargg wrote:I couldn't find that variable in several of the 2008 versions. From the comment, it looks more like it's just trying to emphasize that static objects in C are initialized to 0 if no initializer is present. In other versions there's a local static for calling a user-defined reset handler only once, and the variable is used to keep track of whether it's been called, so maybe this is for that purpose.


Thanks blargg. Let's change usbIsReset by another variable: usbDeviceId, which may be present in newer versions. This variable is so declared in usbdrv.c:
volatile char      usbDeviceId;

And my question is now another one: this variable needs to be zero when control first enters the external interrupt service routine, but it is set to zero nowhere in either usbdrv.c or usbdrvasm.S. It is no other thing than the device address, which must be zero when starting enumeration. How can the declaration above make the variable initial value zero? In C, all uninitialized global variables are zero when the program is loaded (from disk). But here, after turning on power, the RAM is in an aleatory state!

The sources I am using are not among the versions listed in this site. I am, however, giving you a link, http://www.filedropper.com/takefuji-213, coded in 2004 by Christian Starkjohann, except the app, da.c, which by its very simplicity is easy to analyze, in case you care to skim it.

Viewing all articles
Browse latest Browse all 4524

Trending Articles