📄 sd_defs.h
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1999 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 M68EZ328/D */
/* */
/* COMPONENT */
/* */
/* SD - Serial Driver */
/* */
/* DESCRIPTION */
/* */
/* This file contains constant definitions and function macros */
/* for the Serial Driver module. */
/* */
/* DATA STRUCTURES */
/* */
/* SD_BUFFER : Buffer structure for storing RX data. */
/* SD_PORT : Structure to keep all needed info. about a port. */
/* */
/* DEPENDENCIES */
/* */
/* none */
/* */
/*************************************************************************/
#ifndef SD_DEFS
#define SD_DEFS
#include "plus\nucleus.h"
/* Define the size of the input buffer for the serial driver. */
#define SD_BUFFER_SIZE 100
/* Macros for specifying which UART to use. */
#define SD_UART 1
#define SD_MAX_UARTS 1
/* Defines for fields and bits of interrupt control and mask registers. */
#define SD_IMR_UART1_MASK (1 << 12)
/* Macros for reading and writing the UART control registers */
#define M328BASE 0xfffff000
/* Interupt Register Offsets */
#define IVR 0x300 /* Interrupt Vector Reg */
#define ICR 0x302 /* Interrupt Control Reg */
#define IMR 0x304 /* Interrupt Mask Reg */
#define ISR 0x30C /* Interrupt Status Reg */
#define IPR 0x310 /* Interrupt Pending Reg */
#define DBIRQ_IM_MUART 0x04 /* UART */
/* UART Register Offsets */
#define USCREG 0x900
#define UBAUDC 0x902
#define URX_REGS 0x904
#define URX URX_REGS+1
#define UTX_REGS 0x906
#define UTX UTX_REGS+1
#define UMISC 0x908
#define PESEL (*(volatile unsigned char *) 0xFFFFF423)
#define BIT4 0x10
#define BIT5 0x20
/* Define IO macros. */
#define SD_OUTBYTE(reg, data) ( (*( (CHAR *) reg) ) = data)
#define SD_INBYTE(reg) ( *( (CHAR *) reg) )
#define SD_OUTWORD(reg, data) ( (*( (unsigned short *) reg) ) = data)
#define SD_INWORD(reg) ( *( (unsigned short *) reg) )
#define SD_PARITY_NONE 0
#define SD_PARITY_ODD 1
#define SD_PARITY_EVEN 2
/* Defines for fields and bits of UART STATUS/Control registers */
#define SD_UART_ENABLE 0x8000 /* UART Enable */
#define SD_RX_ENABLE 0x4000 /* Recv Enable */
#define SD_TX_ENABLE 0x2000 /* Transmit enable */
#define SD_CLOCK_SYNC 0x1000 /* Synchronous Clock */
#define SD_PARITY_ENABLE 0x0800 /* Parity Enable */
#define SD_PARITY_ODD_SET 0x0400 /* Odd Parity */
#define SD_STOP_BITS_1 0x0000 /* 1 Stop Bit */
#define SD_STOP_BITS_2 0x0200 /* 2 Stop Bit */
#define SD_DATA_BITS_7 0x0000 /* 7 Data Bit */
#define SD_DATA_BITS_8 0x0100 /* 8 Data Bit */
#define SD_OLD_DATA_D 0x0000 /* OLD Data Disable */
#define SD_OLD_DATA_E 0x0080 /* OLD Data Enable */
#define SD_CTSD_D 0x0000 /* CTS Disabled */
#define SD_CTSD_EN 0x0040 /* CTS Enabled */
#define SD_RX_FULL_ENABLE 0x0020 /* RX FULL Enable */
#define SD_RX_HALF_ENABLE 0x0010 /* RX Half Enable */
#define SD_RX_READY_EN 0x0008 /* RX Ready Enable */
#define SD_TX_EMPTY_EN 0x0004 /* TX Empty Enable */
#define SD_TX_HALF_EN 0x0002 /* TX HAlf Empty Enable */
#define SD_TX_AVAIL_REG 0x0001 /* TX Avaliable for new Data */
/* Defines for fields for the UART Baud Control register */
#define SD_BAUD_115200 0x0038
#define SD_BAUD_57600 0x0138
#define SD_BAUD_38400 0x0026
#define SD_BAUD_19200 0x0126
#define SD_BAUD_9600 0x0226
#define SD_BAUD_4800 0x0326
#define SD_BAUD_2400 0x0426
#define SD_BAUD_1200 0x0526
#define SD_BAUD_600 0x0626
#define SD_BAUD_300 0x0726
/* Defines and Macros for Receive Register */
#define SD_RX_FIFO_FULL 0x80
#define SD_RX_FIFO_HALF 0x40
#define SD_RX_DATA_READY 0x20
#define SD_RX_OLD_DATA 0x10
#define SD_RX_OVER_RUN 0x08
#define SD_RX_FRAME_ERROR 0x04
#define SD_RX_BREAK 0x02
#define SD_RX_PARITY_ERROR 0x01
/* Defines and Macros for Transmit Register */
#define SD_TX_FIFO_EMPTY 0x80
#define SD_TX_FIFO_HALF 0x40
#define SD_TX_AVAIL 0x20
#define SD_TX_SEND_BREAK 0x10
#define SD_TX_NO_CTS 0x08
#define SD_TX_BUSY 0x04
#define SD_TX_CTS_STAT 0x02
#define SD_TX_CTS_DELTA 0x01
/* Defines and Macros doe UART Miscellaneous Register */
#define SD_MISC_BAUD_TEST 0x8000 /* Run A Baud Test */
#define SD_MISC_CLK_SRC 0x4000 /* Set the Clock Source */
#define SD_MISC_FORCE_PERR 0x2000 /* Force a Parity Error */
#define SD_MISC_LOOP 0x1000 /* Force a Loop Back Test */
#define SD_MISC_BAUD_RESET 0x0800 /* Reset Baud Rate Generator */
#define SD_MISC_IR_TEST 0x0400 /* Ir Test */
#define SD_RTS_CONT 0x0080 /* Selects RTS control */
#define SD_RTS_RSP 0x0040 /* Selects Request to Send Pin*/
#define SD_IRDA_ENABLE 0x0020 /* Infrared enable */
#define SD_IRDA_LOOP 0x0010 /* Infra-Red Loop */
#define SD_RX_POLARITY 0x0008 /* Receive Polarity */
#define SD_TX_POLARITY 0x0004 /* Transmit Polarity */
#define SD_UART_VECTOR 64
/* Define data structures for management of a serial port. */
typedef struct SD_BUFFER_STRUCT
{
INT status;
CHAR *head;
CHAR *tail;
CHAR *read;
CHAR *write;
CHAR data[SD_BUFFER_SIZE];
} SD_BUFFER;
typedef struct SD_INIT_STRUCT
{
UNSIGNED com_port;
UNSIGNED data_bits;
UNSIGNED stop_bits;
UNSIGNED parity;
UNSIGNED baud_rate;
UNSIGNED data_mode;
UNSIGNED base_address;
UNSIGNED vector;
UNSIGNED parity_errors;
UNSIGNED frame_errors;
UNSIGNED overrun_errors;
SD_BUFFER buffer;
} SD_PORT;
/* Defines to be used by application */
#define NU_SERIAL_PORT SD_PORT
#define NU_SD_PARITY_NONE SD_PARITY_NONE
#define NU_SD_PARITY_EVEN SD_PARITY_EVEN
#define NU_SD_PARITY_ODD SD_PARITY_ODD
#define NU_SD_DATA_BITS_7 SD_DATA_BITS_7
#define NU_SD_DATA_BITS_8 SD_DATA_BITS_8
#define NU_SD_MODE_NORMAL 0
#define NU_SD_MODE_AUTO_ECHO 0
#define NU_SD_MODE_LOCAL_LOOP 0
#define NU_SD_MODE_REMOTE_LOOP 0
#define NU_SD_STOP_BITS_1 SD_STOP_BITS_1
#define NU_SD_STOP_BITS_2 SD_STOP_BITS_2
#define SD_UART1 1
#define NU_SD_UART1 SD_UART1
#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_SD_INVALID_PARITY -1
#define NU_SD_INVALID_DATA_BITS -2
#define NU_SD_INVALID_STOP_BITS -3
#define NU_SD_INVALID_BAUD -4
#define NU_SD_INVALID_COM_PORT -5
#define NU_SD_INVALID_MODE -6
#define NU_SD_UART_LIST_FULL -7
#define NU_SD_BUFFER_FULL 1
#define NU_SD_BUFFER_DATA 2
#define NU_SD_BUFFER_EMPTY 3
#endif /* ifndef SD_DEFS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -