0

µC 中有两个软件,固件和应用程序。从应用程序我想调用在固件中编译的Calculate_Crc。当我直接执行调用时,执行没有成功,代码跳转到其他位置。在那个函数中,我有全局数据和一个子函数。

调用此函数的最安全方式是什么?

我正在使用 Diab 编译器和 C 语言。

            const unsigned long  g_poly_Cst;
            unsigned long  Calculate_Crc32( const void *Src, unsigned char Size, unsigned long Crc, const void *Poly)
            { 
              unsigned long        crc      = ( unsigned long)(crcval); 
              unsigned char      areaSize = Size;             
              g_poly_Cst = *((const unsigned char *)Poly);
              const unsigned char  *data = (*((unsigned char **)&Src_Ptr));          
              unsigned char         bitSize;                                                                  
              while (areaSize != 0)               
                {                                 
                crc ^= ((unsigned long)(*(data++)) << (((sizeof(unsigned long) -1)*8) *((1 << 1)/2)) ); 
                bitSize = 8+1;                    
                while (--bitSize != 0)            
                  {                               
                  if ( (crc & ((unsigned long)((unsigned long)(3 << ((sizeof(unsigned long)*4)-1) ) shift (sizeof(unsigned long)*4))) ) !=0) 
                     crc = (unsigned long)((crc << 1) ^ g_poly_Cst);
                  else                            
                    crc = (unsigned long)(crc << 1);
                  }                               
                areaSize--;                       
                }                     
              }

                Notify_UpperLayer(DONE);                    
                return Crc;                                                               
            }
4

0 回答 0