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

📄 sc16c652.h

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 H
字号:
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//
//  Header:  uart16552.h
//
//  Provides definitions for external SC16C652 Dual UART module based on
//  Freescale MX27 ADS.
//
//------------------------------------------------------------------------------
#ifndef __SC16C652_H
#define __SC16C652_H

#if __cplusplus
extern "C" {
#endif

//------------------------------------------------------------------------------
// GENERAL MODULE CONSTANTS
//------------------------------------------------------------------------------
// SC16C652 crystal freq is 3.6864Mhz on MX27 ADS
#define SC16C652_FREQ           (3686400)   
#define SC16C652_DLL(baud)      (UINT8)(((SC16C652_FREQ / ((baud) * 16)) & 0x00FF))
#define SC16C652_DLM(baud)      (UINT8)(((SC16C652_FREQ / ((baud) * 16)) >> 8))

//------------------------------------------------------------------------------
// REGISTER LAYOUT
//------------------------------------------------------------------------------
typedef union
{
    struct {
        UINT8 RHR_THR;
        UINT8 _pad0;
        UINT8 IER;
        UINT8 _pad1;
        UINT8 FCR_ISR;
        UINT8 _pad2;
        UINT8 LCR;
        UINT8 _pad3;
        UINT8 MCR;
        UINT8 _pad4;
        UINT8 LSR;
        UINT8 _pad5;
        UINT8 MSR;
        UINT8 _pad6;
        UINT8 SPR;
        UINT8 _pad7;
    } General;
    struct {
        UINT8 DLL;
        UINT8 _pad10;
        UINT8 DLM;
        UINT8 _pad11;
    } Special;
    struct {
        UINT8 reserved1;
        UINT8 _pad20;
        UINT8 reserved2;
        UINT8 _pad21;
        UINT8 EFR;
        UINT8 _pad22;
        UINT8 reserved3;
        UINT8 _pad23;
        UINT8 XON_1;
        UINT8 _pad24;
        UINT8 XOFF_1;
        UINT8 _pad25;
        UINT8 XON_2;
        UINT8 _pad26;
        UINT8 XOFF_2;
        UINT8 _pad27;
    } Enhanced;
} BSP_SC16C652_REGS, *PBSP_SC16C652_REGS;

//------------------------------------------------------------------------------
// REGISTER OFFSETS
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// REGISTER BIT FIELD POSITIONS (LEFT SHIFT)
//------------------------------------------------------------------------------

//// General Register Set
// IER
#define SC16C652_IER_RHR_LSH                    0
#define SC16C652_IER_THR_INT_LSH                1
#define SC16C652_IER_RX_LINE_STATUS_INT_LSH     2
#define SC16C652_IER_MODEM_STATUS_INT_RX_LSH    3
#define SC16C652_IER_SLEEP_MODE_LSH             4
#define SC16C652_IER_XOFF_INT_LSH               5
#define SC16C652_IER_RTS_INT_LSH                6
#define SC16C652_IER_CTS_INT_LSH                7

// LCR
#define SC16C652_LCR_WORD_LEN_LSH               0
#define SC16C652_LCR_STOP_BITS_LSH              2
#define SC16C652_LCR_PARITY_EN_LSH              3
#define SC16C652_LCR_EVEN_PARITY_LSH            4
#define SC16C652_LCR_SET_PARITY_LSH             5
#define SC16C652_LCR_SET_BREAK_LSH              6
#define SC16C652_LCR_DIVISOR_LATCH_EN_LSH       7

// MCR
#define SC16C652_MCR_DTR_LSH                    0
#define SC16C652_MCR_RTS_LSH                    1
#define SC16C652_MCR_OP1_LSH                    2
#define SC16C652_MCR_OP2_INT_EN_LSH             3
#define SC16C652_MCR_LOOP_BACK_LSH              4
#define SC16C652_MCR_CLOCK_SELECT_LSH           7

// FCR
#define SC16C652_FCR_FIFO_EN_LSH                0
#define SC16C652_FCR_RCVR_FIFO_RESET_LSH        1
#define SC16C652_FCR_XMIT_FIFO_RESET_LSH        2
#define SC16C652_FCR_DMA_MODE_SELECT_LSH        3
#define SC16C652_FCR_TX_TRIGGER_LSH             4
#define SC16C652_FCR_RCVR_TRIGGER_EN_LSH        6

// FCR
#define SC16C652_LSR_RCVR_DATA_READY_LSH        0
#define SC16C652_LSR_OVERRUN_ERROR_LSH          1
#define SC16C652_LSR_PARITY_ERROR_LSH           2
#define SC16C652_LSR_FRAMING_ERROR_LSH          3
#define SC16C652_LSR_BREAK_INT_LSH              4
#define SC16C652_LSR_THR_EMPTY_LSH              5
#define SC16C652_LSR_THR_TSR_EMPTY_LSH          6
#define SC16C652_LSR_FIFO_DATA_ERROR_LSH        7


//------------------------------------------------------------------------------
// REGISTER BIT FIELD WIDTHS
//------------------------------------------------------------------------------

//// General Register Set
// IER
#define SC16C652_IER_RHR_WID                    1
#define SC16C652_IER_THR_INT_WID                1
#define SC16C652_IER_RX_LINE_STATUS_INT_WID     1
#define SC16C652_IER_MODEM_STATUS_INT_RX_WID    1
#define SC16C652_IER_SLEEP_MODE_WID             1
#define SC16C652_IER_XOFF_INT_WID               1
#define SC16C652_IER_RTS_INT_WID                1
#define SC16C652_IER_CTS_INT_WID                1

// LCR
#define SC16C652_LCR_WORD_LEN_WID               2
#define SC16C652_LCR_STOP_BITS_WID              1
#define SC16C652_LCR_PARITY_EN_WID              1
#define SC16C652_LCR_EVEN_PARITY_WID            1
#define SC16C652_LCR_SET_PARITY_WID             1
#define SC16C652_LCR_SET_BREAK_WID              1
#define SC16C652_LCR_DIVISOR_LATCH_EN_WID       1

// MCR
#define SC16C652_MCR_DTR_WID                    1
#define SC16C652_MCR_RTS_WID                    1
#define SC16C652_MCR_OP1_WID                    1
#define SC16C652_MCR_OP2_INT_EN_WID             1
#define SC16C652_MCR_LOOP_BACK_WID              1
#define SC16C652_MCR_CLOCK_SELECT_WID           1

// FCR
#define SC16C652_FCR_FIFO_EN_WID                1
#define SC16C652_FCR_RCVR_FIFO_RESET_WID        1
#define SC16C652_FCR_XMIT_FIFO_RESET_WID        1
#define SC16C652_FCR_DMA_MODE_SELECT_WID        1
#define SC16C652_FCR_TX_TRIGGER_WID             2
#define SC16C652_FCR_RCVR_TRIGGER_EN_WID        2

// FCR
#define SC16C652_LSR_RCVR_DATA_READY_WID        1
#define SC16C652_LSR_OVERRUN_ERROR_WID          1
#define SC16C652_LSR_PARITY_ERROR_WID           1
#define SC16C652_LSR_FRAMING_ERROR_WID          1
#define SC16C652_LSR_BREAK_INT_WID              1
#define SC16C652_LSR_THR_EMPTY_WID              1
#define SC16C652_LSR_THR_TSR_EMPTY_WID          1
#define SC16C652_LSR_FIFO_DATA_ERROR_WID        1


//------------------------------------------------------------------------------
// REGISTER BIT WRITE VALUES
//------------------------------------------------------------------------------
#define SC16C652_ENABLE                         1
#define SC16C652_DISABLE                        0

#define SC16C652_LCR_WORD_LEN_5                 0
#define SC16C652_LCR_WORD_LEN_6                 1
#define SC16C652_LCR_WORD_LEN_7                 2
#define SC16C652_LCR_WORD_LEN_8                 3

#define SC16C652_LCR_STOP_BITS_1                0
#define SC16C652_LCR_STOP_BITS_2                1

#ifdef __cplusplus
}
#endif

#endif // __SC16C652_H

⌨️ 快捷键说明

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