General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
-
ardiansyah_mrit
- Posts: 10
- Joined: Sun Oct 09, 2011 6:14 am
-
Contact:
Post
by ardiansyah_mrit » Tue Oct 25, 2011 6:41 am
any one i need help about below meaning code :
Code: Select all
uchar usbFunctionRead(uchar *data, uchar len) //??????????????? *data dan len
{
if(len > bytesRemaining)
len = bytesRemaining;
eeprom_read_block(data, (uchar *)0 + currentAddress, len);
currentAddress += len;
bytesRemaining -= len;
return len;
}
i'm not understand about "(uchar *data, uchar len)"..??
-
Daid
- Rank 2
- Posts: 55
- Joined: Mon Apr 18, 2011 12:19 pm
Post
by Daid » Tue Oct 25, 2011 12:05 pm
Then learn a bit about C before you touch micro-controllers.
-
1.21Gigawatts
- Posts: 9
- Joined: Thu Nov 10, 2011 12:11 am
Post
by 1.21Gigawatts » Thu Nov 10, 2011 1:34 am
uchar is how some compilers designate an unsigned char, equivalent to winavr's uint8_t.
Does that help?
-
ulao
- Rank 4
- Posts: 481
- Joined: Mon Aug 25, 2008 8:45 pm
Post
by ulao » Thu Nov 10, 2011 3:12 am
uchar *data : This is nothing more then a pointer to address in memory. uchar ( unsigned char ) is the size you need to hold that address. Pointers are a big part of C, I suggest you read up on them.
uchar len : Here we are setting len to a type uchar ( not a pointer this time ). len will be the length of the data in this case.
So you use data to point to the data in memory and len to figure out how long the data goes.
If len was 2
data -> [byte 0][byte 1]
-
ardiansyah_mrit
- Posts: 10
- Joined: Sun Oct 09, 2011 6:14 am
-
Contact:
Post
by ardiansyah_mrit » Thu Nov 10, 2011 9:58 am
thank's all for reply's,
i undenrstand now, but can you explain to me about uchar len in this function and uchar len in usbfunctionWrite()..??
is there any difference between these two variables ?
what the meaning about
len was 2 => [byte 0] [byte 1]...??
best regard
-
1.21Gigawatts
- Posts: 9
- Joined: Thu Nov 10, 2011 12:11 am
Post
by 1.21Gigawatts » Thu Nov 10, 2011 6:45 pm
Oh, you really do need to do some reading about the C language before you go any further. Particularly, your question about the two len variables points to a lack of understanding about a variable's scope. There's plenty of tutorials on the web, or you can get any number of books. But you're going to be lost if you just try to dice into this code.