new navram api
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* File: hal_nvram_cancel.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: Wed Mar 18 14:21:46 2020
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_nvram_cancel
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 2
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME nvram_id
|
||||
#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
|
||||
/* Input Port 1 */
|
||||
#define IN_PORT_1_NAME address
|
||||
#define INPUT_1_WIDTH 1
|
||||
#define INPUT_DIMS_1_COL 1
|
||||
#define INPUT_1_DTYPE uint32_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
|
||||
|
||||
#define NUM_OUTPUTS 1
|
||||
/* Output Port 0 */
|
||||
#define OUT_PORT_0_NAME ErrorCode
|
||||
#define OUTPUT_0_WIDTH 1
|
||||
#define OUTPUT_DIMS_0_COL 1
|
||||
#define OUTPUT_0_DTYPE int32_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
|
||||
|
||||
#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_nvram_cancel_Start_wrapper(void);
|
||||
extern void hal_nvram_cancel_Outputs_wrapper(const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
int32_T *ErrorCode);
|
||||
/*====================*
|
||||
* 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_UINT32);
|
||||
ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/
|
||||
|
||||
|
||||
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
|
||||
ssSetOutputPortDataType(S, 0, SS_INT32);
|
||||
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_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)
|
||||
{
|
||||
|
||||
hal_nvram_cancel_Start_wrapper();
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *nvram_id = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
const uint32_T *address = (uint32_T *) ssGetInputPortRealSignal(S, 1);
|
||||
int32_T *ErrorCode = (int32_T *) ssGetOutputPortRealSignal(S, 0);
|
||||
|
||||
hal_nvram_cancel_Outputs_wrapper(nvram_id, address, ErrorCode);
|
||||
|
||||
}
|
||||
|
||||
/* 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,70 @@
|
||||
%% File : hal_nvram_cancel.tlc
|
||||
%% Created : Wed Mar 18 14:21:46 2020
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_nvram_cancel.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_nvram_cancel "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_nvram_cancel_Start_wrapper(void);
|
||||
|
||||
extern void hal_nvram_cancel_Outputs_wrapper(const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
int32_T *ErrorCode);
|
||||
|
||||
extern void hal_nvram_cancel_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Start ============================================================
|
||||
%%
|
||||
%function Start(block, system) Output
|
||||
/* %<Type> Block: %<Name> */
|
||||
hal_nvram_cancel_Start_wrapper();
|
||||
%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 py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||
hal_nvram_cancel_Outputs_wrapper(%<pu0>, %<pu1>, %<py0>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_nvram_cancel.tlc
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* File: hal_nvram_read.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: Wed Mar 18 13:56:54 2020
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_nvram_read
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 3
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME nvram_id
|
||||
#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
|
||||
/* Input Port 1 */
|
||||
#define IN_PORT_1_NAME address
|
||||
#define INPUT_1_WIDTH 1
|
||||
#define INPUT_DIMS_1_COL 1
|
||||
#define INPUT_1_DTYPE uint32_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 read_len
|
||||
#define INPUT_2_WIDTH 1
|
||||
#define INPUT_DIMS_2_COL 1
|
||||
#define INPUT_2_DTYPE uint16_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 2
|
||||
/* Output Port 0 */
|
||||
#define OUT_PORT_0_NAME buffer
|
||||
#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 ErrorCode
|
||||
#define OUTPUT_1_WIDTH 1
|
||||
#define OUTPUT_DIMS_1_COL 1
|
||||
#define OUTPUT_1_DTYPE int32_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
|
||||
|
||||
#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_nvram_read_Start_wrapper(void);
|
||||
extern void hal_nvram_read_Outputs_wrapper(const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
const uint16_T *read_len,
|
||||
uint8_T *buffer,
|
||||
int32_T *ErrorCode,
|
||||
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;
|
||||
/* 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_UINT32);
|
||||
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_UINT16);
|
||||
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;
|
||||
/* 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_INT32);
|
||||
ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_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)
|
||||
{
|
||||
|
||||
hal_nvram_read_Start_wrapper();
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *nvram_id = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
const uint32_T *address = (uint32_T *) ssGetInputPortRealSignal(S, 1);
|
||||
const uint16_T *read_len = (uint16_T *) ssGetInputPortRealSignal(S, 2);
|
||||
uint8_T *buffer = (uint8_T *) ssGetOutputPortRealSignal(S, 0);
|
||||
int32_T *ErrorCode = (int32_T *) ssGetOutputPortRealSignal(S, 1);
|
||||
const int_T y_width = ssGetOutputPortWidth(S, 0);
|
||||
|
||||
hal_nvram_read_Outputs_wrapper(nvram_id, address, read_len, buffer, ErrorCode, 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,76 @@
|
||||
%% File : hal_nvram_read.tlc
|
||||
%% Created : Wed Mar 18 13:56:54 2020
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_nvram_read.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_nvram_read "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_nvram_read_Start_wrapper(void);
|
||||
|
||||
extern void hal_nvram_read_Outputs_wrapper(const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
const uint16_T *read_len,
|
||||
uint8_T *buffer,
|
||||
int32_T *ErrorCode,
|
||||
const int_T y_width);
|
||||
|
||||
extern void hal_nvram_read_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Start ============================================================
|
||||
%%
|
||||
%function Start(block, system) Output
|
||||
/* %<Type> Block: %<Name> */
|
||||
hal_nvram_read_Start_wrapper();
|
||||
%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 py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||
%assign py1 = LibBlockOutputSignalAddr(1, "", "", 0)
|
||||
%assign py_width = LibBlockOutputSignalWidth(0)
|
||||
hal_nvram_read_Outputs_wrapper(%<pu0>, %<pu1>, %<pu2>, %<py0>, %<py1>, %<py_width>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_nvram_read.tlc
|
||||
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* File: hal_nvram_write.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: Wed Mar 18 14:08:03 2020
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_nvram_write
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 4
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME buffer
|
||||
#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 nvram_id
|
||||
#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 address
|
||||
#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 write_len
|
||||
#define INPUT_3_WIDTH 1
|
||||
#define INPUT_DIMS_3_COL 1
|
||||
#define INPUT_3_DTYPE uint16_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
|
||||
|
||||
#define NUM_OUTPUTS 1
|
||||
/* Output Port 0 */
|
||||
#define OUT_PORT_0_NAME ErrorCode
|
||||
#define OUTPUT_0_WIDTH 1
|
||||
#define OUTPUT_DIMS_0_COL 1
|
||||
#define OUTPUT_0_DTYPE int32_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
|
||||
|
||||
#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_nvram_write_Start_wrapper(void);
|
||||
extern void hal_nvram_write_Outputs_wrapper(const uint8_T *buffer,
|
||||
const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
const uint16_T *write_len,
|
||||
int32_T *ErrorCode,
|
||||
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_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_UINT16);
|
||||
ssSetInputPortComplexSignal(S, 3, INPUT_3_COMPLEX);
|
||||
ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH);
|
||||
ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/
|
||||
|
||||
|
||||
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||
outputDimsInfo.width = OUTPUT_0_WIDTH;
|
||||
ssSetOutputPortDimensionInfo(S, 0, &outputDimsInfo);
|
||||
ssSetOutputPortFrameData(S, 0, OUT_0_FRAME_BASED);
|
||||
ssSetOutputPortDataType(S, 0, SS_INT32);
|
||||
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
|
||||
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_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));
|
||||
}
|
||||
|
||||
|
||||
#define MDL_SET_INPUT_PORT_DIMENSION_INFO
|
||||
void mdlSetInputPortDimensionInfo(SimStruct *S,
|
||||
int portIndex,
|
||||
const DimsInfo_T *dimsInfo)
|
||||
{
|
||||
DECL_AND_INIT_DIMSINFO(portDimsInfo);
|
||||
int_T dims[2] = { OUTPUT_0_WIDTH, 1 };
|
||||
bool frameIn = (ssGetInputPortFrameData(S, 0) == FRAME_YES);
|
||||
|
||||
ssSetInputPortDimensionInfo(S, 0, dimsInfo);
|
||||
|
||||
if (ssGetOutputPortNumDimensions(S, 0) == (-1)) {
|
||||
/* the output port has not been set */
|
||||
|
||||
portDimsInfo.width = 1;
|
||||
portDimsInfo.numDims = frameIn ? 2 : 1;
|
||||
portDimsInfo.dims = frameIn ? dims : &portDimsInfo.width;
|
||||
|
||||
ssSetOutputPortDimensionInfo(S, 0, &portDimsInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define MDL_SET_OUTPUT_PORT_DIMENSION_INFO
|
||||
void mdlSetOutputPortDimensionInfo(SimStruct *S,
|
||||
int_T portIndex,
|
||||
const DimsInfo_T *dimsInfo)
|
||||
{
|
||||
DECL_AND_INIT_DIMSINFO(portDimsInfo);
|
||||
int_T dims[2] = { OUTPUT_0_WIDTH, 1 };
|
||||
bool frameOut = (ssGetOutputPortFrameData(S, 0) == FRAME_YES);
|
||||
|
||||
ssSetOutputPortDimensionInfo(S, 0, dimsInfo);
|
||||
|
||||
if (ssGetInputPortNumDimensions(S, 0) == (-1)) {
|
||||
/* the input port has not been set */
|
||||
|
||||
portDimsInfo.width = 1;
|
||||
portDimsInfo.numDims = frameOut ? 2 : 1;
|
||||
portDimsInfo.dims = frameOut ? dims : &portDimsInfo.width;
|
||||
|
||||
ssSetInputPortDimensionInfo(S, 0, &portDimsInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define MDL_SET_DEFAULT_PORT_DIMENSION_INFO
|
||||
static void mdlSetDefaultPortDimensionInfo(SimStruct *S)
|
||||
{
|
||||
DECL_AND_INIT_DIMSINFO(portDimsInfo);
|
||||
int_T dims[2] = { 1, 1 };
|
||||
bool frame = (ssGetInputPortFrameData(S, 0) == FRAME_YES) ||
|
||||
(ssGetOutputPortFrameData(S, 0) == FRAME_YES);
|
||||
|
||||
/* Neither the input nor the output ports have been set */
|
||||
|
||||
portDimsInfo.width = 1;
|
||||
portDimsInfo.numDims = frame ? 2 : 1;
|
||||
portDimsInfo.dims = frame ? dims : &portDimsInfo.width;
|
||||
|
||||
if (ssGetInputPortNumDimensions(S, 0) == (-1)) {
|
||||
ssSetInputPortDimensionInfo(S, 0, &portDimsInfo);
|
||||
}
|
||||
|
||||
if (ssGetOutputPortNumDimensions(S, 0) == (-1)) {
|
||||
ssSetInputPortDimensionInfo(S, 0, &portDimsInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
||||
hal_nvram_write_Start_wrapper();
|
||||
}
|
||||
#endif /* MDL_START */
|
||||
|
||||
/* Function: mdlOutputs =======================================================
|
||||
*
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *buffer = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
const uint8_T *nvram_id = (uint8_T *) ssGetInputPortRealSignal(S, 1);
|
||||
const uint32_T *address = (uint32_T *) ssGetInputPortRealSignal(S, 2);
|
||||
const uint16_T *write_len = (uint16_T *) ssGetInputPortRealSignal(S, 3);
|
||||
int32_T *ErrorCode = (int32_T *) ssGetOutputPortRealSignal(S, 0);
|
||||
const int_T u_width = ssGetInputPortWidth(S, 0);
|
||||
|
||||
hal_nvram_write_Outputs_wrapper(buffer, nvram_id, address, write_len, ErrorCode, 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,76 @@
|
||||
%% File : hal_nvram_write.tlc
|
||||
%% Created : Wed Mar 18 14:08:03 2020
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
%% S-function "hal_nvram_write.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_nvram_write "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_nvram_write_Start_wrapper(void);
|
||||
|
||||
extern void hal_nvram_write_Outputs_wrapper(const uint8_T *buffer,
|
||||
const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
const uint16_T *write_len,
|
||||
int32_T *ErrorCode,
|
||||
const int_T u_width);
|
||||
|
||||
extern void hal_nvram_write_Terminate_wrapper(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
%closefile externs
|
||||
%<LibCacheExtern(externs)>
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% Function: Start ============================================================
|
||||
%%
|
||||
%function Start(block, system) Output
|
||||
/* %<Type> Block: %<Name> */
|
||||
hal_nvram_write_Start_wrapper();
|
||||
%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 pu_width = LibBlockInputSignalWidth(0)
|
||||
%assign py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||
hal_nvram_write_Outputs_wrapper(%<pu0>, %<pu1>, %<pu2>, %<pu3>, %<py0>, %<pu_width>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
%% [EOF] hal_nvram_write.tlc
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
#ifdef HAL_IMPL
|
||||
/* include files */
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
#define u_width 1
|
||||
#define y_width 1
|
||||
|
||||
/*
|
||||
* Create external references here.
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
extern void initialize_navram_device(void);
|
||||
extern bool hal_api_navram = false;
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Start function
|
||||
*
|
||||
*/
|
||||
void hal_nvram_cancel_Start_wrapper(void)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
if (hal_api_navram)
|
||||
{
|
||||
initialize_navram_device();
|
||||
hal_api_navram = true;
|
||||
}
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_nvram_cancel_Outputs_wrapper(const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
int32_T *ErrorCode)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
/* ****************************************
|
||||
* Cancel to read/write NAVRAM device
|
||||
* this call should return immediately, so it's better to state the
|
||||
* backgournd task to do the real work.
|
||||
*
|
||||
* inputs:
|
||||
* nvram_id - NV-RAM device/proxy ID
|
||||
* address - Starting address to be write
|
||||
*
|
||||
* outputs:
|
||||
* ErrorCode - return 0 when success cancelling, otherwise return -1
|
||||
*/
|
||||
#else
|
||||
ErrorCode[0] = 0;
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
#ifdef HAL_IMPL
|
||||
/* include files */
|
||||
#endif
|
||||
/* %%%-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
|
||||
extern void initialize_navram_device(void);
|
||||
bool hal_api_navram = false;
|
||||
|
||||
void initialize_navram_device(void)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Start function
|
||||
*
|
||||
*/
|
||||
void hal_nvram_read_Start_wrapper(void)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
if (hal_api_navram)
|
||||
{
|
||||
initialize_navram_device();
|
||||
hal_api_navram = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_nvram_read_Outputs_wrapper(const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
const uint16_T *read_len,
|
||||
uint8_T *buffer,
|
||||
int32_T *ErrorCode,
|
||||
const int_T y_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
/* ****************************************
|
||||
* read from NAVRAM device
|
||||
* this call should return immediately, so it's better to state the
|
||||
* backgournd task to do the real work.
|
||||
*
|
||||
* inputs:
|
||||
* nvram_id - NV-RAM device/proxy ID
|
||||
* address - Starting address to be read
|
||||
* read_len - maxium bytes to be read
|
||||
*
|
||||
* outputs:
|
||||
* buffer - read data to buffer
|
||||
* ErrorCode - return 0 when read complete, otherwise
|
||||
* return remaining length when readling uncompletly,
|
||||
* return -1 on genral failures.
|
||||
* return -2 on busy(ocuppied).
|
||||
* return -3 on cancelled.
|
||||
*
|
||||
* constant:
|
||||
* y_width - the size of buffer, do not write overflow.
|
||||
*/
|
||||
#else
|
||||
ErrorCode[0] = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
#ifdef HAL_IMPL
|
||||
/* include files */
|
||||
#endif
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
#define y_width 1
|
||||
|
||||
/*
|
||||
* Create external references here.
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
extern void initialize_navram_device(void);
|
||||
extern bool hal_api_navram = false;
|
||||
#endif
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Start function
|
||||
*
|
||||
*/
|
||||
void hal_nvram_write_Start_wrapper(void)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
if (hal_api_navram)
|
||||
{
|
||||
initialize_navram_device();
|
||||
hal_api_navram = true;
|
||||
}
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_nvram_write_Outputs_wrapper(const uint8_T *buffer,
|
||||
const uint8_T *nvram_id,
|
||||
const uint32_T *address,
|
||||
const uint16_T *write_len,
|
||||
int32_T *ErrorCode,
|
||||
const int_T u_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
/* ****************************************
|
||||
* write to NAVRAM device
|
||||
* this call should return immediately, so it's better to state the
|
||||
* backgournd task to do the real work.
|
||||
*
|
||||
* inputs:
|
||||
* buffer - write data to buffer
|
||||
* nvram_id - NV-RAM device/proxy ID
|
||||
* address - Starting address to be write
|
||||
* read_len - maxium bytes to be write
|
||||
*
|
||||
* outputs:
|
||||
* ErrorCode - return 0 when write complete, otherwise
|
||||
* return remaining length when writting uncompletly,
|
||||
* return -1 on genral failures.
|
||||
* return -2 on busy(ocuppied).
|
||||
* return -3 on cancelled.
|
||||
*
|
||||
* constant:
|
||||
* u_width - the size of buffer, do not write overflow.
|
||||
*/
|
||||
#else
|
||||
ErrorCode[0] = 0;
|
||||
#endif
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user