148 lines
3.9 KiB
C
148 lines
3.9 KiB
C
|
|
/*
|
|
* 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 */
|
|
#define y_width 1
|
|
|
|
/*
|
|
* Create external references here.
|
|
*
|
|
*/
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
#ifdef HAL_IMPL
|
|
#define REC_ZONE_LEN (2000)
|
|
extern uint8_t rec_zone[2][REC_ZONE_LEN];
|
|
extern int rec_sel;
|
|
extern int rec_head[2];
|
|
|
|
static int FAT_REC_write(uint8_t *buff, const uint16_t len)
|
|
{
|
|
if (rec_head[rec_sel] < REC_ZONE_LEN)
|
|
{
|
|
for (int i=0u;i<len;++i)
|
|
{
|
|
rec_zone[rec_sel][rec_head[rec_sel]++] = buff[i];
|
|
if (rec_head[rec_sel] >= REC_ZONE_LEN)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
|
|
/*
|
|
* Start function
|
|
*
|
|
*/
|
|
void hal_uart_out_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_out_Outputs_wrapper(uint8_T *buff,
|
|
const uint16_T *len,
|
|
const uint8_T *sep,
|
|
int32_T *ErrorCode,
|
|
const uint8_T *uart_id, const int_T p_width0,
|
|
const int_T u_width)
|
|
{
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
|
#ifdef HAL_IMPL
|
|
/* ***********************************************
|
|
* push all data to this uart output queue;
|
|
*
|
|
* inputs:
|
|
* buff - data array to be sent
|
|
* len[0] - available length in the data array
|
|
* sep[0] - it means the data array updated when sep[0] changed,
|
|
* uart_id[0] - uart FIFO device which is required to send data
|
|
*
|
|
* output:
|
|
* ErrorCode[0] - return zero for success, others for failail.
|
|
*
|
|
* constant:
|
|
* u_width - the maximum size of buff, do not read buff out of range.
|
|
*************************************************/
|
|
ErrorCode[0] = -1;
|
|
static uint8_T seq_last[16];
|
|
switch (uart_id[0])
|
|
{
|
|
case 0:
|
|
// TODO write all data to fifo
|
|
if (sep[0] != seq_last[uart_id[0]] && UART_TX_FIFO_write(&uart2_TELEM1_tx, (uint8_t *)buff, len[0]))
|
|
{
|
|
seq_last[uart_id[0]] = sep[0];
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case 1:
|
|
// TODO write all data to fifo
|
|
if (sep[0] != seq_last[uart_id[0]] && UART_TX_FIFO_write(&uart6_TELEM2_tx, (uint8_t *)buff, len[0]))
|
|
{
|
|
seq_last[uart_id[0]] = sep[0];
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case 2:
|
|
// TODO write all data to fifo
|
|
if (sep[0] != seq_last[uart_id[0]] && UART_TX_FIFO_write(&uart3_tx, (uint8_t *)buff, len[0]))
|
|
{
|
|
seq_last[uart_id[0]] = sep[0];
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case 4:
|
|
// TODO write all data to fifo
|
|
if (sep[0] != seq_last[uart_id[0]] && !FAT_REC_write((uint8_t *)buff, len[0]))
|
|
{
|
|
seq_last[uart_id[0]] = sep[0];
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
case 3:
|
|
// TODO write all data to fifo
|
|
if (sep[0] != seq_last[uart_id[0]] && UART_TX_FIFO_write(&uart7_DBG_tx, (uint8_t *)buff, len[0]))
|
|
{
|
|
seq_last[uart_id[0]] = sep[0];
|
|
ErrorCode[0] = 0;
|
|
}
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
#else
|
|
/* dummy function for generate mex file for sim*/
|
|
ErrorCode[0] = 0;
|
|
#endif
|
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
|
}
|
|
|
|
|