59 lines
1.1 KiB
C
59 lines
1.1 KiB
C
|
|
/*
|
|
* Include Files
|
|
*
|
|
*/
|
|
#if defined(MATLAB_MEX_FILE)
|
|
#include "tmwtypes.h"
|
|
#include "simstruc_types.h"
|
|
#else
|
|
#include "rtwtypes.h"
|
|
#endif
|
|
|
|
|
|
|
|
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
|
|
|
|
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
|
#define y_width 1
|
|
|
|
/*
|
|
* Create external references here.
|
|
*
|
|
*/
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
|
|
/*
|
|
* Output function
|
|
*
|
|
*/
|
|
void CRC_CheckSum_Outputs_wrapper(const uint8_T *pBuffer,
|
|
const uint16_T *len,
|
|
uint16_T *crc,
|
|
const int_T u_width)
|
|
{
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
uint16_T poly = 0x8408;
|
|
uint8_T carry;
|
|
uint8_T i_bits;
|
|
uint16_T j;
|
|
|
|
crc[0] = 0;
|
|
for (j = 0; j < len[0]; j++) {
|
|
crc[0] = (uint16_T) (crc[0] ^ (uint8_T) pBuffer[j]);
|
|
for (i_bits = 0; i_bits < 8; i_bits++) {
|
|
carry = (uint8_T) (crc[0] & 1);
|
|
crc[0] = (uint16_T) (crc[0] / 2);
|
|
if (carry) {
|
|
crc[0] = (uint16_T) (crc[0] ^ poly);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
}
|
|
|
|
|