⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tuartlow.h.svn-base

📁 最新火热的CX32 源代码
💻 SVN-BASE
字号:
/**
 *  This code and information is part of Trident DPTV API (TDAPI)
 *
 *  Copyright (C) Trident Multimedia Technologies (Shanghai) Co., Ltd.
 *         2001-2004  All rights reserved.
 *
 *  This file contains routines for hardware related UART operations.
 *
 *  Revision:
 *  12/14/2004     Created by Wang Chao
 *
 */
#ifndef _UARTLOW_H
#define _UARTLOW_H

#include "tdefs.h"
#include "tvconfig.h"
#include "UartCommand.h"
#ifdef __cplusplus
extern "C" {
#endif

#ifdef _USE_STi7710_
#define _DEBUG_STI7710_
#endif

/* The function acts as initialization before communication.
 * @param ucPort: communication port. 
 * @param ucBaud: constant, may be 
UART_BAUD_1200
UART_BAUD_2400
UART_BAUD_4800
UART_BAUD_9600
UART_BAUD_19200 
UART_BAUD_38400
UART_BAUD_57600 */
Bool tdUARTLowInit(Byte ucPort, Byte ucBaud);

/* Push a char into FIFO, return _TURE_ if FIFO is not full, else return _FALSE_.*/
Bool tdUARTPutChar(Byte ucVal);

/* Pop a char from FIFO, return _TURE_ if FIFO is not empty, else return _FALSE_.*/
Bool tdUARTGetChar(GPByte pucVal);

/* This function will not return until all data have been pushed into FIFO.*/
Void tdUARTPut(GPByte pucBuffer, Byte ucLen);

/* This function will not return until all data have been read out from FIFO.*/
Void tdUARTGet(GPByte pucBuffer, Byte ucLen);

/* The function try to read a charactor line. If there is not a line got, it returns 0 immidiately.
 * @param pBuffer The line buffer to store the data.
 * @param nSize the size of the buffer
 * @return The number of bytes read into the buffer. If no line got, it returns 0, if the line is
 * larger than nSize, the last data will be ignored.
 * NOTE: the CR character is not read into the buffer. */
Byte tdUARTLowGetLine(GPByte pucBuffer, Byte nSize);

/* The function first writes the data to the UART, then transmit the 'CR' character and 'LF' character.
 * @param nSize the line length
 * @param pBuffer  The line buffer.
 * @return Number of bytes  transmitted*/
Byte tdUARTLowPutLine(GPByte pucBuffer, Byte nLen);

Void tdUARTLowClearBuffer();

Bool tdUARTLowGotData();

void Printf(Byte  *pFmt, Word wVal);

#ifdef _USE_STi7710_
#define BYTE unsigned char
typedef struct tagIDWVALUE
{
    BYTE ucID;
    BYTE ucValue;
}IDWVALUE;

typedef struct tagPACKETDATA
{
    WORD Magic;
    BYTE Cmdtype;
    WORD Framesize;
    WORD CRC;
    WORD Dtvoper;
    WORD Suboper;
    WORD TranID;
    WORD Payloadsize;
    Byte *Payload;
}PACKETDATA, * LPPACKETDATA;



typedef struct tagSYSUARTSTRUCT
{
    Bool bDtvAcked;	//_false_:waiting for dtv to ack,_true_:has received dtv's ack
    Bool bResendCmding;
    Byte ucResendCmd;
    Byte ucResendCmdTimer;
    Byte ucResendTryTimes;
    Word Packetlength;
    Word wBakTransID;//YYM_06_07_13 add for[]
    PACKETDATA PackData;
}SYSUARTSTRUCT;
extern SYSUARTSTRUCT volatile s_SysUARTStruct;

typedef struct tagRECEIVEUARTSTRUCT
{
    Word Packetlength;
    PACKETDATA PackData;
}UARTRECEIVESTRUCT;
extern UARTRECEIVESTRUCT volatile s_UARTReceiveStruct;


#define PACKET_LENGTH    sizeof(PACKETDATA)
void SetUartPort(Byte port);

#define UART1_ENABLE_RINT                 __DI();   INTRX1 = INT_PRIORITY_F;    INTCLR = 0x23; INTCLR = 0x24;  __EI()//UART1 interrupt set
//#define UART0_ENABLE_RINT                  INTRX0 = INT_PRIORITY_F 

#define UART1_DISABLE_RINT                INTRX1 = INT_PRIORITY_OFF //Disable
//#define UART_ENABLE_TINT                INTTX1 = INT_PRIORITY_E //UART1 interrupt set
//#define UART_DISABLE_TINT               INTTX1 = INT_PRIORITY_OFF //Disable
#define UART1_ENABLE_RECEIVE              UART1_ENABLE_RINT;P95=0;
#define UART1_DISABLE_RECEIVE             UART1_DISABLE_RINT;P95=1;
#endif

#ifdef __cplusplus
}
#endif

#endif //#ifndef _UARTLOW_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -