Code Conversion Help for S12XE

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Code Conversion Help for S12XE

跳至解决方案
1,035 次查看
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 !!       

}

标签 (1)
0 项奖励
回复
1 解答
900 次查看
rayhall
Contributor V

I have solved the problem.

The complier did not like vi++;

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

Ray.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
900 次查看
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 项奖励
回复
901 次查看
rayhall
Contributor V

I have solved the problem.

The complier did not like vi++;

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

Ray.

0 项奖励
回复