📄 scomdemohecgen_wrapper.c
字号:
/*
*
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: BASIC, 1.0 ---
*
* This file is a wrapper S-function produced by the S-Function
* Builder which only recognizes certain fields. Changes made
* outside these fields will be lost the next time the block is
* used to load, edit, and resave this file. This file will be overwritten
* by the S-function Builder block. If you want to edit this file by hand,
* you must change it only in the area defined as:
*
* %%%-SFUNWIZ_wrapper_XXXXX_Changes_BEGIN
* Your Changes go here
* %%%-SFUNWIZ_wrapper_XXXXXX_Changes_END
*
* For better compatibility with the Real-Time Workshop, the
* "wrapper" S-function technique is used. This is discussed
* in the Real-Time Workshop User's Manual in the Chapter titled,
* "Wrapper S-functions".
*
* Created: Mon Aug 20 15:23:09 2001
*/
/*
* Include Files
*
*/
#include "tmwtypes.h"
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#include <math.h>
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Output functions
*
*/
void scomdemohecgen_Outputs_wrapper(const real_T *u,
real_T *y,
const real_T *param0, const int_T p_width0,
const int_T y_width, const int_T u_width)
{
/* This Outputs function allows for 1 input and 1 output
* signal of any width, any number of discrete states and
* parameters, all of type real_T.
*
* If you need the FULL POWER of the S-function interface,
* familiarize yourself with the full template file at:
*
* matlabroot/simulink/src/sfuntmpl_doc.c
*
* and the "Writing S-functions" manual in the documentation.
*/
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
int crc_n = 8;
int i = 0;
uint_T in_bit = 0x0;
uint_T fb_bit = 0x0;
unsigned long buff = 0x0;
unsigned long gen_poly = 0xA7; /* polynomial x^8+x^7+x^5+x^2+x^1+1 */
/* Load UAP into register */
for( i=0; i<crc_n; i++){
in_bit = ((uint_T)(param0[crc_n-i-1]) & 0x1);
buff <<= 1;
buff += in_bit;
}
/* Load input into register (feedback bit is input xor-ed with output bit */
for( i=0; i<u_width; i++){
in_bit = ((uint_T)(u[i]) & 0x1);
fb_bit = in_bit ^ ((buff >> (crc_n - 1)) & 0x1);
buff <<= 1;
buff ^= (fb_bit * gen_poly);
}
/* Break feedback loop and output HEC */
for ( i=0; i < crc_n; i++){
y[i] = (buff >> (crc_n-1-i)) & 0x1;
buff >>= 1;
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Updates function
*
*/
void scomdemohecgen_Update_wrapper(const real_T *u,
const real_T *y,
const real_T *param0, const int_T p_width0,
const int_T y_width, const int_T u_width)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
/*
* Code example
* xD[0] = u[0];
*/
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Derivatives function
*
*/
void scomdemohecgen_Derivatives_wrapper(const real_T *u,
const real_T *y, real_T *dx,
const real_T *param0, const int_T p_width0,
const int_T y_width, const int_T u_width)
{
/* %%%-SFUNWIZ_wrapper_Derivatives_Changes_BEGIN --- EDIT HERE TO _END */
/*
* Code example
* dx[0] = xC[0];
*/
/* %%%-SFUNWIZ_wrapper_Derivatives_Changes_END --- EDIT HERE TO _BEGIN */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -