add more hal api
This commit is contained in:
Binary file not shown.
Binary file not shown.
+399
@@ -0,0 +1,399 @@
|
||||
/*
|
||||
* File: hal_file_io.c
|
||||
*
|
||||
*
|
||||
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
|
||||
*
|
||||
* This file is an 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_defines_Changes_BEGIN
|
||||
* #define NAME 'replacement text'
|
||||
* %%% SFUNWIZ_defines_Changes_END
|
||||
*
|
||||
* DO NOT change NAME--Change the 'replacement text' only.
|
||||
*
|
||||
* For better compatibility with the Simulink Coder, the
|
||||
* "wrapper" S-function technique is used. This is discussed
|
||||
* in the Simulink Coder's Manual in the Chapter titled,
|
||||
* "Wrapper S-functions".
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Created: Tue Nov 01 14:35:16 2022
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_file_io
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 5
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME data
|
||||
#define INPUT_0_WIDTH DYNAMICALLY_SIZED
|
||||
#define INPUT_DIMS_0_COL 1
|
||||
#define INPUT_0_DTYPE uint8_T
|
||||
#define INPUT_0_COMPLEX COMPLEX_NO
|
||||
#define IN_0_FRAME_BASED FRAME_NO
|
||||
#define IN_0_BUS_BASED 0
|
||||
#define IN_0_BUS_NAME
|
||||
#define IN_0_DIMS 1-D
|
||||
#define INPUT_0_FEEDTHROUGH 1
|
||||
#define IN_0_ISSIGNED 0
|
||||
#define IN_0_WORDLENGTH 8
|
||||
#define IN_0_FIXPOINTSCALING 1
|
||||
#define IN_0_FRACTIONLENGTH 9
|
||||
#define IN_0_BIAS 0
|
||||
#define IN_0_SLOPE 0.125
|
||||
/* Input Port 1 */
|
||||
#define IN_PORT_1_NAME size
|
||||
#define INPUT_1_WIDTH 1
|
||||
#define INPUT_DIMS_1_COL 1
|
||||
#define INPUT_1_DTYPE uint16_T
|
||||
#define INPUT_1_COMPLEX COMPLEX_NO
|
||||
#define IN_1_FRAME_BASED FRAME_NO
|
||||
#define IN_1_BUS_BASED 0
|
||||
#define IN_1_BUS_NAME
|
||||
#define IN_1_DIMS 1-D
|
||||
#define INPUT_1_FEEDTHROUGH 1
|
||||
#define IN_1_ISSIGNED 0
|
||||
#define IN_1_WORDLENGTH 8
|
||||
#define IN_1_FIXPOINTSCALING 1
|
||||
#define IN_1_FRACTIONLENGTH 9
|
||||
#define IN_1_BIAS 0
|
||||
#define IN_1_SLOPE 0.125
|
||||
/* Input Port 2 */
|
||||
#define IN_PORT_2_NAME offset
|
||||
#define INPUT_2_WIDTH 1
|
||||
#define INPUT_DIMS_2_COL 1
|
||||
#define INPUT_2_DTYPE uint32_T
|
||||
#define INPUT_2_COMPLEX COMPLEX_NO
|
||||
#define IN_2_FRAME_BASED FRAME_NO
|
||||
#define IN_2_BUS_BASED 0
|
||||
#define IN_2_BUS_NAME
|
||||
#define IN_2_DIMS 1-D
|
||||
#define INPUT_2_FEEDTHROUGH 1
|
||||
#define IN_2_ISSIGNED 0
|
||||
#define IN_2_WORDLENGTH 8
|
||||
#define IN_2_FIXPOINTSCALING 1
|
||||
#define IN_2_FRACTIONLENGTH 9
|
||||
#define IN_2_BIAS 0
|
||||
#define IN_2_SLOPE 0.125
|
||||
/* Input Port 3 */
|
||||
#define IN_PORT_3_NAME opcode
|
||||
#define INPUT_3_WIDTH 1
|
||||
#define INPUT_DIMS_3_COL 1
|
||||
#define INPUT_3_DTYPE uint8_T
|
||||
#define INPUT_3_COMPLEX COMPLEX_NO
|
||||
#define IN_3_FRAME_BASED FRAME_NO
|
||||
#define IN_3_BUS_BASED 0
|
||||
#define IN_3_BUS_NAME
|
||||
#define IN_3_DIMS 1-D
|
||||
#define INPUT_3_FEEDTHROUGH 1
|
||||
#define IN_3_ISSIGNED 0
|
||||
#define IN_3_WORDLENGTH 8
|
||||
#define IN_3_FIXPOINTSCALING 1
|
||||
#define IN_3_FRACTIONLENGTH 9
|
||||
#define IN_3_BIAS 0
|
||||
#define IN_3_SLOPE 0.125
|
||||
/* Input Port 4 */
|
||||
#define IN_PORT_4_NAME session
|
||||
#define INPUT_4_WIDTH 1
|
||||
#define INPUT_DIMS_4_COL 1
|
||||
#define INPUT_4_DTYPE uint8_T
|
||||
#define INPUT_4_COMPLEX COMPLEX_NO
|
||||
#define IN_4_FRAME_BASED FRAME_NO
|
||||
#define IN_4_BUS_BASED 0
|
||||
#define IN_4_BUS_NAME
|
||||
#define IN_4_DIMS 1-D
|
||||
#define INPUT_4_FEEDTHROUGH 1
|
||||
#define IN_4_ISSIGNED 0
|
||||
#define IN_4_WORDLENGTH 8
|
||||
#define IN_4_FIXPOINTSCALING 1
|
||||
#define IN_4_FRACTIONLENGTH 9
|
||||
#define IN_4_BIAS 0
|
||||
#define IN_4_SLOPE 0.125
|
||||
|
||||
#define NUM_OUTPUTS 4
|
||||
/* Output Port 0 */
|
||||
#define OUT_PORT_0_NAME ret_data
|
||||
#define OUTPUT_0_WIDTH DYNAMICALLY_SIZED
|
||||
#define OUTPUT_DIMS_0_COL 1
|
||||
#define OUTPUT_0_DTYPE uint8_T
|
||||
#define OUTPUT_0_COMPLEX COMPLEX_NO
|
||||
#define OUT_0_FRAME_BASED FRAME_NO
|
||||
#define OUT_0_BUS_BASED 0
|
||||
#define OUT_0_BUS_NAME
|
||||
#define OUT_0_DIMS 1-D
|
||||
#define OUT_0_ISSIGNED 1
|
||||
#define OUT_0_WORDLENGTH 8
|
||||
#define OUT_0_FIXPOINTSCALING 1
|
||||
#define OUT_0_FRACTIONLENGTH 3
|
||||
#define OUT_0_BIAS 0
|
||||
#define OUT_0_SLOPE 0.125
|
||||
/* Output Port 1 */
|
||||
#define OUT_PORT_1_NAME ret_size
|
||||
#define OUTPUT_1_WIDTH 1
|
||||
#define OUTPUT_DIMS_1_COL 1
|
||||
#define OUTPUT_1_DTYPE uint16_T
|
||||
#define OUTPUT_1_COMPLEX COMPLEX_NO
|
||||
#define OUT_1_FRAME_BASED FRAME_NO
|
||||
#define OUT_1_BUS_BASED 0
|
||||
#define OUT_1_BUS_NAME
|
||||
#define OUT_1_DIMS 1-D
|
||||
#define OUT_1_ISSIGNED 1
|
||||
#define OUT_1_WORDLENGTH 8
|
||||
#define OUT_1_FIXPOINTSCALING 1
|
||||
#define OUT_1_FRACTIONLENGTH 3
|
||||
#define OUT_1_BIAS 0
|
||||
#define OUT_1_SLOPE 0.125
|
||||
/* Output Port 2 */
|
||||
#define OUT_PORT_2_NAME ret
|
||||
#define OUTPUT_2_WIDTH 1
|
||||
#define OUTPUT_DIMS_2_COL 1
|
||||
#define OUTPUT_2_DTYPE int32_T
|
||||
#define OUTPUT_2_COMPLEX COMPLEX_NO
|
||||
#define OUT_2_FRAME_BASED FRAME_NO
|
||||
#define OUT_2_BUS_BASED 0
|
||||
#define OUT_2_BUS_NAME
|
||||
#define OUT_2_DIMS 1-D
|
||||
#define OUT_2_ISSIGNED 1
|
||||
#define OUT_2_WORDLENGTH 8
|
||||
#define OUT_2_FIXPOINTSCALING 1
|
||||
#define OUT_2_FRACTIONLENGTH 3
|
||||
#define OUT_2_BIAS 0
|
||||
#define OUT_2_SLOPE 0.125
|
||||
/* Output Port 3 */
|
||||
#define OUT_PORT_3_NAME in_progress
|
||||
#define OUTPUT_3_WIDTH 1
|
||||
#define OUTPUT_DIMS_3_COL 1
|
||||
#define OUTPUT_3_DTYPE boolean_T
|
||||
#define OUTPUT_3_COMPLEX COMPLEX_NO
|
||||
#define OUT_3_FRAME_BASED FRAME_NO
|
||||
#define OUT_3_BUS_BASED 0
|
||||
#define OUT_3_BUS_NAME
|
||||
#define OUT_3_DIMS 1-D
|
||||
#define OUT_3_ISSIGNED 1
|
||||
#define OUT_3_WORDLENGTH 8
|
||||
#define OUT_3_FIXPOINTSCALING 1
|
||||
#define OUT_3_FRACTIONLENGTH 3
|
||||
#define OUT_3_BIAS 0
|
||||
#define OUT_3_SLOPE 0.125
|
||||
|
||||
#define NPARAMS 0
|
||||
|
||||
#define SAMPLE_TIME_0 INHERITED_SAMPLE_TIME
|
||||
#define NUM_DISC_STATES 0
|
||||
#define DISC_STATES_IC [0]
|
||||
#define NUM_CONT_STATES 0
|
||||
#define CONT_STATES_IC [0]
|
||||
|
||||
#define SFUNWIZ_GENERATE_TLC 1
|
||||
#define SOURCEFILES "__SFB__"
|
||||
#define PANELINDEX 8
|
||||
#define USE_SIMSTRUCT 0
|
||||
#define SHOW_COMPILE_STEPS 0
|
||||
#define CREATE_DEBUG_MEXFILE 0
|
||||
#define SAVE_CODE_ONLY 0
|
||||
#define SFUNWIZ_REVISION 3.0
|
||||
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
#include "simstruc.h"
|
||||
|
||||
|
||||
extern void hal_file_io_Outputs_wrapper(const uint8_T *data,
|
||||
const uint16_T *size,
|
||||
const uint32_T *offset,
|
||||
const uint8_T *opcode,
|
||||
const uint8_T *session,
|
||||
uint8_T *ret_data,
|
||||
uint16_T *ret_size,
|
||||
int32_T *ret,
|
||||
boolean_T *in_progress,
|
||||
const int_T y_width,
|
||||
const int_T u_width);
|
||||
/*====================*
|
||||
* S-function methods *
|
||||
*====================*/
|
||||
/* Function: mdlInitializeSizes ===============================================
|
||||
* Abstract:
|
||||
* Setup sizes of the various vectors.
|
||||
*/
|
||||
static void mdlInitializeSizes(SimStruct *S)
|
||||
{
|
||||
|
||||
DECL_AND_INIT_DIMSINFO(inputDimsInfo);
|
||||
DECL_AND_INIT_DIMSINFO(outputDimsInfo);
|
||||
ssSetNumSFcnParams(S, NPARAMS);
|
||||
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
|
||||
return; /* Parameter mismatch will be reported by Simulink */
|
||||
}
|
||||
|
||||
ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
|
||||
|
||||
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
|
||||
|
||||
ssSetNumContStates(S, NUM_CONT_STATES);
|
||||
ssSetNumDiscStates(S, NUM_DISC_STATES);
|
||||
|
||||
|
||||
if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
|
||||
/* Input Port 0 */
|
||||
ssSetInputPortWidth(S, 0, INPUT_0_WIDTH);
|
||||
ssSetInputPortDataType(S, 0, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/
|
||||
|
||||
/* Input Port 1 */
|
||||
ssSetInputPortWidth(S, 1, INPUT_1_WIDTH);
|
||||
ssSetInputPortDataType(S, 1, SS_UINT16);
|
||||
ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/
|
||||
|
||||
/* Input Port 2 */
|
||||
ssSetInputPortWidth(S, 2, INPUT_2_WIDTH);
|
||||
ssSetInputPortDataType(S, 2, SS_UINT32);
|
||||
ssSetInputPortComplexSignal(S, 2, INPUT_2_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/
|
||||
|
||||
/* Input Port 3 */
|
||||
ssSetInputPortWidth(S, 3, INPUT_3_WIDTH);
|
||||
ssSetInputPortDataType(S, 3, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 3, INPUT_3_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/
|
||||
|
||||
/* Input Port 4 */
|
||||
ssSetInputPortWidth(S, 4, INPUT_4_WIDTH);
|
||||
ssSetInputPortDataType(S, 4, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 4, INPUT_4_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 4, INPUT_4_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 4, 1); /*direct input signal access*/
|
||||
|
||||
|
||||
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||
/* Output Port 0 */
|
||||
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
|
||||
ssSetOutputPortDataType(S, 0, SS_UINT8);
|
||||
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
|
||||
/* Output Port 1 */
|
||||
ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
|
||||
ssSetOutputPortDataType(S, 1, SS_UINT16);
|
||||
ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
|
||||
/* Output Port 2 */
|
||||
ssSetOutputPortWidth(S, 2, OUTPUT_2_WIDTH);
|
||||
ssSetOutputPortDataType(S, 2, SS_INT32);
|
||||
ssSetOutputPortComplexSignal(S, 2, OUTPUT_2_COMPLEX);
|
||||
/* Output Port 3 */
|
||||
ssSetOutputPortWidth(S, 3, OUTPUT_3_WIDTH);
|
||||
ssSetOutputPortDataType(S, 3, SS_BOOLEAN);
|
||||
ssSetOutputPortComplexSignal(S, 3, OUTPUT_3_COMPLEX);
|
||||
ssSetNumPWork(S, 0);
|
||||
|
||||
ssSetNumSampleTimes(S, 1);
|
||||
ssSetNumRWork(S, 0);
|
||||
ssSetNumIWork(S, 0);
|
||||
ssSetNumModes(S, 0);
|
||||
ssSetNumNonsampledZCs(S, 0);
|
||||
|
||||
ssSetSimulinkVersionGeneratedIn(S, "9.2");
|
||||
|
||||
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
|
||||
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
|
||||
SS_OPTION_USE_TLC_WITH_ACCELERATOR |
|
||||
SS_OPTION_WORKS_WITH_CODE_REUSE));
|
||||
}
|
||||
|
||||
/* Function: mdlInitializeSampleTimes =========================================
|
||||
* Abstract:
|
||||
* Specifiy the sample time.
|
||||
*/
|
||||
static void mdlInitializeSampleTimes(SimStruct *S)
|
||||
{
|
||||
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
|
||||
ssSetModelReferenceSampleTimeDefaultInheritance(S);
|
||||
ssSetOffsetTime(S, 0, 0.0);
|
||||
}
|
||||
|
||||
#define MDL_SET_INPUT_PORT_DATA_TYPE
|
||||
static void mdlSetInputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_OUTPUT_PORT_DATA_TYPE
|
||||
static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetOutputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_DEFAULT_PORT_DATA_TYPES
|
||||
static void mdlSetDefaultPortDataTypes(SimStruct *S)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, SS_DOUBLE);
|
||||
ssSetOutputPortDataType(S, 0, SS_DOUBLE);
|
||||
}
|
||||
|
||||
#define MDL_START /* Change to #undef to remove function */
|
||||
#if defined(MDL_START)
|
||||
/* Function: mdlStart =======================================================
|
||||
* Abstract:
|
||||
* This function is called once at start of model execution. If you
|
||||
* have states that should be initialized once, this is the place
|
||||
* to do it.
|
||||
*/
|
||||
static void mdlStart(SimStruct *S)
|
||||
{
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *data = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
const uint16_T *size = (uint16_T *) ssGetInputPortRealSignal(S, 1);
|
||||
const uint32_T *offset = (uint32_T *) ssGetInputPortRealSignal(S, 2);
|
||||
const uint8_T *opcode = (uint8_T *) ssGetInputPortRealSignal(S, 3);
|
||||
const uint8_T *session = (uint8_T *) ssGetInputPortRealSignal(S, 4);
|
||||
uint8_T *ret_data = (uint8_T *) ssGetOutputPortRealSignal(S, 0);
|
||||
uint16_T *ret_size = (uint16_T *) ssGetOutputPortRealSignal(S, 1);
|
||||
int32_T *ret = (int32_T *) ssGetOutputPortRealSignal(S, 2);
|
||||
boolean_T *in_progress = (boolean_T *) ssGetOutputPortRealSignal(S, 3);
|
||||
const int_T y_width = ssGetOutputPortWidth(S, 0);
|
||||
const int_T u_width = ssGetInputPortWidth(S, 0);
|
||||
|
||||
hal_file_io_Outputs_wrapper(data, size, offset, opcode, session, ret_data, ret_size, ret, in_progress, y_width, u_width);
|
||||
|
||||
}
|
||||
|
||||
/* Function: mdlTerminate =====================================================
|
||||
* Abstract:
|
||||
* In this function, you should perform any actions that are necessary
|
||||
* at the termination of a simulation. For example, if memory was
|
||||
* allocated in mdlStart, this is the place to free it.
|
||||
*/
|
||||
static void mdlTerminate(SimStruct *S)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
|
||||
#include "simulink.c" /* MEX-file interface mechanism */
|
||||
#else
|
||||
#include "cg_sfun.h" /* Code generation registration function */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,80 @@
|
||||
%% File : hal_file_io.tlc
|
||||
%% Created : Tue Nov 01 14:35:16 2022
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_file_io.c".
|
||||
%%
|
||||
%% File generated by S-function Builder Block
|
||||
%%
|
||||
%% For more information on using the Target Language with the
|
||||
%% Simulink Coder, see the Target Language Compiler manual
|
||||
%% (under Simulink Coder) in the "Inlining S-Functions"
|
||||
%% chapter under the section and subsection:
|
||||
%% "Writing Block Target Files to Inline S-Functions",
|
||||
%% "Function-Based or Wrappered Code".
|
||||
%%
|
||||
%implements hal_file_io "C"
|
||||
%% Function: BlockTypeSetup ===================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Set up external references for wrapper functions in the
|
||||
%% generated code.
|
||||
%%
|
||||
%function BlockTypeSetup(block, system) Output
|
||||
%openfile externs
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void hal_file_io_Start_wrapper(void);
|
||||
|
||||
extern void hal_file_io_Outputs_wrapper(const uint8_T *data,
|
||||
const uint16_T *size,
|
||||
const uint32_T *offset,
|
||||
const uint8_T *opcode,
|
||||
const uint8_T *session,
|
||||
uint8_T *ret_data,
|
||||
uint16_T *ret_size,
|
||||
int32_T *ret,
|
||||
boolean_T *in_progress,
|
||||
const int_T y_width,
|
||||
const int_T u_width);
|
||||
|
||||
extern void hal_file_io_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Outputs ==========================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Code generation rules for mdlOutputs function.
|
||||
%%
|
||||
%function Outputs(block, system) Output
|
||||
%%
|
||||
%assign pu0 = LibBlockInputSignalAddr(0, "", "", 0)
|
||||
%assign pu1 = LibBlockInputSignalAddr(1, "", "", 0)
|
||||
%assign pu2 = LibBlockInputSignalAddr(2, "", "", 0)
|
||||
%assign pu3 = LibBlockInputSignalAddr(3, "", "", 0)
|
||||
%assign pu4 = LibBlockInputSignalAddr(4, "", "", 0)
|
||||
%assign pu_width = LibBlockInputSignalWidth(0)
|
||||
%assign py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||
%assign py1 = LibBlockOutputSignalAddr(1, "", "", 0)
|
||||
%assign py2 = LibBlockOutputSignalAddr(2, "", "", 0)
|
||||
%assign py3 = LibBlockOutputSignalAddr(3, "", "", 0)
|
||||
%assign py_width = LibBlockOutputSignalWidth(0)
|
||||
hal_file_io_Outputs_wrapper(%<pu0>, %<pu1>, %<pu2>, %<pu3>, %<pu4>, %<py0>, %<py1>, %<py2>, %<py3>, %<py_width>, %<pu_width>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_file_io.tlc
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
#ifndef HAL_IMPL
|
||||
#include <string.h>
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Create external references here.
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
int file_io(unsigned char num, unsigned char *data, unsigned short size, unsigned int offset, unsigned char session, int ret[1], unsigned short ret_size[1], unsigned char *ret_data);
|
||||
|
||||
#ifndef HAL_IMPL
|
||||
static int file_no;
|
||||
|
||||
int file_io(unsigned char num, unsigned char *data, unsigned short size, unsigned int offset, unsigned char session, int ret[1], unsigned short ret_size[1], unsigned char *ret_data)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
if (offset == 0)
|
||||
{
|
||||
if (size == 1 && data[0] == '/')
|
||||
{
|
||||
ret[0] = 0;
|
||||
memset(&ret_data[0], 0, 239);
|
||||
memcpy(&ret_data[0], "D0:\0", 4);
|
||||
ret_size[0] = 4;
|
||||
file_no = 0;
|
||||
}
|
||||
else if (size == 3 && data[0] == '/' && data[1] == '0' && data[2] == ':')
|
||||
{
|
||||
ret[0] = 0;
|
||||
memset(&ret_data[0], 0, 239);
|
||||
memcpy(&ret_data[0], "Fabc.bin\t16\0", 12);
|
||||
ret_size[0] = 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = -1;
|
||||
ret_size[0] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = 65535;
|
||||
ret_size[0] = 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
if (file_no < 1)
|
||||
{
|
||||
file_no = 1;
|
||||
ret_size[0] = file_no;
|
||||
|
||||
ret[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = 8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
if (file_no >= 1 && session == file_no)
|
||||
{
|
||||
ret[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
ret[0] = 0;
|
||||
file_no = 0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
if (file_no < 1)
|
||||
{
|
||||
file_no = 1;
|
||||
ret_size[0] = file_no;
|
||||
ret[0] = 0;
|
||||
ret_data[0] = 16;
|
||||
ret_data[1] = 0;
|
||||
ret_data[2] = 0;
|
||||
ret_data[3] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = 8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
if (file_no >= 1 && session == file_no)
|
||||
{
|
||||
memset(&ret_data[0], 0, 239);
|
||||
if (offset >= 16)
|
||||
{
|
||||
ret[0] = 65535;
|
||||
ret_size[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ret_size[0] = 0;ret_size[0]<size;ret_size[0]+=1)
|
||||
{
|
||||
if (offset+ret_size[0] < 16)
|
||||
{
|
||||
ret_data[ret_size[0]] = (offset+ret_size[0])%10+'0';
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret[0] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
ret[0] = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_file_io_Outputs_wrapper(const uint8_T *data,
|
||||
const uint16_T *size,
|
||||
const uint32_T *offset,
|
||||
const uint8_T *opcode,
|
||||
const uint8_T *session,
|
||||
uint8_T *ret_data,
|
||||
uint16_T *ret_size,
|
||||
int32_T *ret,
|
||||
boolean_T *in_progress,
|
||||
const int_T y_width,
|
||||
const int_T u_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
in_progress[0] = file_io(opcode[0],data,size[0],offset[0],session[0],ret,ret_size,ret_data);
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* File: hal_save_mission.c
|
||||
*
|
||||
*
|
||||
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
|
||||
*
|
||||
* This file is an 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_defines_Changes_BEGIN
|
||||
* #define NAME 'replacement text'
|
||||
* %%% SFUNWIZ_defines_Changes_END
|
||||
*
|
||||
* DO NOT change NAME--Change the 'replacement text' only.
|
||||
*
|
||||
* For better compatibility with the Simulink Coder, the
|
||||
* "wrapper" S-function technique is used. This is discussed
|
||||
* in the Simulink Coder's Manual in the Chapter titled,
|
||||
* "Wrapper S-functions".
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Created: Tue Nov 01 14:35:05 2022
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_save_mission
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 1
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME typ
|
||||
#define INPUT_0_WIDTH 1
|
||||
#define INPUT_DIMS_0_COL 1
|
||||
#define INPUT_0_DTYPE uint8_T
|
||||
#define INPUT_0_COMPLEX COMPLEX_NO
|
||||
#define IN_0_FRAME_BASED FRAME_NO
|
||||
#define IN_0_BUS_BASED 0
|
||||
#define IN_0_BUS_NAME
|
||||
#define IN_0_DIMS 1-D
|
||||
#define INPUT_0_FEEDTHROUGH 1
|
||||
#define IN_0_ISSIGNED 0
|
||||
#define IN_0_WORDLENGTH 8
|
||||
#define IN_0_FIXPOINTSCALING 1
|
||||
#define IN_0_FRACTIONLENGTH 9
|
||||
#define IN_0_BIAS 0
|
||||
#define IN_0_SLOPE 0.125
|
||||
|
||||
#define NUM_OUTPUTS 0
|
||||
|
||||
#define NPARAMS 0
|
||||
|
||||
#define SAMPLE_TIME_0 INHERITED_SAMPLE_TIME
|
||||
#define NUM_DISC_STATES 0
|
||||
#define DISC_STATES_IC [0]
|
||||
#define NUM_CONT_STATES 0
|
||||
#define CONT_STATES_IC [0]
|
||||
|
||||
#define SFUNWIZ_GENERATE_TLC 1
|
||||
#define SOURCEFILES "__SFB__"
|
||||
#define PANELINDEX 8
|
||||
#define USE_SIMSTRUCT 0
|
||||
#define SHOW_COMPILE_STEPS 0
|
||||
#define CREATE_DEBUG_MEXFILE 0
|
||||
#define SAVE_CODE_ONLY 0
|
||||
#define SFUNWIZ_REVISION 3.0
|
||||
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
#include "simstruc.h"
|
||||
|
||||
|
||||
extern void hal_save_mission_Outputs_wrapper(const uint8_T *typ);
|
||||
/*====================*
|
||||
* S-function methods *
|
||||
*====================*/
|
||||
/* Function: mdlInitializeSizes ===============================================
|
||||
* Abstract:
|
||||
* Setup sizes of the various vectors.
|
||||
*/
|
||||
static void mdlInitializeSizes(SimStruct *S)
|
||||
{
|
||||
|
||||
DECL_AND_INIT_DIMSINFO(inputDimsInfo);
|
||||
DECL_AND_INIT_DIMSINFO(outputDimsInfo);
|
||||
ssSetNumSFcnParams(S, NPARAMS);
|
||||
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
|
||||
return; /* Parameter mismatch will be reported by Simulink */
|
||||
}
|
||||
|
||||
ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
|
||||
|
||||
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
|
||||
|
||||
ssSetNumContStates(S, NUM_CONT_STATES);
|
||||
ssSetNumDiscStates(S, NUM_DISC_STATES);
|
||||
|
||||
|
||||
if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
|
||||
ssSetInputPortWidth(S, 0, INPUT_0_WIDTH);
|
||||
ssSetInputPortDataType(S, 0, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/
|
||||
|
||||
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||
ssSetNumPWork(S, 0);
|
||||
|
||||
ssSetNumSampleTimes(S, 1);
|
||||
ssSetNumRWork(S, 0);
|
||||
ssSetNumIWork(S, 0);
|
||||
ssSetNumModes(S, 0);
|
||||
ssSetNumNonsampledZCs(S, 0);
|
||||
|
||||
ssSetSimulinkVersionGeneratedIn(S, "9.2");
|
||||
|
||||
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
|
||||
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
|
||||
SS_OPTION_USE_TLC_WITH_ACCELERATOR |
|
||||
SS_OPTION_WORKS_WITH_CODE_REUSE));
|
||||
}
|
||||
|
||||
/* Function: mdlInitializeSampleTimes =========================================
|
||||
* Abstract:
|
||||
* Specifiy the sample time.
|
||||
*/
|
||||
static void mdlInitializeSampleTimes(SimStruct *S)
|
||||
{
|
||||
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
|
||||
ssSetModelReferenceSampleTimeDefaultInheritance(S);
|
||||
ssSetOffsetTime(S, 0, 0.0);
|
||||
}
|
||||
|
||||
#define MDL_SET_INPUT_PORT_DATA_TYPE
|
||||
static void mdlSetInputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_OUTPUT_PORT_DATA_TYPE
|
||||
static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetOutputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_DEFAULT_PORT_DATA_TYPES
|
||||
static void mdlSetDefaultPortDataTypes(SimStruct *S)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, SS_DOUBLE);
|
||||
ssSetOutputPortDataType(S, 0, SS_DOUBLE);
|
||||
}
|
||||
|
||||
#define MDL_START /* Change to #undef to remove function */
|
||||
#if defined(MDL_START)
|
||||
/* Function: mdlStart =======================================================
|
||||
* Abstract:
|
||||
* This function is called once at start of model execution. If you
|
||||
* have states that should be initialized once, this is the place
|
||||
* to do it.
|
||||
*/
|
||||
static void mdlStart(SimStruct *S)
|
||||
{
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *typ = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
|
||||
hal_save_mission_Outputs_wrapper(typ);
|
||||
|
||||
}
|
||||
|
||||
/* Function: mdlTerminate =====================================================
|
||||
* Abstract:
|
||||
* In this function, you should perform any actions that are necessary
|
||||
* at the termination of a simulation. For example, if memory was
|
||||
* allocated in mdlStart, this is the place to free it.
|
||||
*/
|
||||
static void mdlTerminate(SimStruct *S)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
|
||||
#include "simulink.c" /* MEX-file interface mechanism */
|
||||
#else
|
||||
#include "cg_sfun.h" /* Code generation registration function */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,60 @@
|
||||
%% File : hal_save_mission.tlc
|
||||
%% Created : Tue Nov 01 14:35:05 2022
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_save_mission.c".
|
||||
%%
|
||||
%% File generated by S-function Builder Block
|
||||
%%
|
||||
%% For more information on using the Target Language with the
|
||||
%% Simulink Coder, see the Target Language Compiler manual
|
||||
%% (under Simulink Coder) in the "Inlining S-Functions"
|
||||
%% chapter under the section and subsection:
|
||||
%% "Writing Block Target Files to Inline S-Functions",
|
||||
%% "Function-Based or Wrappered Code".
|
||||
%%
|
||||
%implements hal_save_mission "C"
|
||||
%% Function: BlockTypeSetup ===================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Set up external references for wrapper functions in the
|
||||
%% generated code.
|
||||
%%
|
||||
%function BlockTypeSetup(block, system) Output
|
||||
%openfile externs
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void hal_save_mission_Start_wrapper(void);
|
||||
|
||||
extern void hal_save_mission_Outputs_wrapper(const uint8_T *typ);
|
||||
|
||||
extern void hal_save_mission_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Outputs ==========================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Code generation rules for mdlOutputs function.
|
||||
%%
|
||||
%function Outputs(block, system) Output
|
||||
%%
|
||||
%assign pu0 = LibBlockInputSignalAddr(0, "", "", 0)
|
||||
hal_save_mission_Outputs_wrapper(%<pu0>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_save_mission.tlc
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
/*
|
||||
* 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 u_width 1
|
||||
|
||||
/*
|
||||
* Create external references here.
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
void save_mission(unsigned char typ);
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_save_mission_Outputs_wrapper(const uint8_T *typ)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
save_mission(typ[0]);
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* File: hal_status_text.c
|
||||
*
|
||||
*
|
||||
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
|
||||
*
|
||||
* This file is an 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_defines_Changes_BEGIN
|
||||
* #define NAME 'replacement text'
|
||||
* %%% SFUNWIZ_defines_Changes_END
|
||||
*
|
||||
* DO NOT change NAME--Change the 'replacement text' only.
|
||||
*
|
||||
* For better compatibility with the Simulink Coder, the
|
||||
* "wrapper" S-function technique is used. This is discussed
|
||||
* in the Simulink Coder's Manual in the Chapter titled,
|
||||
* "Wrapper S-functions".
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Created: Tue Nov 01 14:35:23 2022
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_status_text
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 1
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME max_width
|
||||
#define INPUT_0_WIDTH 1
|
||||
#define INPUT_DIMS_0_COL 1
|
||||
#define INPUT_0_DTYPE uint8_T
|
||||
#define INPUT_0_COMPLEX COMPLEX_NO
|
||||
#define IN_0_FRAME_BASED FRAME_NO
|
||||
#define IN_0_BUS_BASED 0
|
||||
#define IN_0_BUS_NAME
|
||||
#define IN_0_DIMS 1-D
|
||||
#define INPUT_0_FEEDTHROUGH 1
|
||||
#define IN_0_ISSIGNED 0
|
||||
#define IN_0_WORDLENGTH 8
|
||||
#define IN_0_FIXPOINTSCALING 1
|
||||
#define IN_0_FRACTIONLENGTH 9
|
||||
#define IN_0_BIAS 0
|
||||
#define IN_0_SLOPE 0.125
|
||||
|
||||
#define NUM_OUTPUTS 3
|
||||
/* Output Port 0 */
|
||||
#define OUT_PORT_0_NAME text
|
||||
#define OUTPUT_0_WIDTH DYNAMICALLY_SIZED
|
||||
#define OUTPUT_DIMS_0_COL 1
|
||||
#define OUTPUT_0_DTYPE uint8_T
|
||||
#define OUTPUT_0_COMPLEX COMPLEX_NO
|
||||
#define OUT_0_FRAME_BASED FRAME_NO
|
||||
#define OUT_0_BUS_BASED 0
|
||||
#define OUT_0_BUS_NAME
|
||||
#define OUT_0_DIMS 1-D
|
||||
#define OUT_0_ISSIGNED 1
|
||||
#define OUT_0_WORDLENGTH 8
|
||||
#define OUT_0_FIXPOINTSCALING 1
|
||||
#define OUT_0_FRACTIONLENGTH 3
|
||||
#define OUT_0_BIAS 0
|
||||
#define OUT_0_SLOPE 0.125
|
||||
/* Output Port 1 */
|
||||
#define OUT_PORT_1_NAME seq
|
||||
#define OUTPUT_1_WIDTH 1
|
||||
#define OUTPUT_DIMS_1_COL 1
|
||||
#define OUTPUT_1_DTYPE uint8_T
|
||||
#define OUTPUT_1_COMPLEX COMPLEX_NO
|
||||
#define OUT_1_FRAME_BASED FRAME_NO
|
||||
#define OUT_1_BUS_BASED 0
|
||||
#define OUT_1_BUS_NAME
|
||||
#define OUT_1_DIMS 1-D
|
||||
#define OUT_1_ISSIGNED 1
|
||||
#define OUT_1_WORDLENGTH 8
|
||||
#define OUT_1_FIXPOINTSCALING 1
|
||||
#define OUT_1_FRACTIONLENGTH 3
|
||||
#define OUT_1_BIAS 0
|
||||
#define OUT_1_SLOPE 0.125
|
||||
/* Output Port 2 */
|
||||
#define OUT_PORT_2_NAME severity
|
||||
#define OUTPUT_2_WIDTH 1
|
||||
#define OUTPUT_DIMS_2_COL 1
|
||||
#define OUTPUT_2_DTYPE uint8_T
|
||||
#define OUTPUT_2_COMPLEX COMPLEX_NO
|
||||
#define OUT_2_FRAME_BASED FRAME_NO
|
||||
#define OUT_2_BUS_BASED 0
|
||||
#define OUT_2_BUS_NAME
|
||||
#define OUT_2_DIMS 1-D
|
||||
#define OUT_2_ISSIGNED 1
|
||||
#define OUT_2_WORDLENGTH 8
|
||||
#define OUT_2_FIXPOINTSCALING 1
|
||||
#define OUT_2_FRACTIONLENGTH 3
|
||||
#define OUT_2_BIAS 0
|
||||
#define OUT_2_SLOPE 0.125
|
||||
|
||||
#define NPARAMS 0
|
||||
|
||||
#define SAMPLE_TIME_0 INHERITED_SAMPLE_TIME
|
||||
#define NUM_DISC_STATES 0
|
||||
#define DISC_STATES_IC [0]
|
||||
#define NUM_CONT_STATES 0
|
||||
#define CONT_STATES_IC [0]
|
||||
|
||||
#define SFUNWIZ_GENERATE_TLC 1
|
||||
#define SOURCEFILES "__SFB__;"
|
||||
#define PANELINDEX 8
|
||||
#define USE_SIMSTRUCT 0
|
||||
#define SHOW_COMPILE_STEPS 0
|
||||
#define CREATE_DEBUG_MEXFILE 0
|
||||
#define SAVE_CODE_ONLY 0
|
||||
#define SFUNWIZ_REVISION 3.0
|
||||
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
#include "simstruc.h"
|
||||
|
||||
|
||||
extern void hal_status_text_Outputs_wrapper(const uint8_T *max_width,
|
||||
uint8_T *text,
|
||||
uint8_T *seq,
|
||||
uint8_T *severity,
|
||||
const int_T y_width);
|
||||
/*====================*
|
||||
* S-function methods *
|
||||
*====================*/
|
||||
/* Function: mdlInitializeSizes ===============================================
|
||||
* Abstract:
|
||||
* Setup sizes of the various vectors.
|
||||
*/
|
||||
static void mdlInitializeSizes(SimStruct *S)
|
||||
{
|
||||
|
||||
DECL_AND_INIT_DIMSINFO(inputDimsInfo);
|
||||
DECL_AND_INIT_DIMSINFO(outputDimsInfo);
|
||||
ssSetNumSFcnParams(S, NPARAMS);
|
||||
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
|
||||
return; /* Parameter mismatch will be reported by Simulink */
|
||||
}
|
||||
|
||||
ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
|
||||
|
||||
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
|
||||
|
||||
ssSetNumContStates(S, NUM_CONT_STATES);
|
||||
ssSetNumDiscStates(S, NUM_DISC_STATES);
|
||||
|
||||
|
||||
if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
|
||||
ssSetInputPortWidth(S, 0, INPUT_0_WIDTH);
|
||||
ssSetInputPortDataType(S, 0, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/
|
||||
|
||||
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||
/* Output Port 0 */
|
||||
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
|
||||
ssSetOutputPortDataType(S, 0, SS_UINT8);
|
||||
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
|
||||
/* Output Port 1 */
|
||||
ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
|
||||
ssSetOutputPortDataType(S, 1, SS_UINT8);
|
||||
ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
|
||||
/* Output Port 2 */
|
||||
ssSetOutputPortWidth(S, 2, OUTPUT_2_WIDTH);
|
||||
ssSetOutputPortDataType(S, 2, SS_UINT8);
|
||||
ssSetOutputPortComplexSignal(S, 2, OUTPUT_2_COMPLEX);
|
||||
ssSetNumPWork(S, 0);
|
||||
|
||||
ssSetNumSampleTimes(S, 1);
|
||||
ssSetNumRWork(S, 0);
|
||||
ssSetNumIWork(S, 0);
|
||||
ssSetNumModes(S, 0);
|
||||
ssSetNumNonsampledZCs(S, 0);
|
||||
|
||||
ssSetSimulinkVersionGeneratedIn(S, "9.2");
|
||||
|
||||
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
|
||||
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
|
||||
SS_OPTION_USE_TLC_WITH_ACCELERATOR |
|
||||
SS_OPTION_WORKS_WITH_CODE_REUSE));
|
||||
}
|
||||
|
||||
/* Function: mdlInitializeSampleTimes =========================================
|
||||
* Abstract:
|
||||
* Specifiy the sample time.
|
||||
*/
|
||||
static void mdlInitializeSampleTimes(SimStruct *S)
|
||||
{
|
||||
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
|
||||
ssSetModelReferenceSampleTimeDefaultInheritance(S);
|
||||
ssSetOffsetTime(S, 0, 0.0);
|
||||
}
|
||||
|
||||
#define MDL_SET_INPUT_PORT_DATA_TYPE
|
||||
static void mdlSetInputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_OUTPUT_PORT_DATA_TYPE
|
||||
static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetOutputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_DEFAULT_PORT_DATA_TYPES
|
||||
static void mdlSetDefaultPortDataTypes(SimStruct *S)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, SS_DOUBLE);
|
||||
ssSetOutputPortDataType(S, 0, SS_DOUBLE);
|
||||
}
|
||||
|
||||
#define MDL_START /* Change to #undef to remove function */
|
||||
#if defined(MDL_START)
|
||||
/* Function: mdlStart =======================================================
|
||||
* Abstract:
|
||||
* This function is called once at start of model execution. If you
|
||||
* have states that should be initialized once, this is the place
|
||||
* to do it.
|
||||
*/
|
||||
static void mdlStart(SimStruct *S)
|
||||
{
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *max_width = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
uint8_T *text = (uint8_T *) ssGetOutputPortRealSignal(S, 0);
|
||||
uint8_T *seq = (uint8_T *) ssGetOutputPortRealSignal(S, 1);
|
||||
uint8_T *severity = (uint8_T *) ssGetOutputPortRealSignal(S, 2);
|
||||
const int_T y_width = ssGetOutputPortWidth(S, 0);
|
||||
|
||||
hal_status_text_Outputs_wrapper(max_width, text, seq, severity, y_width);
|
||||
|
||||
}
|
||||
|
||||
/* Function: mdlTerminate =====================================================
|
||||
* Abstract:
|
||||
* In this function, you should perform any actions that are necessary
|
||||
* at the termination of a simulation. For example, if memory was
|
||||
* allocated in mdlStart, this is the place to free it.
|
||||
*/
|
||||
static void mdlTerminate(SimStruct *S)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
|
||||
#include "simulink.c" /* MEX-file interface mechanism */
|
||||
#else
|
||||
#include "cg_sfun.h" /* Code generation registration function */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
%% File : hal_status_text.tlc
|
||||
%% Created : Tue Nov 01 14:35:23 2022
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_status_text.c".
|
||||
%%
|
||||
%% File generated by S-function Builder Block
|
||||
%%
|
||||
%% For more information on using the Target Language with the
|
||||
%% Simulink Coder, see the Target Language Compiler manual
|
||||
%% (under Simulink Coder) in the "Inlining S-Functions"
|
||||
%% chapter under the section and subsection:
|
||||
%% "Writing Block Target Files to Inline S-Functions",
|
||||
%% "Function-Based or Wrappered Code".
|
||||
%%
|
||||
%implements hal_status_text "C"
|
||||
%% Function: BlockTypeSetup ===================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Set up external references for wrapper functions in the
|
||||
%% generated code.
|
||||
%%
|
||||
%function BlockTypeSetup(block, system) Output
|
||||
%openfile externs
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void hal_status_text_Start_wrapper(void);
|
||||
|
||||
extern void hal_status_text_Outputs_wrapper(const uint8_T *max_width,
|
||||
uint8_T *text,
|
||||
uint8_T *seq,
|
||||
uint8_T *severity,
|
||||
const int_T y_width);
|
||||
|
||||
extern void hal_status_text_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Outputs ==========================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Code generation rules for mdlOutputs function.
|
||||
%%
|
||||
%function Outputs(block, system) Output
|
||||
%%
|
||||
%assign pu0 = LibBlockInputSignalAddr(0, "", "", 0)
|
||||
%assign py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||
%assign py1 = LibBlockOutputSignalAddr(1, "", "", 0)
|
||||
%assign py2 = LibBlockOutputSignalAddr(2, "", "", 0)
|
||||
%assign py_width = LibBlockOutputSignalWidth(0)
|
||||
hal_status_text_Outputs_wrapper(%<pu0>, %<py0>, %<py1>, %<py2>, %<py_width>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_status_text.tlc
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* File: hal_status_text_in.c
|
||||
*
|
||||
*
|
||||
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
|
||||
*
|
||||
* This file is an 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_defines_Changes_BEGIN
|
||||
* #define NAME 'replacement text'
|
||||
* %%% SFUNWIZ_defines_Changes_END
|
||||
*
|
||||
* DO NOT change NAME--Change the 'replacement text' only.
|
||||
*
|
||||
* For better compatibility with the Simulink Coder, the
|
||||
* "wrapper" S-function technique is used. This is discussed
|
||||
* in the Simulink Coder's Manual in the Chapter titled,
|
||||
* "Wrapper S-functions".
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Created: Tue Nov 01 14:35:32 2022
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_status_text_in
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 3
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME text
|
||||
#define INPUT_0_WIDTH DYNAMICALLY_SIZED
|
||||
#define INPUT_DIMS_0_COL 1
|
||||
#define INPUT_0_DTYPE uint8_T
|
||||
#define INPUT_0_COMPLEX COMPLEX_NO
|
||||
#define IN_0_FRAME_BASED FRAME_NO
|
||||
#define IN_0_BUS_BASED 0
|
||||
#define IN_0_BUS_NAME
|
||||
#define IN_0_DIMS 1-D
|
||||
#define INPUT_0_FEEDTHROUGH 1
|
||||
#define IN_0_ISSIGNED 0
|
||||
#define IN_0_WORDLENGTH 8
|
||||
#define IN_0_FIXPOINTSCALING 1
|
||||
#define IN_0_FRACTIONLENGTH 9
|
||||
#define IN_0_BIAS 0
|
||||
#define IN_0_SLOPE 0.125
|
||||
/* Input Port 1 */
|
||||
#define IN_PORT_1_NAME width
|
||||
#define INPUT_1_WIDTH 1
|
||||
#define INPUT_DIMS_1_COL 1
|
||||
#define INPUT_1_DTYPE uint8_T
|
||||
#define INPUT_1_COMPLEX COMPLEX_NO
|
||||
#define IN_1_FRAME_BASED FRAME_NO
|
||||
#define IN_1_BUS_BASED 0
|
||||
#define IN_1_BUS_NAME
|
||||
#define IN_1_DIMS 1-D
|
||||
#define INPUT_1_FEEDTHROUGH 1
|
||||
#define IN_1_ISSIGNED 0
|
||||
#define IN_1_WORDLENGTH 8
|
||||
#define IN_1_FIXPOINTSCALING 1
|
||||
#define IN_1_FRACTIONLENGTH 9
|
||||
#define IN_1_BIAS 0
|
||||
#define IN_1_SLOPE 0.125
|
||||
/* Input Port 2 */
|
||||
#define IN_PORT_2_NAME severity
|
||||
#define INPUT_2_WIDTH 1
|
||||
#define INPUT_DIMS_2_COL 1
|
||||
#define INPUT_2_DTYPE uint8_T
|
||||
#define INPUT_2_COMPLEX COMPLEX_NO
|
||||
#define IN_2_FRAME_BASED FRAME_NO
|
||||
#define IN_2_BUS_BASED 0
|
||||
#define IN_2_BUS_NAME
|
||||
#define IN_2_DIMS 1-D
|
||||
#define INPUT_2_FEEDTHROUGH 1
|
||||
#define IN_2_ISSIGNED 0
|
||||
#define IN_2_WORDLENGTH 8
|
||||
#define IN_2_FIXPOINTSCALING 1
|
||||
#define IN_2_FRACTIONLENGTH 9
|
||||
#define IN_2_BIAS 0
|
||||
#define IN_2_SLOPE 0.125
|
||||
|
||||
#define NUM_OUTPUTS 0
|
||||
|
||||
#define NPARAMS 0
|
||||
|
||||
#define SAMPLE_TIME_0 INHERITED_SAMPLE_TIME
|
||||
#define NUM_DISC_STATES 0
|
||||
#define DISC_STATES_IC [0]
|
||||
#define NUM_CONT_STATES 0
|
||||
#define CONT_STATES_IC [0]
|
||||
|
||||
#define SFUNWIZ_GENERATE_TLC 1
|
||||
#define SOURCEFILES "__SFB__;"
|
||||
#define PANELINDEX 8
|
||||
#define USE_SIMSTRUCT 0
|
||||
#define SHOW_COMPILE_STEPS 0
|
||||
#define CREATE_DEBUG_MEXFILE 0
|
||||
#define SAVE_CODE_ONLY 0
|
||||
#define SFUNWIZ_REVISION 3.0
|
||||
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
#include "simstruc.h"
|
||||
|
||||
|
||||
extern void hal_status_text_in_Outputs_wrapper(const uint8_T *text,
|
||||
const uint8_T *width,
|
||||
const uint8_T *severity,
|
||||
const int_T u_width);
|
||||
/*====================*
|
||||
* S-function methods *
|
||||
*====================*/
|
||||
/* Function: mdlInitializeSizes ===============================================
|
||||
* Abstract:
|
||||
* Setup sizes of the various vectors.
|
||||
*/
|
||||
static void mdlInitializeSizes(SimStruct *S)
|
||||
{
|
||||
|
||||
DECL_AND_INIT_DIMSINFO(inputDimsInfo);
|
||||
DECL_AND_INIT_DIMSINFO(outputDimsInfo);
|
||||
ssSetNumSFcnParams(S, NPARAMS);
|
||||
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
|
||||
return; /* Parameter mismatch will be reported by Simulink */
|
||||
}
|
||||
|
||||
ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
|
||||
|
||||
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
|
||||
|
||||
ssSetNumContStates(S, NUM_CONT_STATES);
|
||||
ssSetNumDiscStates(S, NUM_DISC_STATES);
|
||||
|
||||
|
||||
if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
|
||||
/* Input Port 0 */
|
||||
ssSetInputPortWidth(S, 0, INPUT_0_WIDTH);
|
||||
ssSetInputPortDataType(S, 0, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/
|
||||
|
||||
/* Input Port 1 */
|
||||
ssSetInputPortWidth(S, 1, INPUT_1_WIDTH);
|
||||
ssSetInputPortDataType(S, 1, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/
|
||||
|
||||
/* Input Port 2 */
|
||||
ssSetInputPortWidth(S, 2, INPUT_2_WIDTH);
|
||||
ssSetInputPortDataType(S, 2, SS_UINT8);
|
||||
ssSetInputPortComplexSignal(S, 2, INPUT_2_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/
|
||||
|
||||
|
||||
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||
ssSetNumPWork(S, 0);
|
||||
|
||||
ssSetNumSampleTimes(S, 1);
|
||||
ssSetNumRWork(S, 0);
|
||||
ssSetNumIWork(S, 0);
|
||||
ssSetNumModes(S, 0);
|
||||
ssSetNumNonsampledZCs(S, 0);
|
||||
|
||||
ssSetSimulinkVersionGeneratedIn(S, "9.2");
|
||||
|
||||
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
|
||||
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
|
||||
SS_OPTION_USE_TLC_WITH_ACCELERATOR |
|
||||
SS_OPTION_WORKS_WITH_CODE_REUSE));
|
||||
}
|
||||
|
||||
/* Function: mdlInitializeSampleTimes =========================================
|
||||
* Abstract:
|
||||
* Specifiy the sample time.
|
||||
*/
|
||||
static void mdlInitializeSampleTimes(SimStruct *S)
|
||||
{
|
||||
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
|
||||
ssSetModelReferenceSampleTimeDefaultInheritance(S);
|
||||
ssSetOffsetTime(S, 0, 0.0);
|
||||
}
|
||||
|
||||
#define MDL_SET_INPUT_PORT_DATA_TYPE
|
||||
static void mdlSetInputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_OUTPUT_PORT_DATA_TYPE
|
||||
static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||
{
|
||||
ssSetOutputPortDataType(S, 0, dType);
|
||||
}
|
||||
|
||||
#define MDL_SET_DEFAULT_PORT_DATA_TYPES
|
||||
static void mdlSetDefaultPortDataTypes(SimStruct *S)
|
||||
{
|
||||
ssSetInputPortDataType(S, 0, SS_DOUBLE);
|
||||
ssSetOutputPortDataType(S, 0, SS_DOUBLE);
|
||||
}
|
||||
|
||||
#define MDL_START /* Change to #undef to remove function */
|
||||
#if defined(MDL_START)
|
||||
/* Function: mdlStart =======================================================
|
||||
* Abstract:
|
||||
* This function is called once at start of model execution. If you
|
||||
* have states that should be initialized once, this is the place
|
||||
* to do it.
|
||||
*/
|
||||
static void mdlStart(SimStruct *S)
|
||||
{
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *text = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
const uint8_T *width = (uint8_T *) ssGetInputPortRealSignal(S, 1);
|
||||
const uint8_T *severity = (uint8_T *) ssGetInputPortRealSignal(S, 2);
|
||||
const int_T u_width = ssGetInputPortWidth(S, 0);
|
||||
|
||||
hal_status_text_in_Outputs_wrapper(text, width, severity, u_width);
|
||||
|
||||
}
|
||||
|
||||
/* Function: mdlTerminate =====================================================
|
||||
* Abstract:
|
||||
* In this function, you should perform any actions that are necessary
|
||||
* at the termination of a simulation. For example, if memory was
|
||||
* allocated in mdlStart, this is the place to free it.
|
||||
*/
|
||||
static void mdlTerminate(SimStruct *S)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
|
||||
#include "simulink.c" /* MEX-file interface mechanism */
|
||||
#else
|
||||
#include "cg_sfun.h" /* Code generation registration function */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
%% File : hal_status_text_in.tlc
|
||||
%% Created : Tue Nov 01 14:35:32 2022
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_status_text_in.c".
|
||||
%%
|
||||
%% File generated by S-function Builder Block
|
||||
%%
|
||||
%% For more information on using the Target Language with the
|
||||
%% Simulink Coder, see the Target Language Compiler manual
|
||||
%% (under Simulink Coder) in the "Inlining S-Functions"
|
||||
%% chapter under the section and subsection:
|
||||
%% "Writing Block Target Files to Inline S-Functions",
|
||||
%% "Function-Based or Wrappered Code".
|
||||
%%
|
||||
%implements hal_status_text_in "C"
|
||||
%% Function: BlockTypeSetup ===================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Set up external references for wrapper functions in the
|
||||
%% generated code.
|
||||
%%
|
||||
%function BlockTypeSetup(block, system) Output
|
||||
%openfile externs
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void hal_status_text_in_Start_wrapper(void);
|
||||
|
||||
extern void hal_status_text_in_Outputs_wrapper(const uint8_T *text,
|
||||
const uint8_T *width,
|
||||
const uint8_T *severity,
|
||||
const int_T u_width);
|
||||
|
||||
extern void hal_status_text_in_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Outputs ==========================================================
|
||||
%%
|
||||
%% Purpose:
|
||||
%% Code generation rules for mdlOutputs function.
|
||||
%%
|
||||
%function Outputs(block, system) Output
|
||||
%%
|
||||
%assign pu0 = LibBlockInputSignalAddr(0, "", "", 0)
|
||||
%assign pu1 = LibBlockInputSignalAddr(1, "", "", 0)
|
||||
%assign pu2 = LibBlockInputSignalAddr(2, "", "", 0)
|
||||
%assign pu_width = LibBlockInputSignalWidth(0)
|
||||
hal_status_text_in_Outputs_wrapper(%<pu0>, %<pu1>, %<pu2>, %<pu_width>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_status_text_in.tlc
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
#include <string.h>
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Create external references here.
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
extern uint8_t status_text_seq;
|
||||
extern uint8_t status_text_severity;
|
||||
extern uint8_t status_text_txt[50];
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_status_text_in_Outputs_wrapper(const uint8_T *text,
|
||||
const uint8_T *width,
|
||||
const uint8_T *severity,
|
||||
const int_T u_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
++status_text_seq;
|
||||
status_text_severity = severity[0];
|
||||
memcpy(status_text_txt, text, width[0]<50?width[0]:50);
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
/*
|
||||
* 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 u_width 1
|
||||
|
||||
/*
|
||||
* Create external references here.
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
void status_text(unsigned char *seq, unsigned char *severity, unsigned char *text, unsigned char max_width)
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_status_text_Outputs_wrapper(const uint8_T *max_width,
|
||||
uint8_T *text,
|
||||
uint8_T *seq,
|
||||
uint8_T *severity,
|
||||
const int_T y_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
status_text(seq, severity, text, max_width[0]);
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user