Files
slhal/B3_AP/hal_do_wrapper.c
T

86 lines
1.7 KiB
C
Raw Normal View History

2020-07-28 11:39:26 +08:00
/*
* 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"
#include "gpio_devs.h"
#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 */
int is_discrete_output_init = 0;
void discrete_output_init()
{
if (!is_discrete_output_init)
{
#ifdef HAL_IMPL
//TODO
is_discrete_output_init = 1;
#endif
}
}
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Start function
*
*/
void hal_do_Start_wrapper(void)
{
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
discrete_output_init();
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Output function
*
*/
void hal_do_Outputs_wrapper(const boolean_T *DO,
const uint16_T *start_idx,
int32_T *ErrorCode,
const int_T u_width)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
ErrorCode[0] = -1;
if (is_discrete_output_init)
{
#ifdef HAL_IMPL
/*
* output *DO* to digital output devices from *start_idx* to *start_idx*+u_width-1.
*
* ErrorCode - return zero on success, otherwise nonzero on failures.
*/
for (int_T i=0;i<u_width;++i)
{
if (start_idx[0]+i < GPIO_WRITEPIN_SIZE)
{
GPIO_WritePin(start_idx[0]+i, DO[i]);
}
}
ErrorCode[0] = 0;
#endif
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}