update rec
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -26,14 +26,14 @@
|
||||
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Created: Sun Sep 06 22:13:25 2020
|
||||
* Created: Wed Oct 14 12:13:07 2020
|
||||
*/
|
||||
|
||||
#define S_FUNCTION_LEVEL 2
|
||||
#define S_FUNCTION_NAME hal_rec
|
||||
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#define NUM_INPUTS 1
|
||||
#define NUM_INPUTS 2
|
||||
/* Input Port 0 */
|
||||
#define IN_PORT_0_NAME id
|
||||
#define INPUT_0_WIDTH 1
|
||||
@@ -51,6 +51,23 @@
|
||||
#define IN_0_FRACTIONLENGTH 9
|
||||
#define IN_0_BIAS 0
|
||||
#define IN_0_SLOPE 0.125
|
||||
/* Input Port 1 */
|
||||
#define IN_PORT_1_NAME time_stamp
|
||||
#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 2
|
||||
/* Output Port 0 */
|
||||
@@ -108,6 +125,7 @@
|
||||
|
||||
|
||||
extern void hal_rec_Outputs_wrapper(const uint8_T *id,
|
||||
const uint32_T *time_stamp,
|
||||
uint8_T *pkg,
|
||||
uint16_T *len,
|
||||
const int_T y_width);
|
||||
@@ -130,19 +148,28 @@ static void mdlInitializeSizes(SimStruct *S)
|
||||
|
||||
ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
|
||||
|
||||
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
|
||||
ssSetOperatingPointCompliance(S, USE_DEFAULT_OPERATING_POINT);
|
||||
|
||||
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;
|
||||
/* Output Port 0 */
|
||||
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
|
||||
@@ -160,7 +187,7 @@ static void mdlInitializeSizes(SimStruct *S)
|
||||
ssSetNumModes(S, 0);
|
||||
ssSetNumNonsampledZCs(S, 0);
|
||||
|
||||
ssSetSimulinkVersionGeneratedIn(S, "9.2");
|
||||
ssSetSimulinkVersionGeneratedIn(S, "10.0");
|
||||
|
||||
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
|
||||
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
|
||||
@@ -217,11 +244,12 @@ static void mdlStart(SimStruct *S)
|
||||
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||
{
|
||||
const uint8_T *id = (uint8_T *) ssGetInputPortRealSignal(S, 0);
|
||||
const uint32_T *time_stamp = (uint32_T *) ssGetInputPortRealSignal(S, 1);
|
||||
uint8_T *pkg = (uint8_T *) ssGetOutputPortRealSignal(S, 0);
|
||||
uint16_T *len = (uint16_T *) ssGetOutputPortRealSignal(S, 1);
|
||||
const int_T y_width = ssGetOutputPortWidth(S, 0);
|
||||
|
||||
hal_rec_Outputs_wrapper(id, pkg, len, y_width);
|
||||
hal_rec_Outputs_wrapper(id, time_stamp, pkg, len, y_width);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
+4
-2
@@ -1,5 +1,5 @@
|
||||
%% File : hal_rec.tlc
|
||||
%% Created : Sun Sep 06 22:13:25 2020
|
||||
%% Created : Wed Oct 14 12:13:07 2020
|
||||
%%
|
||||
%% Description:
|
||||
%% Simulink Coder wrapper functions interface generated for
|
||||
@@ -31,6 +31,7 @@
|
||||
extern void hal_rec_Start_wrapper(void);
|
||||
|
||||
extern void hal_rec_Outputs_wrapper(const uint8_T *id,
|
||||
const uint32_T *time_stamp,
|
||||
uint8_T *pkg,
|
||||
uint16_T *len,
|
||||
const int_T y_width);
|
||||
@@ -54,10 +55,11 @@
|
||||
%function Outputs(block, system) Output
|
||||
%%
|
||||
%assign pu0 = LibBlockInputSignalAddr(0, "", "", 0)
|
||||
%assign pu1 = LibBlockInputSignalAddr(1, "", "", 0)
|
||||
%assign py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||
%assign py1 = LibBlockOutputSignalAddr(1, "", "", 0)
|
||||
%assign py_width = LibBlockOutputSignalWidth(0)
|
||||
hal_rec_Outputs_wrapper(%<pu0>, %<py0>, %<py1>, %<py_width>);
|
||||
hal_rec_Outputs_wrapper(%<pu0>, %<pu1>, %<py0>, %<py1>, %<py_width>);
|
||||
%%
|
||||
%endfunction
|
||||
|
||||
|
||||
+33
-23
@@ -10,10 +10,10 @@
|
||||
#include "rtwtypes.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
#ifdef HAL_IMPL
|
||||
#include "param_pre.h"
|
||||
#endif
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
#define u_width 1
|
||||
|
||||
@@ -22,23 +22,29 @@
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
static void pack(uint8_T *pkg, uint16_T *len, const int_T y_width, uint8_T *src, uint16_T length)
|
||||
static void pack(uint8_T *pkg, uint16_T *len, const int_T y_width, uint8_T *ts, uint8_T *src, uint16_T length)
|
||||
{
|
||||
uint8_T sum;
|
||||
int16_T i;
|
||||
if (length > y_width - 1)
|
||||
{
|
||||
length = y_width - 1;
|
||||
}
|
||||
int16_T i,j;
|
||||
sum = 0;
|
||||
for (i = 0; i < length; ++i)
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
pkg[i] = src[i];
|
||||
pkg[i] = ts[i];
|
||||
sum += ts[i];
|
||||
}
|
||||
if (length > y_width - 5)
|
||||
{
|
||||
length = y_width - 5;
|
||||
}
|
||||
for (i = 0, j = 4; i < length; ++i,++j)
|
||||
{
|
||||
pkg[j] = src[i];
|
||||
sum += src[i];
|
||||
}
|
||||
pkg[i] = sum;
|
||||
len[0] = length+1;
|
||||
pkg[j] = sum;
|
||||
len[0] = length+5;
|
||||
}
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
@@ -46,20 +52,24 @@ static void pack(uint8_T *pkg, uint16_T *len, const int_T y_width, uint8_T *src,
|
||||
*
|
||||
*/
|
||||
void hal_rec_Outputs_wrapper(const uint8_T *id,
|
||||
uint8_T *pkg,
|
||||
uint16_T *len,
|
||||
const int_T y_width)
|
||||
const uint32_T *time_stamp,
|
||||
uint8_T *pkg,
|
||||
uint16_T *len,
|
||||
const int_T y_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
len[0] = 0;
|
||||
#ifdef HAL_IMPL
|
||||
uint8_T *src;
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
switch (id[0])
|
||||
{
|
||||
#ifdef HAL_IMPL
|
||||
case 1:
|
||||
pack(pkg, len, y_width, (uint8_t *)&rec_hi, sizeof(rec_hi));
|
||||
pack(pkg, len, y_width, (uint8_T *)time_stamp, (uint8_T *)&rec_hi, sizeof(rec_hi));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
default:
|
||||
pack(pkg, len, y_width, (uint8_T *)time_stamp, NULL, 0u);
|
||||
}
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user