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

📄 uart.h

📁 文件内包含了nuclues的内核代码和针对Power PC的编译器。需要用VirtNet生成一个虚拟网卡才可使用
💻 H
字号:
/*************************************************************************/
/*                                                                       */
/*        Copyright (c) 1997      Accelerated Technology, Inc.           */
/*                                                                       */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      */
/* subject matter of this material.  All manufacturing, reproduction,    */
/* use, and sales rights pertaining to this subject matter are governed  */
/* by the license agreement.  The recipient of this software implicitly  */
/* accepts the terms of the license.                                     */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                            VERSION          */
/*                                                                       */
/*      uart.h                                        MPC860/D 1.3       */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      UART                                                             */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains constant definitions and function prototypes  */
/*      for the UART module.                                             */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Barry Sellew,     Accelerated Technology, Inc.                   */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      _UART_INIT_STRUCT Uart initialization structure.                 */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      none                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*    Barry Sellew      12-16-1997            Created version 1.0        */
/*                                                                       */
/*************************************************************************/

/* Check to see if the file has been included already.  */

#ifndef UART_H
#define UART_H

/* Defines for initialization */
#define SMC1               0          /* SMC1 port on MPC860 */
#define SMC1_PRAM          2          /* PRAM array index for SMC1 */
#define SMC1_VECTOR       68          /* Nucleus vector # for SMC1 */
#define SMC2               1          /* SMC2 port on MPC860 */
#define SMC2_PRAM          3          /* PRAM array index for SMC2 */
#define SMC2_VECTOR       67          /* Nucleus vector # for SMC2 */
#define SMC_PPP_MODE       1          /* SMC to be used for PPP */
#define SMC_NORMAL_MODE    0          /* SMC to be used normally */
#define BUF_LEN           50          /* Length of the receive buffer */
#define BUF_NOT_FULL       0          /* UART's buffer is not full */
#define BUF_FULL           1          /* UART's buffer is full */
#define BUF_EMPTY          2          /* UART's buffer is empty */

/* Return values from the UART functions. */
#define UART_SUCCESS        NU_SUCCESS
#define UART_FAILURE        -1
#define UART_BAD_SMC_PORT   -2

/* Definition of the processor system clock */
#ifdef  ADS
#define SYSCLK           24576000
#endif
#ifdef  EST
#define SYSCLK           25000000
#endif
#ifdef  MBX
#define SYSCLK           40000000
#endif

/* Initialization structure for the UART */
typedef struct _UART_INIT_STRUCT
{
    UNSIGNED      smc_port;     /* SMC1 or SMC2 */
    UNSIGNED      baud_rate;    /* the initial baud rate */
    UNSIGNED_CHAR mode;         /* either PPP or normal mode */
    UNSIGNED_CHAR read;         /* current location in buffer to read from */
    UNSIGNED_CHAR write;        /* current location in buffer to write to */
    UNSIGNED_CHAR buf_status;   /* current status of the buffer */
    char buffer[BUF_LEN];       /* buffer to hold chars received from UART */
} UART_INIT;

/* Buffer descriptor for SMC Rx and Tx */
typedef struct BufferDescriptor 
{
    unsigned short status;      /* control status */
    unsigned short length;      /* transfer length */
    char* addr;                 /* buffer address */
} BD;

/* UART function prototypes */
STATUS  UART_Init_Port(UART_INIT *);
VOID    UART_LISR (INT vector);
CHAR    UART_Get_Char(UNSIGNED);
VOID    UART_Put_Char(UNSIGNED, CHAR);
VOID    UART_Put_String(UNSIGNED, CHAR *);
VOID    UART_Set_Baud_Rate(UNSIGNED, UNSIGNED);
VOID    UART_Change_Communication_Mode(INT);

#endif

⌨️ 快捷键说明

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