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

📄 mcf5249_hi.c

📁 motorola 针对coldfire 5275 评估板的Dbug bootloader源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * File:        mcf5249_hi.c
 * Purpose:     Register display/modify routines for MCF5249 modules.
 *
 * Notes:
 *
 */

#include "src/include/dbug.h"

/********************************************************************/

/*
 * CPU name string and source code version for display at boot-up.
 */
const char CPU_STR[] = "ColdFire MCF5249";
const int  CPU_VER_MAJOR   = 1;
const char CPU_VER_MINOR   = 'a';

/********************************************************************/

static const char FORMAT8[]  = "%-15s (%-15s): %02X\n";
static const char FORMAT16[] = "%-15s (%-15s): %04X\n";
static const char FORMAT32[] = "%-15s (%-15s): %08X\n";
static const char XFORMAT[]  = "%-15s (%-15s): %12s\n";

static const char INVMOD[] = "Error: Invalid Module: %s\n";
static const char NOREG[]  = "XXXXXX";

#define IRMD(MOD,RDREG,WRREG,SIZE)  \
if (regread)                                            \
{                                                       \
    if ((strcasecmp(#RDREG,reg) == 0) || display_all)   \
    {                                                   \
        rdata = MCF5249_ ## MOD ## _ ## RDREG;  \
        printf(FORMAT ## SIZE, #RDREG, #WRREG, rdata);  \
                                                        \
        pause(&displayed);                              \
                                                        \
        if (!display_all) return;                       \
    }                                                   \
}                                                       \
else                                                    \
{                                                       \
    if (strcasecmp(#WRREG,reg) == 0)                    \
    {                                                   \
        MCF5249_ ## MOD ## _ ## WRREG =(uint ## SIZE)value; \
        return;                                         \
    }                                                   \
}

#define IRMD_NOWR(MOD,RDREG,SIZE)  \
if (regread)                                            \
{                                                       \
    if ((strcasecmp(#RDREG,reg) == 0) || display_all)   \
    {                                                   \
        rdata = MCF5249_ ## MOD ## _ ## RDREG;  \
        printf(FORMAT ## SIZE, #RDREG, NOREG, rdata);   \
                                                        \
        pause(&displayed);                              \
                                                        \
        if (!display_all) return;                       \
    }                                                   \
}

#define IRMD_NORD(MOD,WRREG,SIZE)  \
if (regread && display_all)                             \
{                                                       \
    printf(XFORMAT, NOREG, #WRREG, NOREG);              \
}                                                       \
else                                                    \
{                                                       \
    if (strcasecmp(#WRREG,reg) == 0)                    \
    {                                                   \
        MCF5249_ ## MOD ## _ ## WRREG =(uint ## SIZE) value;    \
        return;                                         \
    }                                                   \
}

static int display_all;
static int displayed;
static uint32 rdata;

/********************************************************************/
static void
//irmd_sim (void *imm, char *reg, int regread, uint32 value)
irmd_sim (char *reg, int regread, uint32 value)
{
    IRMD(SIM,   RSR,    RSR,    8);
    IRMD(SIM,   SYPCR,  SYPCR,  8);
    IRMD(SIM,   SWIVR,  SWIVR,  8);
    IRMD(SIM,   SWSR,   SWSR,   8);
    IRMD(SIM,   IRQPAR, IRQPAR, 8);
    IRMD(SIM,   MPARK,  MPARK,  8);
    IRMD(SIM,   IPR,    IPR,    32);
    IRMD(SIM,   IMR,    IMR,    32);


    IRMD(SIM,   ICR0,   ICR0,   8);
    IRMD(SIM,   ICR1,   ICR1,   8);
    IRMD(SIM,   ICR2,   ICR2,   8);
    IRMD(SIM,   ICR3,   ICR3,   8);
    IRMD(SIM,   ICR4,   ICR4,   8);
    IRMD(SIM,   ICR5,   ICR5,   8);
    IRMD(SIM,   ICR6,   ICR6,   8);
    IRMD(SIM,   ICR7,   ICR7,   8);
    IRMD(SIM,   ICR8,   ICR8,   8);
    IRMD(SIM,   ICR9,   ICR9,   8);
    IRMD(SIM,   ICR10,  ICR10,  8);

    IRMD_NOWR(SIM,  DEVID,  32);

    IRMD(SIM,   GPIO_READ,      GPIO_READ,      32);
    IRMD(SIM,   GPIO_OUT,       GPIO_OUT,       32);
    IRMD(SIM,   GPIO_ENABLE,    GPIO_ENABLE,    32);
    IRMD(SIM,   GPIO_FUNC,      GPIO_FUNC,      32);
    IRMD(SIM,   GPIO1_READ,     GPIO1_READ,     32);
    IRMD(SIM,   GPIO1_OUT,      GPIO1_OUT,      32);
    IRMD(SIM,   GPIO1_ENABLE,   GPIO1_ENABLE,   32);
    IRMD(SIM,   GPIO1_FUNC,     GPIO1_FUNC,     32);
    IRMD(SIM,   GPIO_INT_STAT,  GPIO_INT_STAT,  32);
    IRMD(SIM,   GPIO_INT_CLEAR, GPIO_INT_CLEAR, 32);
    IRMD(SIM,   GPIO_INT_EN,    GPIO_INT_EN,    32);
    IRMD(SIM,   INTERRUPT_STAT3,INTERRUPT_STAT3,32);
    IRMD(SIM,   INTERRUPT_CLR3, INTERRUPT_CLR3, 32);
    IRMD(SIM,   INTERRUPT_EN3,  INTERRUPT_EN3,  32);
    IRMD(SIM,   INTLEV1,        INTLEV1,        8);
    IRMD(SIM,   INTLEV2,        INTLEV2,        8);
    IRMD(SIM,   INTLEV3,        INTLEV3,        8);
    IRMD(SIM,   INTLEV4,        INTLEV4,        8);
    IRMD(SIM,   INTLEV5,        INTLEV5,        8);
    IRMD(SIM,   INTLEV6,        INTLEV6,        8);
    IRMD(SIM,   INTLEV7,        INTLEV7,        8);
    IRMD(SIM,   INTLEV8,        INTLEV8,        8);
    IRMD(SIM,   SPURVEC,        SPURVEC,        8);
    IRMD(SIM,   INTBASE,        INTBASE,        8);

    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_pll (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(PLL,   PLLCR,  PLLCR,  32);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(CS,    CSAR0,  CSAR0,  16);
    IRMD(CS,    CSMR0,  CSMR0,  32);
    IRMD(CS,    CSCR0,  CSCR0,  16);
    IRMD(CS,    CSAR1,  CSAR1,  16);
    IRMD(CS,    CSMR1,  CSMR1,  32);
    IRMD(CS,    CSCR1,  CSCR1,  16);
    IRMD(CS,    CSAR2,  CSAR2,  16);
    IRMD(CS,    CSMR2,  CSMR2,  32);
    IRMD(CS,    CSCR2,  CSCR2,  16);
    IRMD(CS,    CSAR3,  CSAR3,  16);
    IRMD(CS,    CSMR3,  CSMR3,  32);
    IRMD(CS,    CSCR3,  CSCR3,  16);
    IRMD(CS,    IDECONFIG1, IDECONFIG1, 32);
    IRMD(CS,    IDECONFIG2, IDECONFIG2, 32);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_qspi (/*void *imm,*/ char *reg, int regread, uint32 value)
{

    IRMD(QSPI,  QMR,    QMR,    32);
    IRMD(QSPI,  QDLYR,  QDLYR,  32);
    IRMD(QSPI,  QWR,    QWR,    32);
    IRMD(QSPI,  QIR,    QIR,    32);
    IRMD(QSPI,  QAR,    QAR,    32);
    IRMD(QSPI,  QDR,    QDR,    32);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_dma0 (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(DMA0,  SAR,    SAR,    32);
    IRMD(DMA0,  DAR,    DAR,    32);
    IRMD(DMA0,  DCR,    DCR,    16);
    IRMD(DMA0,  BCR,    BCR,    16);
    IRMD(DMA0,  DSR,    DSR,    8);
    IRMD(DMA0,  DIVR,   DIVR,   8);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_dma1 (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(DMA1,  SAR,    SAR,    32);
    IRMD(DMA1,  DAR,    DAR,    32);
    IRMD(DMA1,  DCR,    DCR,    16);
    IRMD(DMA1,  BCR,    BCR,    16);
    IRMD(DMA1,  DSR,    DSR,    8);
    IRMD(DMA1,  DIVR,   DIVR,   8);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_dma2 (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(DMA2,  SAR,    SAR,    32);
    IRMD(DMA2,  DAR,    DAR,    32);
    IRMD(DMA2,  DCR,    DCR,    16);
    IRMD(DMA2,  BCR,    BCR,    16);
    IRMD(DMA2,  DSR,    DSR,    8);
    IRMD(DMA2,  DIVR,   DIVR,   8);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_dma3 (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(DMA3,  SAR,    SAR,    32);
    IRMD(DMA3,  DAR,    DAR,    32);
    IRMD(DMA3,  DCR,    DCR,    16);
    IRMD(DMA3,  BCR,    BCR,    16);
    IRMD(DMA3,  DSR,    DSR,    8);
    IRMD(DMA3,  DIVR,   DIVR,   8);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_uart0 (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(UART0, UMR,    UMR,    8);
    IRMD(UART0, USR,    UCSR,   8);
    IRMD_NORD(UART0,    UCR,    8);
    IRMD(UART0, URB,    UTB,    8);
    IRMD(UART0, UIPCR,  UACR,   8);
    IRMD(UART0, UISR,   UIMR,   8);
    IRMD_NORD(UART0,    UBG1,   8);
    IRMD_NORD(UART0,    UBG2,   8);
    IRMD(UART0, UIVR,   UIVR,   8);
    IRMD_NOWR(UART0,    UIP,    8);
    IRMD_NORD(UART0,    UOP1,   8);
    IRMD_NORD(UART0,    UOP0,   8);

    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_uart1 (/*void *imm,*/ char *reg, int regread, uint32 value)
{
    IRMD(UART1, UMR,    UMR,    8);
    IRMD(UART1, USR,    UCSR,   8);
    IRMD_NORD(UART1,    UCR,    8);
    IRMD(UART1, URB,    UTB,    8);
    IRMD(UART1, UIPCR,  UACR,   8);
    IRMD(UART1, UISR,   UIMR,   8);
    IRMD_NORD(UART1,    UBG1,   8);
    IRMD_NORD(UART1,    UBG2,   8);

⌨️ 快捷键说明

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