132 lines
2.3 KiB
C
132 lines
2.3 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 "spi_devs.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 magn_inited[3];
|
|
|
|
void initialize_3axis_magn(uint8_t id)
|
|
{
|
|
switch (id)
|
|
{
|
|
case 0:
|
|
if (!magn_inited[0])
|
|
{
|
|
#ifdef HAL_IMPL
|
|
// TODO initialize 3axis-magn No.0
|
|
magn_inited[0] = 1;
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case 1:
|
|
if (!magn_inited[1])
|
|
{
|
|
#ifdef HAL_IMPL
|
|
// TODO initialize 3axis-magn No.1
|
|
magn_inited[1] = 1;
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case 2:
|
|
if (!magn_inited[2])
|
|
{
|
|
#ifdef HAL_IMPL
|
|
// TODO initialize 3axis-magn No.2
|
|
magn_inited[2] = 1;
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
|
|
/*
|
|
* Start function
|
|
*
|
|
*/
|
|
void hal_3axis_magn_Start_wrapper(const uint8_T *id, const int_T p_width0)
|
|
{
|
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
|
initialize_3axis_magn(id[0]);
|
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
|
}
|
|
/*
|
|
* Output function
|
|
*
|
|
*/
|
|
void hal_3axis_magn_Outputs_wrapper(HAL_magn_mG_t *magn,
|
|
int32_T *ErrorCode,
|
|
const uint8_T *id, const int_T p_width0)
|
|
{
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
ErrorCode[0] = -1;
|
|
switch (id[0])
|
|
{
|
|
case 0:
|
|
if (magn_inited[0])
|
|
{
|
|
#ifdef HAL_IMPL
|
|
if (cps_rm3100.success)
|
|
{
|
|
magn->x = cps_rm3100.magx;
|
|
magn->y = cps_rm3100.magy;
|
|
magn->z = cps_rm3100.magz;
|
|
magn->seq = cps_rm3100.seq;
|
|
|
|
ErrorCode[0] = 0;
|
|
}
|
|
else
|
|
ErrorCode[0] = -1;
|
|
#endif
|
|
}
|
|
break;
|
|
|
|
case 1:
|
|
if (magn_inited[1])
|
|
{
|
|
#ifdef HAL_IMPL
|
|
ErrorCode[0] = -1;
|
|
#endif
|
|
}
|
|
break;
|
|
case 2:
|
|
if (magn_inited[2])
|
|
{
|
|
#ifdef HAL_IMPL
|
|
ErrorCode[0] = -1;
|
|
#endif
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
}
|