#include "mmm2.h"
#include "mmm2_private.h"
/* Block signals (auto storage) */
#pragma DATA_ALIGN(mmm2_B, 8)
BlockIO_mmm2 mmm2_B;
/* Block states (auto storage) */
#pragma DATA_ALIGN(mmm2_DWork, 8)
D_Work_mmm2 mmm2_DWork;
/* Real-time model */
RT_MODEL_mmm2 mmm2_M_;
RT_MODEL_mmm2 *mmm2_M = &mmm2_M_;
/* Model step function */
void mmm2_step(void)
{
{
/* local block i/o variables */ /*ADDED WHEN REMOVING ECHO*/
real_Trtb_Sum[64];
real_T rtb_LMSFilter_o1[64];
real_Trtb_Gain[64];
int32_TbuffStart;
int32_T copy1Size;
int32_T copy2Size;
uint32_T copy2Bytes;
real_T rtb_Delay1[64]; /*REMOVED WHEN REMOVING ECHO*/
real_Trtb_Gain[64];
/* S-Function (sdspdelay): '<Root>/Delay1' */
buffStart = mmm2_DWork.Delay1_CIRC_BUF_IDX % 4000;
if (buffStart<= 3936) {
copy1Size = 64;
copy2Size = 0;
} else {
copy1Size = 4000 - buffStart;
copy2Size = 64 - copy1Size;
}
copy2Bytes = (uint32_T)(copy2Size * (int32_T)MWDSP_SIZEOF_DOUBLE);
memcpy(&rtb_Delay1[0], &mmm2_DWork.Delay1_IC_BUFF[buffStart], (uint32_T)
(copy1Size * (int32_T)MWDSP_SIZEOF_DOUBLE));
memcpy(&rtb_Delay1[copy1Size], &mmm2_DWork.Delay1_IC_BUFF[0], copy2Bytes);
/* Gain: '<Root>/Gain' */
for (buffStart = 0; buffStart< 64; buffStart++) {
rtb_Gain[buffStart] = mmm2_P.Gain_Gain * rtb_Delay1[buffStart];
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */ /*ADDED WHEN REMOVING ECHO*/
{
const real_T ADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;
// Retrieve ADC buffer pointer and invalidate CACHE
blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
mmm3_B.ADC = (real_T)*blkAdcBuffPtr * ADCScaleFactor;
/* Skip Right side for mono mode */
blkAdcBuffPtr += 2;
}
}
/* Sum: '<Root>/Sum' */
for (buffStart = 0; buffStart < 64; buffStart++) {
rtb_Sum[buffStart] = rtb_Gain[buffStart] + mmm3_B.ADC[buffStart];
}
/* Signal Processing Blockset LMS adaptive filter (sdsplms) - '<Root>/LMS Filter' - Output */
/* LMS filter */
{
const boolean_T NeedAdapt = *(boolean_T *)&mmm3_P.Enable_Value;
MWDSP_lms_ay_wn_DD(
(const real_T*)rtb_Sum,
(const real_T*)rtb_Gain,
(const real_T)(*(real_T *)&mmm3_P.LMSFilter_MU_RTP),
(uint32_T *)&mmm3_DWork.LMSFilter_BUFF_IDX_DWORK,
(real_T*)&mmm3_DWork.LMSFilter_IN_BUFFER_DWORK[0],
(real_T*)&mmm3_DWork.LMSFilter_WGT_IC_DWORK[0],
(int_T)10,
(const real_T)(*(real_T *)&mmm3_P.LMSFilter_LEAKAGE_RTP),
(int_T)64,
(int_T)sizeof(real_T),
(real_T*)rtb_LMSFilter_o1,
(real_T*)mmm3_B.LMSFilter_o2
,(const boolean_T)NeedAdapt
);
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */
{
constreal_TADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;
// Retrieve ADC buffer pointer and invalidate CACHE
blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
mmm2_B.ADC = (real_T)*blkAdcBuffPtr * ADCScaleFactor;
/* Skip Right side for mono mode */
blkAdcBuffPtr += 2;
}
}
/* Sum: '<Root>/Sum' */
for (buffStart = 0; buffStart< 64; buffStart++) {
mmm2_B.Sum[buffStart] = rtb_Gain[buffStart] + mmm2_B.ADC[buffStart];
}
/* S-Function Block: <Root>/DAC (c6416dsk_dac) */
{
constreal_TDACScaleFactor = 32768.0;
int_T i;
void *blkDacBuffPtr;
int16_T *outPtr;
blkDacBuffPtr = getDacBuff();
outPtr = (int16_T *) blkDacBuffPtr;
for (i = 0; i < 64; i++) {
/* Left */
*outPtr = (int16_T)(mmm2_B.Sum * DACScaleFactor);
/* Right */
*(outPtr+1) = *outPtr; /* Copy same word to RHS for mono mode. */
outPtr += 2;
}
CACHE_wbL2( (void *) blkDacBuffPtr, 256, CACHE_WAIT );
}
/* Update for S-Function (sdspdelay): '<Root>/Delay1' */
buffStart = mmm2_DWork.Delay1_CIRC_BUF_IDX % 4000;
if (buffStart<= 3936) {
copy1Size = 64;
copy2Size = 0;
} else {
copy1Size = 4000 - buffStart;
copy2Size = 64 - copy1Size;
}
copy2Bytes = (uint32_T)(copy2Size * (int32_T)MWDSP_SIZEOF_DOUBLE);
memcpy(&mmm2_DWork.Delay1_IC_BUFF[buffStart], &mmm2_B.ADC[0], (uint32_T)
(copy1Size * (int32_T)MWDSP_SIZEOF_DOUBLE));
memcpy(&mmm2_DWork.Delay1_IC_BUFF[0], &mmm2_B.ADC[copy1Size], copy2Bytes);
mmm2_DWork.Delay1_CIRC_BUF_IDX = buffStart + 64;
}
}
/* Model initialize function */
void mmm2_initialize(boolean_TfirstTime)
{
(void)firstTime;
/* Registration code */
/* initialize error status */
rtmSetErrorStatus(mmm2_M, (NULL));
/* block I/O */
{
int_T i;
for (i = 0; i < 64; i++) {
mmm2_B.ADC = 0.0;
}
for (i = 0; i < 64; i++) {
mmm2_B.Sum = 0.0;
}
}
/* states (dwork) */
(void) memset((void *)&mmm2_DWork, 0,
sizeof(D_Work_mmm2));
{
int_T i;
for (i = 0; i < 4000; i++) {
mmm2_DWork.Delay1_IC_BUFF = 0.0;
}
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */
codec_init();
/* S-Function Block: <Root>/DAC (c6416dsk_dac) */
/* InitializeConditions for S-Function (sdspdelay): '<Root>/Delay1' */
mmm2_DWork.Delay1_CIRC_BUF_IDX = 0;
memset(&mmm2_DWork.Delay1_IC_BUFF[0], (uint32_T)0.0, 4000U * sizeof(real_T));
/*ADDED WHEN REMOVING ECHO*/
/* Initialization: Signal Processing Blockset LMS adaptive filter (sdsplms) - '<Root>/LMS Filter' */
/* reset weight buffer: copy Weight IC from RTP to Weight IC buffer (DWork) */
{
/* Initial condition for filter taps is a scalar */
int_T i;
for (i = 0; i < 10; i++) {
mmm3_DWork.LMSFilter_WGT_IC_DWORK = mmm3_ConstP.pooled1;
}
}
}
/* Model terminate function */
void mmm2_terminate(void)
- - - Updated - - -
#include "mmm2.h"
#include "mmm2_private.h"
/* Block signals (auto storage) */
#pragma DATA_ALIGN(mmm2_B, 8)
BlockIO_mmm2 mmm2_B;
/* Block states (auto storage) */
#pragma DATA_ALIGN(mmm2_DWork, 8)
D_Work_mmm2 mmm2_DWork;
/* Real-time model */
RT_MODEL_mmm2 mmm2_M_;
RT_MODEL_mmm2 *mmm2_M = &mmm2_M_;
/* Model step function */
void mmm2_step(void)
{
{
/* local block i/o variables */ /*ADDED WHEN REMOVING ECHO*/
real_Trtb_Sum[64];
real_T rtb_LMSFilter_o1[64];
real_Trtb_Gain[64];
int32_TbuffStart;
int32_T copy1Size;
int32_T copy2Size;
uint32_T copy2Bytes;
real_T rtb_Delay1[64]; /*REMOVED WHEN REMOVING ECHO*/
real_Trtb_Gain[64];
/* S-Function (sdspdelay): '<Root>/Delay1' */
buffStart = mmm2_DWork.Delay1_CIRC_BUF_IDX % 4000;
if (buffStart<= 3936) {
copy1Size = 64;
copy2Size = 0;
} else {
copy1Size = 4000 - buffStart;
copy2Size = 64 - copy1Size;
}
copy2Bytes = (uint32_T)(copy2Size * (int32_T)MWDSP_SIZEOF_DOUBLE);
memcpy(&rtb_Delay1[0], &mmm2_DWork.Delay1_IC_BUFF[buffStart], (uint32_T)
(copy1Size * (int32_T)MWDSP_SIZEOF_DOUBLE));
memcpy(&rtb_Delay1[copy1Size], &mmm2_DWork.Delay1_IC_BUFF[0], copy2Bytes);
/* Gain: '<Root>/Gain' */
for (buffStart = 0; buffStart< 64; buffStart++) {
rtb_Gain[buffStart] = mmm2_P.Gain_Gain * rtb_Delay1[buffStart];
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */ /*ADDED WHEN REMOVING ECHO*/
{
const real_T ADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;
// Retrieve ADC buffer pointer and invalidate CACHE
blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
mmm3_B.ADC = (real_T)*blkAdcBuffPtr * ADCScaleFactor;
/* Skip Right side for mono mode */
blkAdcBuffPtr += 2;
}
}
/* Sum: '<Root>/Sum' */
for (buffStart = 0; buffStart < 64; buffStart++) {
rtb_Sum[buffStart] = rtb_Gain[buffStart] + mmm3_B.ADC[buffStart];
}
/* Signal Processing Blockset LMS adaptive filter (sdsplms) - '<Root>/LMS Filter' - Output */
/* LMS filter */
{
const boolean_T NeedAdapt = *(boolean_T *)&mmm3_P.Enable_Value;
MWDSP_lms_ay_wn_DD(
(const real_T*)rtb_Sum,
(const real_T*)rtb_Gain,
(const real_T)(*(real_T *)&mmm3_P.LMSFilter_MU_RTP),
(uint32_T *)&mmm3_DWork.LMSFilter_BUFF_IDX_DWORK,
(real_T*)&mmm3_DWork.LMSFilter_IN_BUFFER_DWORK[0],
(real_T*)&mmm3_DWork.LMSFilter_WGT_IC_DWORK[0],
(int_T)10,
(const real_T)(*(real_T *)&mmm3_P.LMSFilter_LEAKAGE_RTP),
(int_T)64,
(int_T)sizeof(real_T),
(real_T*)rtb_LMSFilter_o1,
(real_T*)mmm3_B.LMSFilter_o2
,(const boolean_T)NeedAdapt
);
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */
{
constreal_TADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;
// Retrieve ADC buffer pointer and invalidate CACHE
blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
mmm2_B.ADC = (real_T)*blkAdcBuffPtr * ADCScaleFactor;
/* Skip Right side for mono mode */
blkAdcBuffPtr += 2;
}
}
/* Sum: '<Root>/Sum' */
for (buffStart = 0; buffStart< 64; buffStart++) {
mmm2_B.Sum[buffStart] = rtb_Gain[buffStart] + mmm2_B.ADC[buffStart];
}
/* S-Function Block: <Root>/DAC (c6416dsk_dac) */
{
constreal_TDACScaleFactor = 32768.0;
int_T i;
void *blkDacBuffPtr;
int16_T *outPtr;
blkDacBuffPtr = getDacBuff();
outPtr = (int16_T *) blkDacBuffPtr;
for (i = 0; i < 64; i++) {
/* Left */
*outPtr = (int16_T)(mmm2_B.Sum * DACScaleFactor);
/* Right */
*(outPtr+1) = *outPtr; /* Copy same word to RHS for mono mode. */
outPtr += 2;
}
CACHE_wbL2( (void *) blkDacBuffPtr, 256, CACHE_WAIT );
}
/* Update for S-Function (sdspdelay): '<Root>/Delay1' */
buffStart = mmm2_DWork.Delay1_CIRC_BUF_IDX % 4000;
if (buffStart<= 3936) {
copy1Size = 64;
copy2Size = 0;
} else {
copy1Size = 4000 - buffStart;
copy2Size = 64 - copy1Size;
}
copy2Bytes = (uint32_T)(copy2Size * (int32_T)MWDSP_SIZEOF_DOUBLE);
memcpy(&mmm2_DWork.Delay1_IC_BUFF[buffStart], &mmm2_B.ADC[0], (uint32_T)
(copy1Size * (int32_T)MWDSP_SIZEOF_DOUBLE));
memcpy(&mmm2_DWork.Delay1_IC_BUFF[0], &mmm2_B.ADC[copy1Size], copy2Bytes);
mmm2_DWork.Delay1_CIRC_BUF_IDX = buffStart + 64;
}
}
/* Model initialize function */
void mmm2_initialize(boolean_TfirstTime)
{
(void)firstTime;
/* Registration code */
/* initialize error status */
rtmSetErrorStatus(mmm2_M, (NULL));
/* block I/O */
{
int_T i;
for (i = 0; i < 64; i++) {
mmm2_B.ADC = 0.0;
}
for (i = 0; i < 64; i++) {
mmm2_B.Sum = 0.0;
}
}
/* states (dwork) */
(void) memset((void *)&mmm2_DWork, 0,
sizeof(D_Work_mmm2));
{
int_T i;
for (i = 0; i < 4000; i++) {
mmm2_DWork.Delay1_IC_BUFF = 0.0;
}
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */
codec_init();
/* S-Function Block: <Root>/DAC (c6416dsk_dac) */
/* InitializeConditions for S-Function (sdspdelay): '<Root>/Delay1' */
mmm2_DWork.Delay1_CIRC_BUF_IDX = 0;
memset(&mmm2_DWork.Delay1_IC_BUFF[0], (uint32_T)0.0, 4000U * sizeof(real_T));
/*ADDED WHEN REMOVING ECHO*/
/* Initialization: Signal Processing Blockset LMS adaptive filter (sdsplms) - '<Root>/LMS Filter' */
/* reset weight buffer: copy Weight IC from RTP to Weight IC buffer (DWork) */
{
/* Initial condition for filter taps is a scalar */
int_T i;
for (i = 0; i < 10; i++) {
mmm3_DWork.LMSFilter_WGT_IC_DWORK = mmm3_ConstP.pooled1;
}
}
}
/* Model terminate function */
void mmm2_terminate(void)
- - - Updated - - -
#include "mmm2.h"
#include "mmm2_private.h"
/* Block signals (auto storage) */
#pragma DATA_ALIGN(mmm2_B, 8)
BlockIO_mmm2 mmm2_B;
/* Block states (auto storage) */
#pragma DATA_ALIGN(mmm2_DWork, 8)
D_Work_mmm2 mmm2_DWork;
/* Real-time model */
RT_MODEL_mmm2 mmm2_M_;
RT_MODEL_mmm2 *mmm2_M = &mmm2_M_;
/* Model step function */
void mmm2_step(void)
{
{
/* local block i/o variables */ /*ADDED WHEN REMOVING ECHO*/
real_Trtb_Sum[64];
real_T rtb_LMSFilter_o1[64];
real_Trtb_Gain[64];
int32_TbuffStart;
int32_T copy1Size;
int32_T copy2Size;
uint32_T copy2Bytes;
real_T rtb_Delay1[64]; /*REMOVED WHEN REMOVING ECHO*/
real_Trtb_Gain[64];
/* S-Function (sdspdelay): '<Root>/Delay1' */
buffStart = mmm2_DWork.Delay1_CIRC_BUF_IDX % 4000;
if (buffStart<= 3936) {
copy1Size = 64;
copy2Size = 0;
} else {
copy1Size = 4000 - buffStart;
copy2Size = 64 - copy1Size;
}
copy2Bytes = (uint32_T)(copy2Size * (int32_T)MWDSP_SIZEOF_DOUBLE);
memcpy(&rtb_Delay1[0], &mmm2_DWork.Delay1_IC_BUFF[buffStart], (uint32_T)
(copy1Size * (int32_T)MWDSP_SIZEOF_DOUBLE));
memcpy(&rtb_Delay1[copy1Size], &mmm2_DWork.Delay1_IC_BUFF[0], copy2Bytes);
/* Gain: '<Root>/Gain' */
for (buffStart = 0; buffStart< 64; buffStart++) {
rtb_Gain[buffStart] = mmm2_P.Gain_Gain * rtb_Delay1[buffStart];
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */ /*ADDED WHEN REMOVING ECHO*/
{
const real_T ADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;
// Retrieve ADC buffer pointer and invalidate CACHE
blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
mmm3_B.ADC = (real_T)*blkAdcBuffPtr * ADCScaleFactor;
/* Skip Right side for mono mode */
blkAdcBuffPtr += 2;
}
}
/* Sum: '<Root>/Sum' */
for (buffStart = 0; buffStart < 64; buffStart++) {
rtb_Sum[buffStart] = rtb_Gain[buffStart] + mmm3_B.ADC[buffStart];
}
/* Signal Processing Blockset LMS adaptive filter (sdsplms) - '<Root>/LMS Filter' - Output */
/* LMS filter */
{
const boolean_T NeedAdapt = *(boolean_T *)&mmm3_P.Enable_Value;
MWDSP_lms_ay_wn_DD(
(const real_T*)rtb_Sum,
(const real_T*)rtb_Gain,
(const real_T)(*(real_T *)&mmm3_P.LMSFilter_MU_RTP),
(uint32_T *)&mmm3_DWork.LMSFilter_BUFF_IDX_DWORK,
(real_T*)&mmm3_DWork.LMSFilter_IN_BUFFER_DWORK[0],
(real_T*)&mmm3_DWork.LMSFilter_WGT_IC_DWORK[0],
(int_T)10,
(const real_T)(*(real_T *)&mmm3_P.LMSFilter_LEAKAGE_RTP),
(int_T)64,
(int_T)sizeof(real_T),
(real_T*)rtb_LMSFilter_o1,
(real_T*)mmm3_B.LMSFilter_o2
,(const boolean_T)NeedAdapt
);
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */
{
constreal_TADCScaleFactor = 1.0 / 32768.0;
int_T i;
int16_T *blkAdcBuffPtr;
// Retrieve ADC buffer pointer and invalidate CACHE
blkAdcBuffPtr = (int16_T *) getAdcBuff();
CACHE_wbInvL2( (void *) blkAdcBuffPtr, 256, CACHE_WAIT );
for (i = 0; i < 64; i++) {
mmm2_B.ADC = (real_T)*blkAdcBuffPtr * ADCScaleFactor;
/* Skip Right side for mono mode */
blkAdcBuffPtr += 2;
}
}
/* Sum: '<Root>/Sum' */
for (buffStart = 0; buffStart< 64; buffStart++) {
mmm2_B.Sum[buffStart] = rtb_Gain[buffStart] + mmm2_B.ADC[buffStart];
}
/* S-Function Block: <Root>/DAC (c6416dsk_dac) */
{
constreal_TDACScaleFactor = 32768.0;
int_T i;
void *blkDacBuffPtr;
int16_T *outPtr;
blkDacBuffPtr = getDacBuff();
outPtr = (int16_T *) blkDacBuffPtr;
for (i = 0; i < 64; i++) {
/* Left */
*outPtr = (int16_T)(mmm2_B.Sum * DACScaleFactor);
/* Right */
*(outPtr+1) = *outPtr; /* Copy same word to RHS for mono mode. */
outPtr += 2;
}
CACHE_wbL2( (void *) blkDacBuffPtr, 256, CACHE_WAIT );
}
/* Update for S-Function (sdspdelay): '<Root>/Delay1' */
buffStart = mmm2_DWork.Delay1_CIRC_BUF_IDX % 4000;
if (buffStart<= 3936) {
copy1Size = 64;
copy2Size = 0;
} else {
copy1Size = 4000 - buffStart;
copy2Size = 64 - copy1Size;
}
copy2Bytes = (uint32_T)(copy2Size * (int32_T)MWDSP_SIZEOF_DOUBLE);
memcpy(&mmm2_DWork.Delay1_IC_BUFF[buffStart], &mmm2_B.ADC[0], (uint32_T)
(copy1Size * (int32_T)MWDSP_SIZEOF_DOUBLE));
memcpy(&mmm2_DWork.Delay1_IC_BUFF[0], &mmm2_B.ADC[copy1Size], copy2Bytes);
mmm2_DWork.Delay1_CIRC_BUF_IDX = buffStart + 64;
}
}
/* Model initialize function */
void mmm2_initialize(boolean_TfirstTime)
{
(void)firstTime;
/* Registration code */
/* initialize error status */
rtmSetErrorStatus(mmm2_M, (NULL));
/* block I/O */
{
int_T i;
for (i = 0; i < 64; i++) {
mmm2_B.ADC = 0.0;
}
for (i = 0; i < 64; i++) {
mmm2_B.Sum = 0.0;
}
}
/* states (dwork) */
(void) memset((void *)&mmm2_DWork, 0,
sizeof(D_Work_mmm2));
{
int_T i;
for (i = 0; i < 4000; i++) {
mmm2_DWork.Delay1_IC_BUFF = 0.0;
}
}
/* S-Function Block: <Root>/ADC (c6416dsk_adc) */
codec_init();
/* S-Function Block: <Root>/DAC (c6416dsk_dac) */
/* InitializeConditions for S-Function (sdspdelay): '<Root>/Delay1' */
mmm2_DWork.Delay1_CIRC_BUF_IDX = 0;
memset(&mmm2_DWork.Delay1_IC_BUFF[0], (uint32_T)0.0, 4000U * sizeof(real_T));
/*ADDED WHEN REMOVING ECHO*/
/* Initialization: Signal Processing Blockset LMS adaptive filter (sdsplms) - '<Root>/LMS Filter' */
/* reset weight buffer: copy Weight IC from RTP to Weight IC buffer (DWork) */
{
/* Initial condition for filter taps is a scalar */
int_T i;
for (i = 0; i < 10; i++) {
mmm3_DWork.LMSFilter_WGT_IC_DWORK = mmm3_ConstP.pooled1;
}
}
}
/* Model terminate function */
void mmm2_terminate(void)