Обновление

This commit is contained in:
cfif 2025-12-19 16:07:24 +03:00
commit eca1bd9aed
7 changed files with 1033 additions and 0 deletions

53
Model_Task.c Normal file
View File

@ -0,0 +1,53 @@
//
// Created by cfif on 19.12.2025.
//
#include "Model_Task.h"
#include <SystemDelayInterface.h>
#include <CmsisRtosThreadUtils.h>
#include "Model_actuator.h"
void ModelTask_Init(
tModelTask *env
) {
Model_actuator_initialize();
env->access = osMutexNew(NULL);
InitThreadAtrStatic(&env->thread.attr, "ModelTask", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
env->thread.id = 0;
}
static void setActuatorBusy() {
for (uint8_t i = 0; i < 9; ++i) {
if (rtY.Out1.COM[i] != 0) {
rtU.in_Busy_Ch0 = 1;
return;
}
}
}
static _Noreturn void ModelTask_Thread(tModelTask *env) {
for (;;) {
if (osMutexAcquire(env->access, 1000) == osOK) {
Model_actuator_step();
setActuatorBusy();
osMutexRelease(env->access);
}
SystemDelayMs(100);
}
}
void ModelTask_StartThread(tModelTask *env) {
if (!env->thread.id) {
env->thread.id = osThreadNew((osThreadFunc_t) (ModelTask_Thread), (void *) (env), &env->thread.attr);
} else {
osThreadResume(env->thread.id);
}
}
void ModelTask_StopThread(tModelTask *env) {
if (env->thread.id) {
osThreadSuspend(env->thread.id);
}
}

27
Model_Task.h Normal file
View File

@ -0,0 +1,27 @@
//
// Created by cfif on 19.12.2025.
//
#ifndef HVAC_M7_MODEL_TASK_H
#define HVAC_M7_MODEL_TASK_H
#include <cmsis_os.h>
typedef struct {
osMutexId_t access;
struct {
osThreadId_t id;
uint32_t stack[1024];
StaticTask_t controlBlock;
osThreadAttr_t attr;
} thread;
} tModelTask;
void ModelTask_Init(tModelTask *env);
void ModelTask_StartThread(tModelTask *env);
void ModelTask_StopThread(tModelTask *env);
#endif //HVAC_M7_MODEL_TASK_H

666
Model_actuator.c Normal file
View File

@ -0,0 +1,666 @@
/*
* File: Model_actuator.c
*
* Code generated for Simulink model 'Model_actuator'.
*
* Model version : 1.538
* Simulink Coder version : 24.1 (R2024a) 19-Nov-2023
* C/C++ source code generated on : Fri Dec 19 14:23:04 2025
*
* Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex-M
* Emulation hardware selection:
* Differs from embedded hardware (MATLAB Host)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Model_actuator.h"
#include <stdint.h>
#include "Model_actuator_private.h"
#include "Model_actuator_types.h"
/* Exported block states */
ActuatorCmdBus controllerData; /* '<Root>/Data Store Memory15' */
/* Block signals (default storage) */
B rtB;
/* Block states (default storage) */
DW rtDW;
/* External inputs (root inport signals with default storage) */
ExtU rtU;
/* External outputs (root outports fed by signals with default storage) */
ExtY rtY;
/* Real-time model */
static RT_MODEL rtM_;
RT_MODEL *const rtM = &rtM_;
/*
* Output and update for action system:
* '<S9>/If Action Subsystem2'
* '<S8>/If Action Subsystem2'
*/
void IfActionSubsystem2(int8_t rtu_stepIn, int8_t *rty_step, uint8_t
rtd_autos_set_loc[9], uint8_t rtd_coils_stop_set_loc[9], uint8_t rtd_com_loc[9],
uint8_t rtd_lnoise_set_loc[9], uint8_t rtd_speed_set_loc[9], uint8_t
rtd_stall_set_loc[9])
{
int32_t i;
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S31>/Data Store Write1' incorporates:
* Constant: '<S31>/Constant1'
*/
rtd_stall_set_loc[i] = 0U;
/* DataStoreWrite: '<S31>/Data Store Write3' incorporates:
* Constant: '<S31>/Constant2'
*/
rtd_lnoise_set_loc[i] = 0U;
/* DataStoreWrite: '<S31>/Data Store Write2' */
rtd_com_loc[i] = 2U;
/* DataStoreWrite: '<S31>/Data Store Write4' incorporates:
* Constant: '<S31>/Constant4'
*/
rtd_autos_set_loc[i] = 0U;
/* DataStoreWrite: '<S31>/Data Store Write5' incorporates:
* Constant: '<S31>/Constant5'
*/
rtd_speed_set_loc[i] = 0U;
/* DataStoreWrite: '<S31>/Data Store Write6' incorporates:
* Constant: '<S31>/Constant6'
*/
rtd_coils_stop_set_loc[i] = 0U;
}
/* Sum: '<S31>/step inc' incorporates:
* Constant: '<S31>/Constant'
*/
*rty_step = (int8_t)(rtu_stepIn + 1);
}
/* Model step function */
void Model_actuator_step(void)
{
int32_t i;
uint16_t tmp;
int8_t rtb_Switch;
/* BusCreator: '<Root>/Bus Creator' incorporates:
* DataStoreRead: '<Root>/Data Store Read1'
* DataStoreRead: '<Root>/Data Store Read2'
* DataStoreRead: '<Root>/Data Store Read3'
* DataStoreRead: '<Root>/Data Store Read4'
* DataStoreRead: '<Root>/Data Store Read5'
* DataStoreRead: '<Root>/Data Store Read6'
* DataStoreRead: '<Root>/Data Store Read7'
* DataStoreRead: '<Root>/Data Store Read8'
* DataStoreRead: '<Root>/Data Store Read9'
* DataStoreWrite: '<Root>/Data Store Write'
*/
for (i = 0; i < 9; i++) {
controllerData.POS[i] = rtDW.pos_loc[i];
controllerData.BUS_ADR[i] = rtDW.busAdr_loc[i];
controllerData.MODE[i] = rtDW.mode_loc[i];
controllerData.COM[i] = rtDW.com_loc[i];
controllerData.Stall_SET[i] = rtDW.stall_set_loc[i];
controllerData.Lnoise_SET[i] = rtDW.lnoise_set_loc[i];
controllerData.Autos_SET[i] = rtDW.autos_set_loc[i];
controllerData.Speed_SET[i] = rtDW.speed_set_loc[i];
controllerData.Coils_Stop_SET[i] = rtDW.coils_stop_set_loc[i];
}
/* End of BusCreator: '<Root>/Bus Creator' */
/* Switch: '<Root>/Switch' incorporates:
* Constant: '<Root>/Constant1'
* DataStoreRead: '<Root>/Data Store Read'
* UnitDelay: '<Root>/Unit Delay'
*/
if (rtDW.stepSig >= 1) {
rtb_Switch = rtDW.UnitDelay_DSTATE;
} else {
rtb_Switch = 1;
}
/* End of Switch: '<Root>/Switch' */
/* SwitchCase: '<Root>/Switch Case' */
switch (rtb_Switch) {
case 1:
/* Outputs for IfAction SubSystem: '<Root>/Stop Mode' incorporates:
* ActionPort: '<S12>/Action Port'
*/
/* If: '<S12>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S12>/If Action Subsystem2' incorporates:
* ActionPort: '<S37>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S37>/Data Store Write2' */
rtDW.mode_loc[i] = 2U;
/* DataStoreWrite: '<S37>/Data Store Write3' */
rtDW.com_loc[i] = 0U;
}
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S37>/Constant'
* Merge: '<S12>/Merge'
* Sum: '<S37>/step inc'
*/
rtB.Merge = (int8_t)(rtb_Switch + 1);
/* End of Outputs for SubSystem: '<S12>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S12>/If Action Subsystem3' incorporates:
* ActionPort: '<S38>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S12>/Merge'
* SignalConversion generated from: '<S38>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S12>/If Action Subsystem3' */
}
/* End of If: '<S12>/If1' */
/* MATLAB Function: '<S12>/stop mode' */
/* : y = step; */
/* : fprintf('Stop Mode\n'); */
printf("Stop Mode\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Stop Mode' */
break;
case 2:
/* Outputs for IfAction SubSystem: '<Root>/Initial CPOS Min' incorporates:
* ActionPort: '<S7>/Action Port'
*/
/* If: '<S7>/If' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S7>/If Action Subsystem' incorporates:
* ActionPort: '<S24>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S24>/Data Store Write' */
rtDW.pos_loc[i] = 6000U;
/* DataStoreWrite: '<S24>/Data Store Write1' */
rtDW.com_loc[i] = 1U;
}
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S24>/Constant'
* Merge: '<S7>/Merge'
* Sum: '<S24>/step inc'
*/
rtB.Merge = (int8_t)(rtb_Switch + 1);
/* End of Outputs for SubSystem: '<S7>/If Action Subsystem' */
} else {
/* Outputs for IfAction SubSystem: '<S7>/If Action Subsystem3' incorporates:
* ActionPort: '<S25>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S7>/Merge'
* SignalConversion generated from: '<S25>/step'
* SignalConversion generated from: '<S25>/stepIn1'
*/
/* : y = step; */
/* : coder.extrinsic('fprintf'); */
/* : fprintf('Actuator else: step = %d\n', step); */
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S7>/If Action Subsystem3' */
}
/* End of If: '<S7>/If' */
/* MATLAB Function: '<S7>/Initial CPOS Min' */
/* : y = step; */
/* : fprintf('Initial CPOS Min\n'); */
printf("Initial CPOS Min\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Initial CPOS Min' */
break;
case 3:
/* Outputs for IfAction SubSystem: '<Root>/Normal Mode' incorporates:
* ActionPort: '<S10>/Action Port'
*/
/* If: '<S10>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S10>/If Action Subsystem2' incorporates:
* ActionPort: '<S34>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S34>/Data Store Write' */
rtDW.mode_loc[i] = 0U;
/* DataStoreWrite: '<S34>/Data Store Write2' */
rtDW.com_loc[i] = 0U;
}
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S34>/Constant'
* Merge: '<S10>/Merge'
* Sum: '<S34>/step inc'
*/
rtB.Merge = (int8_t)(rtb_Switch + 1);
/* End of Outputs for SubSystem: '<S10>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S10>/If Action Subsystem3' incorporates:
* ActionPort: '<S35>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S10>/Merge'
* SignalConversion generated from: '<S35>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S10>/If Action Subsystem3' */
}
/* End of If: '<S10>/If1' */
/* MATLAB Function: '<S10>/Normal Mode' */
/* : y = step; */
/* : fprintf('Normal Mode\n'); */
printf("Normal Mode\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Normal Mode' */
break;
case 4:
/* Outputs for IfAction SubSystem: '<Root>/Move to position Min' incorporates:
* ActionPort: '<S9>/Action Port'
*/
/* If: '<S9>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S9>/If Action Subsystem2' incorporates:
* ActionPort: '<S31>/Action Port'
*/
/* Merge: '<Root>/Merge' */
IfActionSubsystem2(rtb_Switch, &rtB.Merge, rtDW.autos_set_loc,
rtDW.coils_stop_set_loc, rtDW.com_loc,
rtDW.lnoise_set_loc, rtDW.speed_set_loc,
rtDW.stall_set_loc);
/* End of Outputs for SubSystem: '<S9>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S9>/If Action Subsystem3' incorporates:
* ActionPort: '<S32>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S9>/Merge'
* SignalConversion generated from: '<S32>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S9>/If Action Subsystem3' */
}
/* End of If: '<S9>/If1' */
/* MATLAB Function: '<S9>/Move to position Min' */
/* : y = step; */
/* : fprintf('Move to position Min\n'); */
printf("Move to position Min\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Move to position Min' */
break;
case 5:
/* Outputs for IfAction SubSystem: '<Root>/Check Stall Min' incorporates:
* ActionPort: '<S2>/Action Port'
*/
/* If: '<S2>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S2>/If Action Subsystem2' incorporates:
* ActionPort: '<S17>/Action Port'
*/
/* DataStoreWrite: '<S17>/Data Store Write1' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
for (i = 0; i < 9; i++) {
rtDW.Min_position_Ch0[i] = rtU.in_CPOS_ALL_Ch0[i];
}
/* End of DataStoreWrite: '<S17>/Data Store Write1' */
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S17>/Constant'
* Merge: '<S2>/Merge'
* Sum: '<S17>/step inc'
*/
rtB.Merge = (int8_t)(rtb_Switch + 1);
/* End of Outputs for SubSystem: '<S2>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S2>/If Action Subsystem3' incorporates:
* ActionPort: '<S18>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S2>/Merge'
* SignalConversion generated from: '<S18>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S2>/If Action Subsystem3' */
}
/* End of If: '<S2>/If1' */
/* MATLAB Function: '<S2>/Check Stall Min' */
/* : y = step; */
/* : fprintf('Check Stall Min\n'); */
printf("Check Stall Min\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Check Stall Min' */
break;
case 6:
/* Outputs for IfAction SubSystem: '<Root>/Initial CPOS Max' incorporates:
* ActionPort: '<S6>/Action Port'
*/
/* If: '<S6>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S6>/If Action Subsystem2' incorporates:
* ActionPort: '<S21>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S21>/Data Store Write' */
rtDW.pos_loc[i] = 0U;
/* DataStoreWrite: '<S21>/Data Store Write1' */
rtDW.com_loc[i] = 1U;
}
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S21>/Constant'
* Merge: '<S6>/Merge'
* Sum: '<S21>/step inc'
*/
rtB.Merge = (int8_t)(rtb_Switch + 1);
/* End of Outputs for SubSystem: '<S6>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S6>/If Action Subsystem3' incorporates:
* ActionPort: '<S22>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S6>/Merge'
* SignalConversion generated from: '<S22>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S6>/If Action Subsystem3' */
}
/* End of If: '<S6>/If1' */
/* MATLAB Function: '<S6>/Initial CPOS Max' */
/* : y = step; */
/* : fprintf('Initial CPOS Max\n'); */
printf("Initial CPOS Max\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Initial CPOS Max' */
break;
case 7:
/* Outputs for IfAction SubSystem: '<Root>/Move to position Max' incorporates:
* ActionPort: '<S8>/Action Port'
*/
/* If: '<S8>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S8>/If Action Subsystem2' incorporates:
* ActionPort: '<S28>/Action Port'
*/
/* Merge: '<Root>/Merge' */
IfActionSubsystem2(rtb_Switch, &rtB.Merge, rtDW.autos_set_loc,
rtDW.coils_stop_set_loc, rtDW.com_loc,
rtDW.lnoise_set_loc, rtDW.speed_set_loc,
rtDW.stall_set_loc);
/* End of Outputs for SubSystem: '<S8>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S8>/If Action Subsystem3' incorporates:
* ActionPort: '<S29>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S8>/Merge'
* SignalConversion generated from: '<S29>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S8>/If Action Subsystem3' */
}
/* End of If: '<S8>/If1' */
/* MATLAB Function: '<S8>/Move to position Max' */
/* : y = step; */
/* : fprintf('Move to position Max\n'); */
printf("Move to position Max\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Move to position Max' */
break;
case 8:
/* Outputs for IfAction SubSystem: '<Root>/Check Stall Max' incorporates:
* ActionPort: '<S1>/Action Port'
*/
/* If: '<S1>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S1>/If Action Subsystem2' incorporates:
* ActionPort: '<S14>/Action Port'
*/
/* DataStoreWrite: '<S14>/Data Store Write1' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
for (i = 0; i < 9; i++) {
rtDW.Max_position_Ch0[i] = rtU.in_CPOS_ALL_Ch0[i];
}
/* End of DataStoreWrite: '<S14>/Data Store Write1' */
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S14>/Constant'
* Merge: '<S1>/Merge'
* Sum: '<S14>/step inc'
*/
rtB.Merge = (int8_t)(rtb_Switch + 1);
/* End of Outputs for SubSystem: '<S1>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S1>/If Action Subsystem3' incorporates:
* ActionPort: '<S15>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S1>/Merge'
* SignalConversion generated from: '<S15>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<S1>/If Action Subsystem3' */
}
/* End of If: '<S1>/If1' */
/* MATLAB Function: '<S1>/Check Stall Max' */
/* : y = step; */
/* : fprintf('Check Stall Max\n'); */
printf("Check Stall Max\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<Root>/Check Stall Max' */
break;
case 9:
/* Outputs for IfAction SubSystem: '<Root>/Homing' incorporates:
* ActionPort: '<S4>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S4>/Constant2'
* SignalConversion generated from: '<S4>/step'
*/
rtB.Merge = 1;
/* MATLAB Function: '<S4>/MAX POSITION' incorporates:
* DataStoreRead: '<S4>/Data Store Read2'
*/
/* : y = step; */
/* : fprintf('MAX POSITION '); */
printf("MAX POSITION ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
tmp = rtDW.Max_position_Ch0[i];
if (tmp > 32767) {
tmp = 32767U;
}
printf("%d ", (int16_t)tmp);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
/* End of MATLAB Function: '<S4>/MAX POSITION' */
/* MATLAB Function: '<S4>/MIN POSITION' incorporates:
* DataStoreRead: '<S4>/Data Store Read3'
*/
/* : y = step; */
/* : fprintf('MIN POSITION '); */
printf("MIN POSITION ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
tmp = rtDW.Min_position_Ch0[i];
if (tmp > 32767) {
tmp = 32767U;
}
printf("%d ", (int16_t)tmp);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
/* End of MATLAB Function: '<S4>/MIN POSITION' */
/* End of Outputs for SubSystem: '<Root>/Homing' */
break;
case 0:
/* Outputs for IfAction SubSystem: '<Root>/Homing1' incorporates:
* ActionPort: '<S5>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* SignalConversion generated from: '<S5>/stepIn'
*/
rtB.Merge = rtb_Switch;
/* End of Outputs for SubSystem: '<Root>/Homing1' */
break;
}
/* End of SwitchCase: '<Root>/Switch Case' */
/* Outport: '<Root>/Out1' incorporates:
* DataStoreRead: '<Root>/Data Store Read10'
*/
rtY.Out1 = controllerData;
/* DataStoreWrite: '<Root>/Start write stepSig' incorporates:
* Constant: '<Root>/Constant1'
*/
rtDW.stepSig = 1;
/* MATLAB Function: '<Root>/Finish case' incorporates:
* UnitDelay: '<Root>/Unit Delay'
*/
/* : y = step; */
/* : fprintf('Finish case: step = %d\n', step); */
printf("Finish case: step = %d\n", rtDW.UnitDelay_DSTATE);
fflush(stdout);
/* MATLAB Function: '<Root>/Start case' */
/* : y = step; */
/* : fprintf('Start case: step = %d\n', step); */
printf("Start case: step = %d\n", rtb_Switch);
fflush(stdout);
/* Update for UnitDelay: '<Root>/Unit Delay' */
rtDW.UnitDelay_DSTATE = rtB.Merge;
}
/* Model initialize function */
void Model_actuator_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Model_actuator_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/

191
Model_actuator.h Normal file
View File

@ -0,0 +1,191 @@
/*
* File: Model_actuator.h
*
* Code generated for Simulink model 'Model_actuator'.
*
* Model version : 1.538
* Simulink Coder version : 24.1 (R2024a) 19-Nov-2023
* C/C++ source code generated on : Fri Dec 19 14:23:04 2025
*
* Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex-M
* Emulation hardware selection:
* Differs from embedded hardware (MATLAB Host)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef Model_actuator_h_
#define Model_actuator_h_
#ifndef Model_actuator_COMMON_INCLUDES_
#define Model_actuator_COMMON_INCLUDES_
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#endif /* Model_actuator_COMMON_INCLUDES_ */
#include "Model_actuator_types.h"
/* Macros for accessing real-time model data structure */
#ifndef rtmGetErrorStatus
#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
#endif
#ifndef rtmSetErrorStatus
#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
#endif
/* user code (top of header file) */
#include <stdio.h>
/* Block signals (default storage) */
typedef struct {
int8_t Merge; /* '<Root>/Merge' */
} B;
/* Block states (default storage) for system '<Root>' */
typedef struct {
uint16_t Min_position_Ch0[9]; /* '<Root>/Data Store Memory12' */
uint16_t Max_position_Ch0[9]; /* '<Root>/Data Store Memory13' */
uint16_t pos_loc[9]; /* '<Root>/Data Store Memory4' */
int8_t UnitDelay_DSTATE; /* '<Root>/Unit Delay' */
int8_t stepSig; /* '<Root>/Data Store Memory' */
uint8_t mode_loc[9]; /* '<Root>/Data Store Memory1' */
uint8_t com_loc[9]; /* '<Root>/Data Store Memory2' */
uint8_t busAdr_loc[9]; /* '<Root>/Data Store Memory3' */
uint8_t stall_set_loc[9]; /* '<Root>/Data Store Memory5' */
uint8_t lnoise_set_loc[9]; /* '<Root>/Data Store Memory6' */
uint8_t autos_set_loc[9]; /* '<Root>/Data Store Memory7' */
uint8_t speed_set_loc[9]; /* '<Root>/Data Store Memory8' */
uint8_t coils_stop_set_loc[9]; /* '<Root>/Data Store Memory9' */
} DW;
/* External inputs (root inport signals with default storage) */
typedef struct {
uint16_t in_CPOS_ALL_Ch0[9]; /* '<Root>/in_CPOS_ALL_Ch0' */
uint8_t in_Act_Emrf_Slave_Ch0[9]; /* '<Root>/in_Act_Emrf_Slave_Ch0' */
uint8_t in_Mode_Slave_Ch0[9]; /* '<Root>/in_Mode_Slave_Ch0' */
uint8_t in_Act_Err1_Supply_Ch0[9]; /* '<Root>/in_Act_Err1_Supply_Ch0' */
uint8_t in_Act_Err2_Communication_Ch0[9];
/* '<Root>/in_Act_Err2_Communication_Ch0' */
uint8_t in_Act_Err3_Temperature_Ch0[9];
/* '<Root>/in_Act_Err3_Temperature_Ch0' */
uint8_t in_Act_Err4_Permanent_Electrical_Ch0[9];
/* '<Root>/in_Act_Err4_Permanent_Electrical_Ch0' */
uint8_t in_Act_Stall_Slave_Ch0[9]; /* '<Root>/in_Act_Stall_Slave_Ch0' */
uint8_t in_Act_Reset_Ch0[9]; /* '<Root>/in_Act_Reset_Ch0' */
uint8_t in_Busy_Ch0; /* '<Root>/in_Busy_Ch0' */
uint8_t in_Error_Connect_Ch0; /* '<Root>/in_Error_Connect_Ch0' */
} ExtU;
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
ActuatorCmdBus Out1; /* '<Root>/Out1' */
} ExtY;
/* Real-time Model Data Structure */
struct tag_RTM {
const char * volatile errorStatus;
};
/* Block signals (default storage) */
extern B rtB;
/* Block states (default storage) */
extern DW rtDW;
/* External inputs (root inport signals with default storage) */
extern ExtU rtU;
/* External outputs (root outports fed by signals with default storage) */
extern ExtY rtY;
/*
* Exported States
*
* Note: Exported states are block states with an exported global
* storage class designation. Code generation will declare the memory for these
* states and exports their symbols.
*
*/
extern ActuatorCmdBus controllerData; /* '<Root>/Data Store Memory15' */
/* Model entry point functions */
extern void Model_actuator_initialize(void);
extern void Model_actuator_step(void);
extern void Model_actuator_terminate(void);
/* Real-time Model object */
extern RT_MODEL *const rtM;
/*-
* These blocks were eliminated from the model due to optimizations:
*
* Block '<S7>/Display1' : Unused code path elimination
* Block '<S7>/Display2' : Unused code path elimination
* Block '<S7>/Display3' : Unused code path elimination
* Block '<S12>/Display3' : Unused code path elimination
*/
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is <system>/block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('<S3>') - opens system 3
* hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '<Root>' : 'Model_actuator'
* '<S1>' : 'Model_actuator/Check Stall Max'
* '<S2>' : 'Model_actuator/Check Stall Min'
* '<S3>' : 'Model_actuator/Finish case'
* '<S4>' : 'Model_actuator/Homing'
* '<S5>' : 'Model_actuator/Homing1'
* '<S6>' : 'Model_actuator/Initial CPOS Max'
* '<S7>' : 'Model_actuator/Initial CPOS Min'
* '<S8>' : 'Model_actuator/Move to position Max'
* '<S9>' : 'Model_actuator/Move to position Min'
* '<S10>' : 'Model_actuator/Normal Mode'
* '<S11>' : 'Model_actuator/Start case'
* '<S12>' : 'Model_actuator/Stop Mode'
* '<S13>' : 'Model_actuator/Check Stall Max/Check Stall Max'
* '<S14>' : 'Model_actuator/Check Stall Max/If Action Subsystem2'
* '<S15>' : 'Model_actuator/Check Stall Max/If Action Subsystem3'
* '<S16>' : 'Model_actuator/Check Stall Min/Check Stall Min'
* '<S17>' : 'Model_actuator/Check Stall Min/If Action Subsystem2'
* '<S18>' : 'Model_actuator/Check Stall Min/If Action Subsystem3'
* '<S19>' : 'Model_actuator/Homing/MAX POSITION'
* '<S20>' : 'Model_actuator/Homing/MIN POSITION'
* '<S21>' : 'Model_actuator/Initial CPOS Max/If Action Subsystem2'
* '<S22>' : 'Model_actuator/Initial CPOS Max/If Action Subsystem3'
* '<S23>' : 'Model_actuator/Initial CPOS Max/Initial CPOS Max'
* '<S24>' : 'Model_actuator/Initial CPOS Min/If Action Subsystem'
* '<S25>' : 'Model_actuator/Initial CPOS Min/If Action Subsystem3'
* '<S26>' : 'Model_actuator/Initial CPOS Min/Initial CPOS Min'
* '<S27>' : 'Model_actuator/Initial CPOS Min/If Action Subsystem3/Log Ambient Lv3'
* '<S28>' : 'Model_actuator/Move to position Max/If Action Subsystem2'
* '<S29>' : 'Model_actuator/Move to position Max/If Action Subsystem3'
* '<S30>' : 'Model_actuator/Move to position Max/Move to position Max'
* '<S31>' : 'Model_actuator/Move to position Min/If Action Subsystem2'
* '<S32>' : 'Model_actuator/Move to position Min/If Action Subsystem3'
* '<S33>' : 'Model_actuator/Move to position Min/Move to position Min'
* '<S34>' : 'Model_actuator/Normal Mode/If Action Subsystem2'
* '<S35>' : 'Model_actuator/Normal Mode/If Action Subsystem3'
* '<S36>' : 'Model_actuator/Normal Mode/Normal Mode'
* '<S37>' : 'Model_actuator/Stop Mode/If Action Subsystem2'
* '<S38>' : 'Model_actuator/Stop Mode/If Action Subsystem3'
* '<S39>' : 'Model_actuator/Stop Mode/stop mode'
*/
#endif /* Model_actuator_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/

36
Model_actuator_private.h Normal file
View File

@ -0,0 +1,36 @@
/*
* File: Model_actuator_private.h
*
* Code generated for Simulink model 'Model_actuator'.
*
* Model version : 1.538
* Simulink Coder version : 24.1 (R2024a) 19-Nov-2023
* C/C++ source code generated on : Fri Dec 19 14:23:04 2025
*
* Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex-M
* Emulation hardware selection:
* Differs from embedded hardware (MATLAB Host)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef Model_actuator_private_h_
#define Model_actuator_private_h_
#include <stdbool.h>
#include <stdint.h>
#include "Model_actuator_types.h"
#include "Model_actuator.h"
extern void IfActionSubsystem2(int8_t rtu_stepIn, int8_t *rty_step, uint8_t
rtd_autos_set_loc[9], uint8_t rtd_coils_stop_set_loc[9], uint8_t rtd_com_loc[9],
uint8_t rtd_lnoise_set_loc[9], uint8_t rtd_speed_set_loc[9], uint8_t
rtd_stall_set_loc[9]);
#endif /* Model_actuator_private_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/

47
Model_actuator_types.h Normal file
View File

@ -0,0 +1,47 @@
/*
* File: Model_actuator_types.h
*
* Code generated for Simulink model 'Model_actuator'.
*
* Model version : 1.538
* Simulink Coder version : 24.1 (R2024a) 19-Nov-2023
* C/C++ source code generated on : Fri Dec 19 14:23:04 2025
*
* Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex-M
* Emulation hardware selection:
* Differs from embedded hardware (MATLAB Host)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#ifndef Model_actuator_types_h_
#define Model_actuator_types_h_
#include <stdint.h>
#ifndef DEFINED_TYPEDEF_FOR_ActuatorCmdBus_
#define DEFINED_TYPEDEF_FOR_ActuatorCmdBus_
typedef struct {
uint16_t POS[9];
uint8_t BUS_ADR[9];
uint8_t MODE[9];
uint8_t COM[9];
uint8_t Stall_SET[9];
uint8_t Lnoise_SET[9];
uint8_t Autos_SET[9];
uint8_t Speed_SET[9];
uint8_t Coils_Stop_SET[9];
} ActuatorCmdBus;
#endif
/* Forward declaration for rtModel */
typedef struct tag_RTM RT_MODEL;
#endif /* Model_actuator_types_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/

13
modular.json Normal file
View File

@ -0,0 +1,13 @@
{
"dep": [
],
"cmake": {
"inc_dirs": [
"./"
],
"srcs": [
"./**.c"
]
}
}