Files
slhal/B3_AP/hal_can_transfer_wrapper.c
T
2020-09-18 11:42:54 +08:00

77 lines
1.4 KiB
C

/*
* Include Files
*
*/
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif
#include "hal_can_transfer_bus.h"
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#ifdef HAL_IMPL
#include "can_devs.h"
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define u_width 1
#define y_width 1
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
#ifdef HAL_IMPL
static int32_T pushMsg(CAN_BUS_t *can_bus, const CAN_MESSAGE_BUS *msg)
{
uint32_t ide;
if (msg->Extended)
{
ide = CAN_ID_EXT;
}
else
{
ide = CAN_ID_STD;
}
if ( CAN_BUS_transfer(can_bus, ide, msg->ID, msg->Data, msg->Length))
{
return 0;
}
return -1;
}
#endif
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Output function
*
*/
void hal_can_transfer_Outputs_wrapper(const CAN_MESSAGE_BUS *msg,
int32_T *ErrorCode,
const uint8_T *canbus_id, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
ErrorCode[0] = -1;
#ifdef HAL_IMPL
switch (canbus_id[0])
{
case 0:
ErrorCode[0] = pushMsg(&can_bus1, msg);
break;
case 1:
ErrorCode[0] = pushMsg(&can_bus3, msg);
break;
default:
break;
}
#endif
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}