📄 c2812pwmtest.c
字号:
/*
* File: c2812pwmtest.c
*
* Real-Time Workshop code generated for Simulink model c2812pwmtest.
*
* Model version : 1.102
* Real-Time Workshop file version : 6.3 (R14SP3) 26-Jul-2005
* Real-Time Workshop file generated on : Sat Dec 13 20:42:50 2008
* TLC version : 6.3 (Aug 5 2005)
* C source code generated on : Sat Dec 13 20:42:51 2008
*/
#include "c2812pwmtest.h"
#include "c2812pwmtest_private.h"
/* Block states (auto storage) */
D_Work_c2812pwmtest c2812pwmtest_DWork;
/* Real-time model */
RT_MODEL_c2812pwmtest c2812pwmtest_M_;
RT_MODEL_c2812pwmtest *c2812pwmtest_M = &c2812pwmtest_M_;
/* Model step function */
void c2812pwmtest_step(void)
{
/* local block i/o variables*/
real_T rtb_PulseGenerator;
uint16_T rtb_Add;
/* DiscretePulseGenerator: '<S2>/Pulse Generator' */
rtb_PulseGenerator = ((real_T)c2812pwmtest_DWork.clockTickCounter <
c2812pwmtest_P.PulseGenerator_Duty) && (c2812pwmtest_DWork.clockTickCounter
>= 0L) ? c2812pwmtest_P.PulseGenerator_Amp : 0.0;
if((real_T)c2812pwmtest_DWork.clockTickCounter >=
c2812pwmtest_P.PulseGenerator_Period - 1.0) {
c2812pwmtest_DWork.clockTickCounter = 0L;
} else {
c2812pwmtest_DWork.clockTickCounter = c2812pwmtest_DWork.clockTickCounter +
1L;
}
/* Sum: '<S2>/Add' incorporates:
* DataTypeConversion: '<S2>/Data Type Conversion'
* Constant: '<S2>/Constant'
*/
rtb_Add = (uint16_T)(rtb_PulseGenerator <= 65535.0 ? rtb_PulseGenerator >= 0.0
? rtb_PulseGenerator : 0.0 : 65535.0) + c2812pwmtest_P.Constant_Value;
/* S-Function Block: <Root>/C28x PWM (c28xpwm) */
{
EvaRegs.T1PR = (uint16_T)rtb_Add;
EvaRegs.CMPR1 = (uint16_T)c2812pwmtest_P.PulseWidthSource_Value;
}
}
/* Model initialize function */
void c2812pwmtest_initialize(boolean_T firstTime)
{
if (firstTime) {
/* initialize error status */
rtmSetErrorStatus(c2812pwmtest_M, (const char_T *)0);
/* data type work */
(void) memset((char_T *) &c2812pwmtest_DWork,0,sizeof(D_Work_c2812pwmtest));
/* initialize non-finites */
rt_InitInfAndNaN(sizeof(real_T));
/* Start for DiscretePulseGenerator: '<S2>/Pulse Generator' */
c2812pwmtest_DWork.clockTickCounter = 0L;
EALLOW;
GpioMuxRegs.GPAMUX.all = 0x00FF; // EVA PWM 1-6 pins
config_PWM_A (37500.0,2,1,"INPUT_PORT",18500.0,
0,"SPECIFY_VIA_DIALOG",18500.0,0,"SPECIFY_VIA_DIALOG",18500.0,1638,
0, 0, 0, 0, 1, 0);
EDIS;
}
}
/* Model terminate function */
void c2812pwmtest_terminate(void)
{
/* (no terminate code required) */
}
/* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -