📄 dt_rspfmttr.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
*
* Filename:
* ---------
* dt_rspfmttr.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file is intends for ....
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
*****************************************************************************/
#define DT_RSPFMTTR_C
#include <stdio.h>
#include <string.h>
#include "kal_release.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "stacklib.h" /* Basic type for dll, evshed, stacktimer */
#include "app_buff_alloc.h"
#include "stack_timer.h"
#include "event_shed.h"
#include "stack_config.h"
#include "stack_buff_pool.h"
#include "ctrl_buff_pool.h"
#include "tst_buff_pool.h"
#include "sysconf_statistics.h"
#include "dt_trc.h"
#include "uart_sw.h"
#include "dt_common_enum.h"
#include "dt_context.h"
#include "dt_utility.h"
#include "dt_rspfmttr.h"
extern void UART_ClrRxBuffer(UART_PORT port, module_type ownerid);
extern void UART_ClrTxBuffer(UART_PORT port, module_type ownerid);
extern int UART_GetOwnerID(UART_PORT port);
/*****************************************************************************
* FUNCTION
* dt_uart_send_data
*
* DESCRIPTION
* This is dt_uart_send_data function of L4C module.
* pass data from rmmi output queue to uart
*
* PARAMETERS
* none.
*
* RETURNS
* count number of bytes sent to uart
*
* GLOBALS AFFECTED
* none.
*****************************************************************************/
kal_uint16 dt_uart_send_data (kal_uint8 port)
{
kal_uint16 result;
kal_uint16 temp;
kal_uint16 len;
#ifndef UART_ENABLE
FILE *output;
#endif
kal_trace(TRACE_FUNC, FUNC_DT_UART_SEND_DATA_ENTRY);
len = DT_PTR->uart_output_queue.length;
if ((DT_PTR->uart_output_queue.head + len) > DT_MAX_DATA_OUTPUT_QUEUE_LENGTH)
{
temp = DT_MAX_DATA_OUTPUT_QUEUE_LENGTH - DT_PTR->uart_output_queue.head;
#ifdef UART_ENABLE
result = DT_UART_PutBytes (port,
&(DT_PTR->uart_output_queue.data
[DT_PTR->uart_output_queue.head]), temp, MOD_DT);
#else
output = fopen ("c:\\mcu_out.log", "a");
result = fprintf (output, "%s",
DT_PTR->uart_output_queue.data+DT_PTR->uart_output_queue.head);
#endif /* UART_ENABLE */
len -= temp;
#ifdef UART_ENABLE
if(result<temp)
{
DT_PTR->uart_output_queue.head += result;
DT_PTR->uart_output_queue.length -= result;
return result;
}
result += DT_UART_PutBytes (port,
DT_PTR->uart_output_queue.data, len,MOD_DT);
#else
result += fprintf (output, "%s", DT_PTR->uart_output_queue.data);
fclose (output);
#endif /* UART_ENABLE */
DT_PTR->uart_output_queue.head =
(DT_PTR->uart_output_queue.head + result) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH ;
DT_PTR->uart_output_queue.length -= result;
}
else
{
#ifdef UART_ENABLE
result = DT_UART_PutBytes (port,
&(DT_PTR->uart_output_queue.data
[DT_PTR->uart_output_queue.head]),
len, MOD_DT);
#else
output = fopen ("c:\\mcu_out.log", "a");
result = fprintf (output, "%s",
DT_PTR->uart_output_queue.data+DT_PTR->uart_output_queue.head);
fclose (output);
#endif /* UART_ENABLE */
DT_PTR->uart_output_queue.head += result;
DT_PTR->uart_output_queue.length -= result;
}
return result;
}
void dt_uart_write_data(kal_uint8 *buffer, kal_uint16 length, kal_bool stuff, kal_uint8 cid, kal_uint8 port)
{
kal_uint16 i;
kal_uint16 tail;
kal_uint16 temp;
kal_uint16 actual_write;
kal_trace(TRACE_FUNC, FUNC_DT_UART_WRITE_DATA_ENTRY);
/* we will clear our uart queue if we can not write to rmmi queue */
if(DT_MAX_DATA_OUTPUT_QUEUE_LENGTH - DT_PTR->uart_output_queue.length <= length)
{
#ifdef UART_ENABLE
kal_print("RMMI: ClrTxBuffer");
DT_UART_ClrTxBuffer(port, MOD_DT);
#endif
DT_PTR->uart_output_queue.head = 0;
DT_PTR->uart_output_queue.length = 0;
}
tail = (DT_PTR->uart_output_queue.head +
DT_PTR->uart_output_queue.length) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH ;
if (stuff == KAL_TRUE)
{
//for module: Maui_sw 9943
if(DT_PTR->rsp_mode.format != DT_NUM_PARTIAL_HEAD_TAIL)
{
DT_PTR->uart_output_queue.data
[(tail+0)% DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = DT_PTR->s_reg.s3;
DT_PTR->uart_output_queue.data
[(tail+1) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = DT_PTR->s_reg.s4;
for (i=0; i<length; i++)
{
DT_PTR->uart_output_queue.data
[(tail+2+i) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = *((kal_uint8 *)buffer+i);
}
DT_PTR->uart_output_queue.data
[(tail+2+length) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = DT_PTR->s_reg.s3;
DT_PTR->uart_output_queue.data
[(tail+3+length) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = DT_PTR->s_reg.s4;
DT_PTR->uart_output_queue.length += 4;
}
else
{ //for module: Maui_sw 9943
for (i=0; i<length; i++)
{
DT_PTR->uart_output_queue.data
[(tail+i) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = *((kal_uint8 *)buffer+i);
}
DT_PTR->uart_output_queue.data
[(tail+0+length) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = DT_PTR->s_reg.s3;
#ifdef __WINCE__
//RMMI_PTR->uart_output_queue[cid].data
// [(tail+1+length) % MAX_DATA_QUEUE_LENGTH] = RMMI_PTR->s_reg.s4;
(DT_PTR->uart_output_queue.length) ++;
#else
DT_PTR->uart_output_queue.data
[(tail+1+length) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = DT_PTR->s_reg.s4;
DT_PTR->uart_output_queue.length += 2;
#endif
}//for module: Maui_sw 9943
}
else
{
for (i=0; i<length; i++)
{
DT_PTR->uart_output_queue.data
[(tail+i) % DT_MAX_DATA_OUTPUT_QUEUE_LENGTH] = *((kal_uint8 *)buffer+i);
}
}
DT_PTR->uart_output_queue.length += length;
//if ((DT_PTR->uart_stop_send_flag & (0x01 << cid)) == 0)
if(DT_PTR->uart_stop_send_flag == KAL_FALSE)
{
temp = DT_PTR->uart_output_queue.length;
actual_write = dt_uart_send_data(port);
if (actual_write < temp)
{
//DT_PTR->uart_stop_send_flag |= (0x01 << cid);
DT_PTR->uart_stop_send_flag = KAL_TRUE;
}
}
return;
}
/*****************************************************************************
* FUNCTION
* dt_write_to_uart
*
* DESCRIPTION
* This is dt_write_to_uart function of L4C module.
* continue write until uart has no available space
* or rmmi output queue is empty
*
* PARAMETERS
* buffer IN data to be write to uart
* length IN number of bytes to be write to uart
* stuff IN need to pad CR & LF in front and back of data or not
*
* RETURNS
* none.
*
* GLOBALS AFFECTED
* none.
*****************************************************************************/
void dt_write_to_uart (kal_uint8 *buffer, kal_uint16 length, kal_bool stuff)
{
//kal_uint8 port;
kal_uint8 cid= 0;
kal_trace(TRACE_FUNC, FUNC_DT_WRITE_TO_UART_ENTRY);
#if 0
#ifdef __SATC3__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
if(UART_GetOwnerID(DT_PTR->transfered_port) != MOD_DT)
{
kal_trace(TRACE_ERROR, ERROR_DT_UART_OWNER_IS_NOT_DT);
return;
}
dt_uart_write_data(buffer, length, stuff, cid, DT_PTR->transfered_port);
}
/*****************************************************************************
* FUNCTION
* dt_read_from_uart
*
* DESCRIPTION
* This is dt_read_from_uart function of L4C module.
* calculate available space in rmmi input queue for
* reading data from uart, continue read until no space
* or uart has no more data
*
* PARAMETERS
* none.
*
* RETURNS
* none.
*
* GLOBALS AFFECTED
* none.
*****************************************************************************/
void dt_read_from_uart (kal_uint8 port)
{
kal_uint16 space;
kal_uint16 actual_read=0;
kal_uint16 temp_read = 0; /* to print more detail trace information */
kal_trace(TRACE_FUNC, FUNC_DT_READ_FROM_UART_ENTRY);
if (port == uart_port_null)
return;
DT_PTR->transfered_port = port;//mtk00924_051021
// if (RMMI_PTR->cmux_enable == KAL_FALSE)
// {
if(UART_GetOwnerID(port) != MOD_DT)
{
kal_trace(TRACE_ERROR, ERROR_DT_UART_OWNER_IS_NOT_DT);
return;
}
// }
//#ifdef __BTVCSR_HP__
// /* we do not allow the other channel when BT is used as serial port ,
// Note that we do not read data from UART here, so we have to clear the RX buffer
// when BT is no longer used as serial port : rmmi_bt_crfcstat_hdlr */
// if ((RMMI_PTR->BT_as_serial_port == KAL_TRUE) && (port != PS_UART_PORT))
// return;
//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -