Files
slhal/EF3Lite/hal_general_out_wrapper.c
T
2020-04-13 15:19:23 +08:00

94 lines
2.0 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 <stdint.h>
#include <string.h>
/* %%%-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 */
typedef int (*genral_out_ptr)(const uint8_t *packed_out, const int u_width, void **pW);
#ifdef HAL_IMPL
extern int demo_init_func(void **pW);
#else
int demo_init_func(void **pW)
{
}
#endif
int demo_out_func(const uint8_t *packed_out, const int u_width, void **pW)
{
return 0;
}
//TODO add other init/output functions
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Start function
*
*/
void hal_general_out_Start_wrapper(void **pW,
const uint8_T *device_id, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
int *valid = (int *)&pW[0]; /* 0-invalid; 1-valid; */
genral_out_ptr *func = (genral_out_ptr *)&pW[1];
valid[0] = 0;
if (strncmp(device_id, "demo", p_width0))
{
if (!demo_init_func(&pW[2]))
{
*valid = 1;
*func = &demo_out_func;
}
}
//TODO add other cases
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Output function
*
*/
void hal_general_out_Outputs_wrapper(const uint8_T *packed_out,
int32_T *ErrorCode,
void **pW,
const uint8_T *device_id, const int_T p_width0,
const int_T u_width)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
int *valid = (int *)&pW[0]; /* 0-invalid; 1-valid; */
if (valid[0])
{
genral_out_ptr func = (genral_out_ptr)pW[1];
ErrorCode[0] = (*func)(packed_out, u_width, &pW[2]);
}
else
{
ErrorCode[0] = -1;
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}