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

📄 uart.h

📁 FreeRTOS-3.2.4-HCS08 Files
💻 H
📖 第 1 页 / 共 2 页
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : UART.H
**     Project   : RTOSDemo
**     Processor : MC9S08GT60CFB
**     Beantype  : AsynchroSerial
**     Version   : Bean 02.333, Driver 01.12, CPU db: 2.87.086
**     Compiler  : Metrowerks HCS08 C Compiler
**     Date/Time : 3/10/2006, 2:35 PM
**     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          : 57600baud
**             Width                   : 8 bits
**             Stop bits               : 1
**             Parity                  : none
**             Breaks                  : Disabled
**
**         Registers
**             Input buffer            : SCI1D     [001F]
**             Output buffer           : SCI1D     [001F]
**             Control register        : SCI1C1    [001A]
**             Mode register           : SCI1C2    [001B]
**             Baud setting reg.       : SCI1BD    [0018]
**             Special register        : SCI1S1    [001C]
**
**         Input interrupt
**             Vector name             : Vsci1rx
**
**         Output interrupt
**             Vector name             : Vsci1tx
**
**         Used pins:
**         ----------------------------------------------------------
**           Function | On package           |    Name
**         ----------------------------------------------------------
**            Input   |     10               |  PTE1_RxD1
**            Output  |     9                |  PTE0_TxD1
**             RTS    |     33               |  PTA1_KBI1P1
**         ----------------------------------------------------------
**
**             Note: RTS pin is NOT supported by hardware.
**                   It is handled by software.
**
**
**     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-2005
**     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_tItem
#define __BWUserType_tItem
  typedef struct {                     /* Item of the index table for possible baudrates */
    word div;                          /* divisor */
    byte val;                          /* values of the prescalers */
  } tItem;
#endif
#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 */
    } 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 250          /* Input buffer size */
#define UART_OUT_BUF_SIZE 250          /* Output buffer size */
#define UART_RTS_BUF_SIZE 1            /* Number of characters in rcv. buffer when RTS signal gets activated */

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. 
**         DMA mode:
**         If DMA controller is available on the selected CPU and
**         the receiver is configured to use DMA controller then
**         this method only sets the selected DMA channel. Then the
**         status of the DMA transfer can be checked using
**         GetCharsInRxBuf method. See an example of a typical usage
**         for details about the communication using DMA.
**     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 <Interrupt service> property
**                           is disabled)
**                           ERR_COMMON - common error occurred (the
**                           GetError method can be used for error
**                           specification)
**                           DMA mode:
**                           If DMA controller is available on the
**                           selected CPU and the receiver is
**                           configured to use DMA controller then
**                           only ERR_OK, ERR_RXEMPTY, and ERR_SPEED
**                           error code can be returned from this
**                           method.
** ===================================================================
*/

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.
**         DMA mode:
**         If DMA controller is available on the selected CPU and
**         the transmitter is configured to use DMA controller then
**         this method only sets selected DMA channel. Then the
**         status of the DMA transfer can be checked using
**         GetCharsInTxBuf method. See an example of a typical usage
**         for details about communication using DMA.
**     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.
**         DMA mode:
**         If DMA controller is available on the selected CPU and
**         the receiver is configured to use DMA controller then
**         this method only sets the selected DMA channel. Then the
**         status of the DMA transfer can be checked using
**         GetCharsInRxBuf method. See an example of a typical usage
**         for details about communication using DMA.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Ptr             - Pointer to the block of received data
**         Size            - Size of the block
**       * Rcv             - Pointer to real number of the received
**                           data
**     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_VALUE - Parameter is out of range.
**                           ERR_COMMON - common error occurred (the
**                           GetError method can be used for error

⌨️ 快捷键说明

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