support EF3Lite
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
|
||||
/*
|
||||
* 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 "DrvAdcEx.h"
|
||||
#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 */
|
||||
int is_analog_input_init = 0;
|
||||
|
||||
void analog_input_init()
|
||||
{
|
||||
if (!is_analog_input_init)
|
||||
{
|
||||
#ifdef HAL_IMPL
|
||||
//TODO
|
||||
is_analog_input_init = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
/*
|
||||
* Start function
|
||||
*
|
||||
*/
|
||||
void hal_ai_Start_wrapper(void)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
analog_input_init();
|
||||
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
/*
|
||||
* Output function
|
||||
*
|
||||
*/
|
||||
void hal_ai_Outputs_wrapper(const uint16_T *start_idx,
|
||||
uint16_T *AI,
|
||||
int32_T *ErrorCode,
|
||||
const int_T y_width)
|
||||
{
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
ErrorCode[0] = -1;
|
||||
if (is_analog_input_init)
|
||||
{
|
||||
#ifdef HAL_IMPL
|
||||
/*
|
||||
* input *AI* from ADC channels from *start_idx* to *start_idx*+y_width-1.
|
||||
*
|
||||
* ErrorCode - return zero on success, otherwise nonzero on failures.
|
||||
*/
|
||||
// TODO set analog inputs
|
||||
if(start_idx[0]+y_width-1 > 4)
|
||||
ErrorCode[0] = 1;
|
||||
else
|
||||
{
|
||||
for(uint8_T i = start_idx[0]; i < start_idx[0]+y_width; i++)
|
||||
{
|
||||
AI[i] = g_Voltage[i]*100; //单位 0.01v g_Voltage0-4分别代表:排线AD1-AD4电压、飞控电压
|
||||
ErrorCode[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user