Code Conversion Help for S12XE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code Conversion Help for S12XE

Jump to solution
636 Views
rayhall
Contributor V

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=&sector[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=&sector[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 !!       

}

Labels (1)
0 Kudos
Reply
1 Solution
501 Views
rayhall
Contributor V

I have solved the problem.

The complier did not like vi++;

I replaced it with  vi = (char*)vi + 1;

Ray.

View solution in original post

0 Kudos
Reply
2 Replies
501 Views
RadekS
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
502 Views
rayhall
Contributor V

I have solved the problem.

The complier did not like vi++;

I replaced it with  vi = (char*)vi + 1;

Ray.

0 Kudos
Reply