93 lines
1.9 KiB
C
93 lines
1.9 KiB
C
|
|
|
||
|
|
/*
|
||
|
|
* Include Files
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
#if defined(MATLAB_MEX_FILE)
|
||
|
|
#include "tmwtypes.h"
|
||
|
|
#include "simstruc_types.h"
|
||
|
|
#else
|
||
|
|
#include "rtwtypes.h"
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#include "hal_api.h"
|
||
|
|
|
||
|
|
|
||
|
|
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
|
||
|
|
#ifdef HAL_IMPL
|
||
|
|
//#include "param_mgr.h"
|
||
|
|
#include "sbus_conn.h"
|
||
|
|
#include <string.h>
|
||
|
|
#endif
|
||
|
|
#include <stdint.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 */
|
||
|
|
int is_sbus_in_init[1];
|
||
|
|
|
||
|
|
void sbus_input_init(uint8_t id)
|
||
|
|
{
|
||
|
|
switch (id)
|
||
|
|
{
|
||
|
|
case 0:
|
||
|
|
if (!is_sbus_in_init[0])
|
||
|
|
{
|
||
|
|
#ifdef HAL_IMPL
|
||
|
|
//TODO config channels, update rate, etc. and bind properties
|
||
|
|
is_sbus_in_init[0] = 1;
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Start function
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
void hal_sbus_in_Start_wrapper(const uint8_T *id, const int_T p_width0)
|
||
|
|
{
|
||
|
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
||
|
|
sbus_input_init(id[0]);
|
||
|
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
||
|
|
}
|
||
|
|
/*
|
||
|
|
* Output function
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
void hal_sbus_in_Outputs_wrapper(HAL_sbus_in_t *sbus,
|
||
|
|
int32_T *ErrorCode,
|
||
|
|
const uint8_T *id, const int_T p_width0)
|
||
|
|
{
|
||
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||
|
|
ErrorCode[0] = -1;
|
||
|
|
/*
|
||
|
|
* input *AI* from ADC channels from *start_idx* to *start_idx*+y_width-1.
|
||
|
|
*
|
||
|
|
* ErrorCode - return zero on success, otherwise nonzero on failures.
|
||
|
|
*/
|
||
|
|
switch (id[0])
|
||
|
|
{
|
||
|
|
case 0u:
|
||
|
|
if (is_sbus_in_init[0])
|
||
|
|
{
|
||
|
|
#ifdef HAL_IMPL
|
||
|
|
sbus->valid = sbus_in.valid;
|
||
|
|
sbus->seq = sbus_in.seq;
|
||
|
|
sbus->id = id[0];
|
||
|
|
memcpy(sbus->channels, sbus_in.ch, sizeof(sbus->channels));
|
||
|
|
ErrorCode[0] = 0;
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||
|
|
}
|
||
|
|
|
||
|
|
|