Files
slhal/X7/hal_uart_in_wrapper.c
T

102 lines
2.4 KiB
C
Raw Normal View History

2020-10-18 19:46:38 +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 "uart_fifos.h"
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Start function
*
*/
void hal_uart_in_Start_wrapper(const uint8_T *uart_id, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
#ifdef HAL_IMPL
// initialize_uart_device(uart_id[0]);
#endif
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Output function
*
*/
void hal_uart_in_Outputs_wrapper(uint8_T *Data,
uint16_T *Data_len,
int32_T *ErrorCode,
const uint8_T *uart_id, const int_T p_width0,
const int_T y_width)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
#ifdef HAL_IMPL
/* **********************************************************
* collect all data from this uart and push to Data buffer;
*
* parameter:
* uart_id - uart FIFO device to read
*
* outputs:
* Data - read all FIFO data and write to Data array
* Data_len[0] - the number of written data
* ErrorCode[0] - return zero for success, others for failail.
*
* constant:
* y_width - maximum length to write to Data array
************************************************************/
Data_len[0] = 0u;
ErrorCode[0] = -1;
switch (uart_id[0])
{
case 0:
Data_len[0] = UART_RX_FIFO_read(&uart2_TELEM1_rx, Data, y_width);
ErrorCode[0] = 0;
break;
case 1:
Data_len[0] = UART_RX_FIFO_read(&uart6_TELEM2_rx, Data, y_width);
ErrorCode[0] = 0;
break;
case 2:
Data_len[0] = UART_RX_FIFO_read(&uart3_rx, Data, y_width);
ErrorCode[0] = 0;
break;
2021-01-09 13:55:07 +08:00
case 3:
Data_len[0] = UART_RX_FIFO_read(&uart7_DBG_rx, Data, y_width);
ErrorCode[0] = 0;
break;
2020-10-18 19:46:38 +08:00
}
#else
/* dummy function for generate mex file for sim*/
Data_len[0] = 0u;
ErrorCode[0] = 0;
#endif
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}