276 lines
7.9 KiB
C
276 lines
7.9 KiB
C
|
|
/*
|
|
* 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 "param_mgr.h"
|
|
#endif
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
|
|
|
/*
|
|
* Create external references here.
|
|
*
|
|
*/
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
typedef enum PROP_TYPE
|
|
{
|
|
PROP_ARRAY_UINT8 = 1, /* 8-bit unsigned integer | */
|
|
PROP_ARRAY_INT8 = 2, /* 8-bit signed integer | */
|
|
PROP_ARRAY_UINT16 = 3, /* 16-bit unsigned integer | */
|
|
PROP_ARRAY_INT16 = 4, /* 16-bit signed integer | */
|
|
PROP_ARRAY_UINT32 = 5, /* 32-bit unsigned integer | */
|
|
PROP_ARRAY_INT32 = 6, /* 32-bit signed integer | */
|
|
PROP_ARRAY_REAL32 = 7, /* 32-bit floating-point | */
|
|
PROP_FUNC_UINT8 = 8, /* 8-bit unsigned integer | */
|
|
PROP_FUNC_INT8 = 9, /* 8-bit signed integer | */
|
|
PROP_FUNC_UINT16 = 10, /* 16-bit unsigned integer | */
|
|
PROP_FUNC_INT16 = 11, /* 16-bit signed integer | */
|
|
PROP_FUNC_UINT32 = 12, /* 32-bit unsigned integer | */
|
|
PROP_FUNC_INT32 = 13, /* 32-bit signed integer | */
|
|
PROP_FUNC_REAL32 = 14, /* 32-bit floating-point | */
|
|
} PROP_TYPE;
|
|
|
|
typedef int8_t (*get_prop_b_func_ptr)(int index, void *paramter);
|
|
typedef uint8_t (*get_prop_B_func_ptr)(int index, void *paramter);
|
|
typedef int16_t (*get_prop_h_func_ptr)(int index, void *paramter);
|
|
typedef uint16_t (*get_prop_H_func_ptr)(int index, void *paramter);
|
|
typedef int32_t (*get_prop_i_func_ptr)(int index, void *paramter);
|
|
typedef uint32_t (*get_prop_I_func_ptr)(int index, void *paramter);
|
|
typedef float (*get_prop_f_func_ptr)(int index, void *paramter);
|
|
|
|
float RPM0[4];
|
|
|
|
float RPM1(int index, void *paramter)
|
|
{
|
|
(void *)paramter;
|
|
|
|
return RPM0[index];
|
|
}
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
|
|
/*
|
|
* Start function
|
|
*
|
|
*/
|
|
void hal_sen_read_Start_wrapper(void **pW,
|
|
const uint8_T *name, const int_T p_width0)
|
|
{
|
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
|
/* initialize code to bind property; */
|
|
int *valid = (int *)&pW[0]; /* 0-invalid; 1-valid; */
|
|
PROP_TYPE *type = (PROP_TYPE *)&pW[1];
|
|
int *len = (int *)&pW[2]; /* parameter length; */
|
|
void **val_ptr = &pW[3]; /* pointer to value array */
|
|
void **parameter = &pW[4]; /* parameter for function */
|
|
|
|
/* set default pW values */
|
|
*valid = 0;
|
|
*type = 0;
|
|
*val_ptr = NULL;
|
|
*parameter = NULL;
|
|
*len = 0;
|
|
if (strncmp(name, "RPM0", p_width0))
|
|
{
|
|
*valid = 1;
|
|
*type = PROP_ARRAY_REAL32;
|
|
*len = 4;
|
|
*val_ptr = &RPM0;
|
|
}
|
|
else if (strncmp(name, "RPM1", p_width0))
|
|
{
|
|
*valid = 1;
|
|
*type = PROP_FUNC_REAL32;
|
|
*len = 4;
|
|
*val_ptr = &RPM1;
|
|
}
|
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
|
}
|
|
/*
|
|
* Output function
|
|
*
|
|
*/
|
|
void hal_sen_read_Outputs_wrapper(real32_T *value,
|
|
int32_T *ErrorCode,
|
|
void **pW,
|
|
const uint8_T *name, const int_T p_width0,
|
|
const int_T y_width)
|
|
{
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
/* get binded property value; */
|
|
ErrorCode[0] = -1;
|
|
|
|
int *valid = (int *)&pW[0];
|
|
if (*valid)
|
|
{
|
|
int *len = (int *)&pW[2];
|
|
if (y_width > *len)
|
|
{
|
|
ErrorCode[0] = -2;
|
|
}
|
|
else
|
|
{
|
|
int i;
|
|
PROP_TYPE *type = (PROP_TYPE *)&pW[1];
|
|
switch (*type)
|
|
{
|
|
case PROP_ARRAY_UINT8:
|
|
{
|
|
uint8_t *val = *(uint8_t **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_ARRAY_INT8:
|
|
{
|
|
int8_t *val = *(int8_t **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_ARRAY_UINT16:
|
|
{
|
|
uint16_t *val = *(uint16_t **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_ARRAY_INT16:
|
|
{
|
|
int16_t *val = *(int16_t **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_ARRAY_UINT32:
|
|
{
|
|
uint32_t *val = *(uint32_t **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_ARRAY_INT32:
|
|
{
|
|
int32_t *val = *(int32_t **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_ARRAY_REAL32:
|
|
{
|
|
float *val = *(float **)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = val[i];
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_UINT8:
|
|
{
|
|
get_prop_B_func_ptr func = *(get_prop_B_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)(*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_INT8:
|
|
{
|
|
get_prop_b_func_ptr func = *(get_prop_b_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)(*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_UINT16:
|
|
{
|
|
get_prop_H_func_ptr func = *(get_prop_H_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)(*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_INT16:
|
|
{
|
|
get_prop_h_func_ptr func = *(get_prop_h_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)(*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_UINT32:
|
|
{
|
|
get_prop_I_func_ptr func = *(get_prop_I_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)(*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_INT32:
|
|
{
|
|
get_prop_i_func_ptr func = *(get_prop_i_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (float)(*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case PROP_FUNC_REAL32:
|
|
{
|
|
get_prop_f_func_ptr func = *(get_prop_f_func_ptr *)&pW[3];
|
|
for (i = 0; i < y_width; ++i)
|
|
{
|
|
value[i] = (*func)(i, pW[4]);
|
|
}
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
}
|
|
|
|
|