freescale
来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 369 行 · 第 1/2 页
TXT
369 行
/** ###################################################################
** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : Uart.H
** Project : Pc_Communication
** Processor : MC9S08JM60CLHE
** Beantype : AsynchroSerial
** Version : Bean 02.453, Driver 01.25, CPU db: 3.00.033
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2009-10-25, 15:01
** Abstract :
** This bean "AsynchroSerial" implements an asynchronous serial
** communication. The bean supports different settings of
** parity, word width, stop-bit and communication speed,
** user can select interrupt or polling handler.
** Communication speed can be changed also in runtime.
** The bean requires one on-chip asynchronous serial channel.
** Settings :
** Serial channel : SCI1
**
** Protocol
** Init baud rate : 19200baud
** Width : 8 bits
** Stop bits : 1
** Parity : none
** Breaks : Disabled
**
** Registers
** Input buffer : SCI1D [$003F]
** Output buffer : SCI1D [$003F]
** Control register : SCI1C1 [$003A]
** Mode register : SCI1C2 [$003B]
** Baud setting reg. : SCI1BD [$0038]
** Special register : SCI1S1 [$003C]
**
** Input interrupt
** Vector name : Vsci1rx
** Priority :
**
** Output interrupt
** Vector name : Vsci1tx
** Priority :
**
** Used pins:
** ----------------------------------------------------------
** Function | On package | Name
** ----------------------------------------------------------
** Input | 14 | PTE1_RxD1
** Output | 13 | PTE0_TxD1
** ----------------------------------------------------------
**
**
**
** Contents :
** RecvChar - byte Uart_RecvChar(Uart_TComData *Chr);
** SendChar - byte Uart_SendChar(Uart_TComData Chr);
** RecvBlock - byte Uart_RecvBlock(Uart_TComData *Ptr, word Size, word *Rcv);
** SendBlock - byte Uart_SendBlock(Uart_TComData *Ptr, word Size, word *Snd);
** ClearRxBuf - byte Uart_ClearRxBuf(void);
** ClearTxBuf - byte Uart_ClearTxBuf(void);
** GetCharsInRxBuf - word Uart_GetCharsInRxBuf(void);
** GetCharsInTxBuf - word Uart_GetCharsInTxBuf(void);
**
** (c) Copyright UNIS, spol. s r.o. 1997-2008
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
#ifndef __Uart
#define __Uart
/* MODULE Uart. */
#include "Cpu.h"
#ifndef __BWUserType_Uart_TError
#define __BWUserType_Uart_TError
typedef union {
byte err;
struct {
bool OverRun : 1; /* Overrun error flag */
bool Framing : 1; /* Framing error flag */
bool Parity : 1; /* Parity error flag */
bool RxBufOvf : 1; /* Rx buffer full error flag */
bool Noise : 1; /* Noise error flag */
bool Break : 1; /* Break detect */
bool LINSync : 1; /* LIN synchronization error */
bool BitError : 1; /* Bit error flag - mismatch to the expected value happened. */
} errName;
} Uart_TError; /* Error flags. For languages which don't support bit access is byte access only to error flags possible. */
#endif
#ifndef __BWUserType_Uart_TComData
#define __BWUserType_Uart_TComData
typedef byte Uart_TComData ; /* User type for communication. Size of this type depends on the communication data witdh. */
#endif
#define Uart_INP_BUF_SIZE 16 /* Input buffer size */
#define Uart_OUT_BUF_SIZE 8 /* Output buffer size */
extern byte Uart_OutLen; /* Length of the output buffer content */
extern byte Uart_InpLen; /* Length of the input buffer content */
byte Uart_RecvChar(Uart_TComData *Chr);
/*
** ===================================================================
** Method : Uart_RecvChar (bean AsynchroSerial)
**
** Description :
** If any data is received, this method returns one
** character, otherwise it returns an error code (it does
** not wait for data). This method is enabled only if the
** receiver property is enabled.
** [Note:] Because the preferred method to handle error and
** break exception in the interrupt mode is to use events
** <OnError> and <OnBreak> the return value ERR_RXEMPTY has
** higher priority than other error codes. As a consequence
** the information about an exception in interrupt mode is
** returned only if there is a valid character ready to be
** read.
** Parameters :
** NAME - DESCRIPTION
** * Chr - Pointer to a received character
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ERR_RXEMPTY - No data in receiver
** ERR_BREAK - Break character is detected
** (only when the <Interrupt service>
** property is disabled and the <Break
** signal> property is enabled)
** ERR_COMMON - common error occurred (the
** <GetError> method can be used for error
** specification)
** ===================================================================
*/
byte Uart_SendChar(Uart_TComData Chr);
/*
** ===================================================================
** Method : Uart_SendChar (bean AsynchroSerial)
**
** Description :
** Sends one character to the channel. If the bean is
** temporarily disabled (Disable method) SendChar method
** only stores data into an output buffer. In case of a zero
** output buffer size, only one character can be stored.
** Enabling the bean (Enable method) starts the transmission
** of the stored data. This method is available only if the
** transmitter property is enabled.
** Parameters :
** NAME - DESCRIPTION
** Chr - Character to send
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ERR_TXFULL - Transmitter is full
** ===================================================================
*/
byte Uart_RecvBlock(Uart_TComData *Ptr,word Size,word *Rcv);
/*
** ===================================================================
** Method : Uart_RecvBlock (bean AsynchroSerial)
**
** Description :
** If any data is received, this method returns the block of
** the data and its length (and incidental error), otherwise
** it returns an error code (it does not wait for data).
** This method is available only if non-zero length of the
** input buffer is defined and the receiver property is
** enabled.
** If less than requested number of characters is received
** only the available data is copied from the receive buffer
** to the user specified destination. The value ERR_EXEMPTY
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?