📄 sd_defs.h
字号:
/*************************************************************************
*
* Copyright (c) 2001 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
*
* sd_defs.h Nucleus PLUS\MPC8245\Diab C/C++ 1.13.1
*
* COMPONENT
*
* SD - Serial Driver
*
* DESCRIPTION
*
* This file contains constant definitions and function macros
* for the Serial Driver module.
*
* DATA STRUCTURES
*
* SD_PORT : Structure to keep all needed info. about a port.
*
* DEPENDENCIES
*
* none
*
* HISTORY
*
* NAME DATE REMARKS
*
* T. Weller 12\19\2001 Created inital version 1.13.1
*
*************************************************************************/
#ifndef SD_DEFS_H
#define SD_DEFS_H
/************** Begin Port Specific Section ****************/
/* Include following files for definitions specific to the
Sandpoint X3 board and MPC8245 Unity X4 board. */
#include "epic_extr.h" /* EPIC controller */
#include "superio.h" /* SuperIO controller */
#include "winbond.h" /* Winbond controller */
/*************** End Port Specific Section *****************/
/**************** User configurable section *************************/
#define SYSTEM_CLOCK 250000000
#define EXT_SERIAL_CLOCK 115200
/**************** End configurable section **************************/
/************** Begin Port Specific Section ****************/
#include "epic_extr.h"
#include "superio.h"
#include "winbond.h"
/*************** End Port Specific Section *****************/
/* Base address of Serial IO */
#define SD_BASE 0xFE000000
/* Macros for reading and writing to the cascaded 82C59 interrupt
control and mask registers */
#define SD_PIC1_BASE_OFFSET 0x020
#define SD_PIC2_BASE_OFFSET 0x0A0
#define SD_EOI_OFFSET 0x00
#define SD_IMR_OFFSET 0x01
#define SD_PIC_EOI 0x00
/* Macros for reading and writing the UART control registers */
#define SD_UART1_BASE_OFFSET 0x3F8
#define SD_UART2_BASE_OFFSET 0x2F8
/* Defines for fields and bits of interrupt control and mask registers. */
#define SD_IMR_UART1_MASK (1 << 4)
#define SD_IMR_UART2_MASK (1 << 3)
/* Defines for UART vectors. */
#define SD_UART1_VECTOR 37
#define SD_UART2_VECTOR 36
/* Macros for specifying which UART to use. */
#define SD_UART1 1
#define SD_UART2 2
#define SD_MAX_UARTS 2
/* UART register offsets from the UART base. */
#define SD_DATA_OFFSET 0x00
#define SD_IER_OFFSET 0x01
#define SD_IIR_OFFSET 0x02
#define SD_LCR_OFFSET 0x03
#define SD_MCR_OFFSET 0x04
#define SD_LSR_OFFSET 0x05
#define SD_MSR_OFFSET 0x06
/* Defines for fields and bits of UART control registers */
/* Write Register 1 - IER - interrupt enable register */
#define SD_IER_ENABLE_RCV 0x01
#define SD_IER_ENABLE_TX 0x02
#define SD_IER_ENABLE_ERROR 0x04
/* Write Register 2 - IIR - interrupt indentification register */
#define SD_IIR_INT_TYPE 0x06
#define SD_IIR_INT_PENDING 0x00
#define SD_IIR_INT_PENDING_OFF 0x01
#define SD_IIR_INT_TX 0x02
#define SD_IIR_INT_RX 0x04
#define SD_IIR_INT_ERROR 0x06
#define SD_IIR_FIFO_DISABLE 0x00
#define SD_IIR_INT_PENDING_MASK 0x01
/* Write Register 3 - LCR - line control register */
#define SD_LCR_DLAB 0x80
/* Write Register 4 - MCR - modem control register */
#define SD_MCR_INT_ENABLE 0x08
#define SD_MCR_DTR 0x01
#define SD_MCR_RTS 0x02
/* Write Register 5 - LSR - line status register */
#define SD_LSR_OVERRUN_ERR 0x02
#define SD_LSR_PARITY_ERR 0x04
#define SD_LSR_FRAME_ERR 0x08
#define SD_LSR_TXRDY 0x20 /* Transmit Buffer Empty. */
#define SD_LSR_RXRDY 0x01 /* Receive data ready */
/* These use generic type names, leaving off the register name
in the macro, because they are used by generic sections of
code which will not require changes for other UARTS. Only the
bits these correspond to should change. */
/* UART Mode Register One Bits */
#define SD_PARITY_NONE 0x00
#define SD_PARITY_EVEN 0x18
#define SD_PARITY_ODD 0x08
#define SD_DATA_BITS_5 0x00
#define SD_DATA_BITS_6 0x01
#define SD_DATA_BITS_7 0x02
#define SD_DATA_BITS_8 0x03
/* UART Mode Register Two Bits */
#define SD_MODE_NORMAL 0x00
/* SD_MODE_NORMAL is _ONLY_ valid operating mode */
#define SD_MODE_AUTO_ECHO 0x40
#define SD_MODE_LOCAL_LOOP 0x80
#define SD_MODE_REMOTE_LOOP 0xC0
#define SD_STOP_BITS_1 0x00
#define SD_STOP_BITS_2 0x04
/* These use specific type names, putting the register name
in the macro, because these macros are used by port specific
sections of code and will most likely have different names
on other UARTS. */
/* UART Command Register Bits */
#define SD_UCR_RST_MODE_REG 0x10
#define SD_UCR_RST_RX 0x20
#define SD_UCR_RST_TX 0x30
#define SD_UCR_RST_ERR_STAT 0x40
#define SD_UCR_TX_ENABLE 0x04
#define SD_UCR_TX_DISABLE 0x08
#define SD_UCR_RX_ENABLE 0x01
#define SD_UCR_RX_DISABLE 0x02
/* UART Clock-Select Bits */
#define SD_UCSR_TIMER 0xDD
/* UART Mask Register Bits */
#define SD_UIMR_RX_ENABLE 0x02
#define SD_UIMR_TX_ENABLE 0x01
/* UART Status Register Bits */
#define SD_USR_FRAME_ERR 0x40
#define SD_USR_PARITY_ERR 0x20
#define SD_USR_OVERRUN 0x10
#define SD_USR_TXRDY 0x04
#define SD_USR_RXRDY 0x01
#define SD_UIVR_UART1_VECTOR ((SD_ICR_UART1_PRIORITY) * 4)
#define SD_UIVR_UART2_VECTOR ((SD_ICR_UART2_PRIORITY) * 4)
/* Define data structures for management of a serial port. */
typedef struct SD_INIT_STRUCT
{
UINT32 data_mode;
UINT32 base_address;
/* The following elements should generic accross other
platforms. */
NU_SEMAPHORE *sd_semaphore;
UINT32 com_port;
UINT32 data_bits;
UINT32 stop_bits;
UINT32 parity;
UINT32 baud_rate;
/************** Begin Port Specific Section ****************/
UINT32 vector;
/*************** End Port Specific Section *****************/
UINT32 driver_options;
UINT32 sd_buffer_size;
UINT32 parity_errors;
UINT32 frame_errors;
UINT32 overrun_errors;
UINT32 busy_errors;
UINT32 general_errors;
CHAR *rx_buffer;
INT rx_buffer_read;
INT rx_buffer_write;
volatile INT rx_buffer_status;
/* All of the following elements are required by PPP, do not modify. */
UINT32 communication_mode;
CHAR *tx_buffer;
INT tx_buffer_read;
INT tx_buffer_write;
volatile INT tx_buffer_status;
} SD_PORT;
/* Defines to be used by application */
#define MODE_NORMAL SD_MODE_NORMAL
#define MODE_AUTO_ECHO SD_MODE_AUTO_ECHO
#define MODE_LOCAL_LOOP SD_MODE_LOCAL_LOOP
#define MODE_REMOTE_LOOP SD_MODE_REMOTE_LOOP
#define STOP_BITS_1 SD_STOP_BITS_1
#define STOP_BITS_2 SD_STOP_BITS_2
#define UART1 SD_UART1
#define UART2 SD_UART2
/* Defines to determine communication mode */
#define SERIAL_MODE 0
#define SERIAL_MOUSE 3
/* MDM_NETWORK and MDM_TERMINAL do not need to be defined here
since they are defined in PPP. */
/***********************************************************************
Note: everything below should be generic.
*/
#define NU_SERIAL_PORT SD_PORT
#define PARITY_NONE SD_PARITY_NONE
#define PARITY_EVEN SD_PARITY_EVEN
#define PARITY_ODD SD_PARITY_ODD
#define DATA_BITS_6 SD_DATA_BITS_6
#define DATA_BITS_7 SD_DATA_BITS_7
#define DATA_BITS_8 SD_DATA_BITS_8
#define NU_SD_Put_Char SDC_Put_Char
#define NU_SD_Get_Char SDC_Get_Char
#define NU_SD_Put_String SDC_Put_String
#define NU_SD_Init_Port SDC_Init_Port
#define NU_SD_Data_Ready SDC_Data_Ready
#define NU_UART_SUCCESS 0
#define NU_INVALID_PARITY -1
#define NU_INVALID_DATA_BITS -2
#define NU_INVALID_STOP_BITS -3
#define NU_INVALID_BAUD -4
#define NU_INVALID_COM_PORT -5
#define NU_INVALID_DATA_MODE -6
#define NU_UART_LIST_FULL -7
#define NU_INVALID_MOUSE_MODE -8
#define NU_BUFFER_FULL 1
#define NU_BUFFER_DATA 2
#define NU_BUFFER_EMPTY 3
/* Deifine IO macros. */
/* 8 bit access */
#define SD_OUTBYTE(reg, data) ( (*( (UINT8 *) (reg) ) ) = (UINT8) (data) )
#define SD_INBYTE(reg) ( *( (UINT8 *) (reg) ) )
/* 16 bit access */
#define SD_OUTWORD(reg, data) ( (*( (UINT16 *) (reg) ) ) = (data) )
#define SD_INWORD(reg) ( *( (UINT16 *) (reg) ) )
/* 32 bit access */
#define SD_OUTDWORD(reg, data) ( (*( (UINT32 *) (reg) ) ) = (data) )
#define SD_INDWORD(reg) ( *( (UINT32 *) (reg) ) )
/*Macro used for converting URT to SD_PORT. This is for PPP serial driver
backwards compatability. */
#define URT_LAYER SD_PORT
#define URT_TX_BUFFER_SIZE uart->sd_buffer_size
#define URT_Get_Char SDC_Get_Char
#define URT_Put_Char SDC_Put_Char
#define URT_Reset SDC_Reset
#define URT_Change_Communication_Mode SDC_Change_Communication_Mode
#define URT_Carrier SDC_Carrier
#endif /* ifndef SD_DEFS_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -