I am converting code from Atmel AVR to use with the S12XE. The code relates to FAT library. I have most of it converted except for this function.
The problem is (void)*vi=&i; I do not understand what a (void)* is. I get errors like "Indirection applied to non-pointer" and "vi not declared". If I do declare it I still get errors.
Ray.
unsigned long int fat_getNextCluster(unsigned long int oneCluster){
unsigned long int i,j;
// FAT 16**************FAT 16
if(fat.fatType==16){
// i=oneCluster/256
i=oneCluster>>8;; // errechnet den sektor der fat in dem oneCluster ist (rundet immer ab)
// j=(oneCluster-256*i)*2 == 2*oneCluster-512*i
j=(oneCluster<<1)-(i<<9); // errechnet das low byte von oneCluster in dem ausgelesenen sektor der fat (high und low byte enthalten den folge cluster)
if(0==fat_loadSector(i+fat.fatSec)){ // neu laden nicht nötig
i=0;
(void)*vi=&i; // zeiger auf i
bytesOfSec=§or[j]; // zeiger auf puffer
*(unsigned char*)vi=*bytesOfSec; // setzen low byte von i, aus puffer
vi++; // zeigt auf nächst höheres byte in i
bytesOfSec++; // nächst höheres byte in puffer
*(unsigned char*)vi=*bytesOfSec; // setzen von höherem byte in i, aus puffer
return i; // gibt neuen cluster zurück (oder 0xffff)
}
}
// FAT 32**************FAT 32
if(fat.fatType==32){
// i=oneCluster/128
i=oneCluster>>7; // errechnet den sektor der fat in dem oneCluster ist (rundet immer ab)
// j=(oneCluster-128*i)*4 == oneCluster*4-512*i
j=(oneCluster<<2)-(i<<9); // errechnet das low byte von oneCluster in dem ausgelesenen sektor der fat (high und low byte enthalten den folge cluster)
if(0==fat_loadSector(i+fat.fatSec)){ // neu laden nicht nötig
void *vi=&i;
bytesOfSec=§or[j];
*(unsigned char*)vi=*bytesOfSec;
vi++;
bytesOfSec++;
*(unsigned char*)vi=*bytesOfSec;
vi++;
bytesOfSec++;
*(unsigned char*)vi=*bytesOfSec;
vi++;
bytesOfSec++;
*(unsigned char*)vi=*bytesOfSec;
return i;
}
}
return(0); // neuladen des fat sektors, in dem oneCluster ist nötig !!
}
Solved! Go to Solution.
I have solved the problem.
The complier did not like vi++;
I replaced it with vi = (char*)vi + 1;
Ray.
Hi Ray,
The void pointer, also known as the generic pointer, is a special type of pointer that can be pointed at objects of any data type.
For more details, please see for example:
http://stackoverflow.com/questions/4334831/what-is-a-void-pointer-and-what-is-a-null-pointer
http://stackoverflow.com/questions/8530080/what-is-a-void-pointer-in-c
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I have solved the problem.
The complier did not like vi++;
I replaced it with vi = (char*)vi + 1;
Ray.