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

📄 mcf5282_hi.c

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

#include "src/include/dbug.h"
#include "src/uif/cpu.h"

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

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

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

static const char FORMAT8[]  = "%6s (%-6s): %02X\n";
static const char FORMAT16[] = "%6s (%-6s): %04X\n";
static const char FORMAT32[] = "%6s (%-6s): %08X\n";
static const char XFORMAT[]  = "%6s (%-6s): %6s\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 = MCF5282_ ## MOD ## _ ## RDREG;  \
        printf(FORMAT ## SIZE, #RDREG, #WRREG, rdata);  \
                                                        \
        pause(&displayed);                              \
                                                        \
        if (!display_all) return;                       \
    }                                                   \
}                                                       \
else                                                    \
{                                                       \
    if (strcasecmp(#WRREG,reg) == 0)                    \
    {                                                   \
        MCF5282_ ## MOD ## _ ## WRREG = (uint ## SIZE) value;   \
        return;                                         \
    }                                                   \
}

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

#define IRMD_NOWR(MOD,RDREG,SIZE)  \
if (regread)                                            \
{                                                       \
    if ((strcasecmp(#RDREG,reg) == 0) || display_all)   \
    {                                                   \
        rdata = MCF5282_ ## 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)                    \
    {                                                   \
        MCF5282_ ## MOD ## _ ## WRREG = (uint ## SIZE) value;   \
        return;                                         \
    }                                                   \
}

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

/********************************************************************/
static void
irmd_scm (char *reg, int regread, uint32 value)
{
    IRMD(SCM,   IPSBAR, IPSBAR, 32);
    IRMD(SCM,   RAMBAR, RAMBAR, 32);
    IRMD(SCM,   CRSR,   CRSR,   8);
    IRMD(SCM,   CWCR,   CWCR,   8);
    IRMD(SCM,   LPICR,  LPICR,  8);
    IRMD(SCM,   CWSR,   CWSR,   8);
    IRMD(SCM,   DMAREQC,DMAREQC,32);
    IRMD(SCM,   MPARK,  MPARK,  32);
    IRMD(SCM,   MPR,    MPR,    8);
    IRMD(SCM,   PACR0,  PACR0,  8);
    IRMD(SCM,   PACR1,  PACR1,  8);
    IRMD(SCM,   PACR2,  PACR2,  8);
    IRMD(SCM,   PACR3,  PACR3,  8);
    IRMD(SCM,   PACR4,  PACR4,  8);
    IRMD(SCM,   PACR5,  PACR5,  8);
    IRMD(SCM,   PACR6,  PACR6,  8);
    IRMD(SCM,   PACR7,  PACR7,  8);
    IRMD(SCM,   PACR8,  PACR8,  8);
    IRMD(SCM,   GPACR0, GPACR0, 8);
    IRMD(SCM,   GPACR1, GPACR1, 8);
    
    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs0 (char *reg, int regread, uint32 value)
{
    IRMD(CS0,   CSAR,   CSAR,   16);
    IRMD(CS0,   CSMR,   CSMR,   32);
    IRMD(CS0,   CSCR,   CSCR,   16);

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

/********************************************************************/
static void
irmd_cs1 (char *reg, int regread, uint32 value)
{
    IRMD(CS1,   CSAR,   CSAR,   16);
    IRMD(CS1,   CSMR,   CSMR,   32);
    IRMD(CS1,   CSCR,   CSCR,   16);
    
    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs2 (char *reg, int regread, uint32 value)
{
    IRMD(CS2,   CSAR,   CSAR,   16);
    IRMD(CS2,   CSMR,   CSMR,   32);
    IRMD(CS2,   CSCR,   CSCR,   16);
    
    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs3 (char *reg, int regread, uint32 value)
{
    IRMD(CS3,   CSAR,   CSAR,   16);
    IRMD(CS3,   CSMR,   CSMR,   32);
    IRMD(CS3,   CSCR,   CSCR,   16);
    
    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs4 (char *reg, int regread, uint32 value)
{
    IRMD(CS4,   CSAR,   CSAR,   16);
    IRMD(CS4,   CSMR,   CSMR,   32);
    IRMD(CS4,   CSCR,   CSCR,   16);
    
    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs5 (char *reg, int regread, uint32 value)
{
    IRMD(CS5,   CSAR,   CSAR,   16);
    IRMD(CS5,   CSMR,   CSMR,   32);
    IRMD(CS5,   CSCR,   CSCR,   16);
    
    if (!display_all)
        printf(INVREG,reg);
}

/********************************************************************/
static void
irmd_cs6 (char *reg, int regread, uint32 value)
{
    IRMD(CS6,   CSAR,   CSAR,   16);
    IRMD(CS6,   CSMR,   CSMR,   32);
    IRMD(CS6,   CSCR,   CSCR,   16);
    
    if (!display_all)
        printf(INVREG,reg);
}

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

    IRMD(GPIO,  PORTA,  PORTA,  8);
    IRMD(GPIO,  PORTB,  PORTB,  8);
    IRMD(GPIO,  PORTC,  PORTC,  8);
    IRMD(GPIO,  PORTD,  PORTD,  8);
    IRMD(GPIO,  PORTE,  PORTE,  8);
    IRMD(GPIO,  PORTF,  PORTF,  8);
    IRMD(GPIO,  PORTG,  PORTG,  8);
    IRMD(GPIO,  PORTH,  PORTH,  8);
    IRMD(GPIO,  PORTJ,  PORTJ,  8);
    IRMD(GPIO,  PORTDD, PORTDD, 8);
    IRMD(GPIO,  PORTEH, PORTEH, 8);
    IRMD(GPIO,  PORTEL, PORTEL, 8);
    IRMD(GPIO,  PORTAS, PORTQS, 8);
    IRMD(GPIO,  PORTQS, PORTQS, 8);
    IRMD(GPIO,  PORTSD, PORTSD, 8);
    IRMD(GPIO,  PORTTC, PORTTC, 8);
    IRMD(GPIO,  PORTTD, PORTTD, 8);
    IRMD(GPIO,  PORTUA, PORTUA, 8);
    IRMD(GPIO,  DDRA,   DDRA,   8);
    IRMD(GPIO,  DDRB,   DDRB,   8);
    IRMD(GPIO,  DDRC,   DDRC,   8);
    IRMD(GPIO,  DDRD,   DDRD,   8);
    IRMD(GPIO,  DDRE,   DDRE,   8);
    IRMD(GPIO,  DDRF,   DDRF,   8);
    IRMD(GPIO,  DDRG,   DDRG,   8);
    IRMD(GPIO,  DDRH,   DDRH,   8);
    IRMD(GPIO,  DDRJ,   DDRJ,   8);
    IRMD(GPIO,  DDRDD,  DDRDD,  8);
    IRMD(GPIO,  DDREH,  DDREH,  8);
    IRMD(GPIO,  DDREL,  DDREL,  8);
    IRMD(GPIO,  DDRAS,  DDRQS,  8);
    IRMD(GPIO,  DDRQS,  DDRQS,  8);
    IRMD(GPIO,  DDRSD,  DDRSD,  8);
    IRMD(GPIO,  DDRTC,  DDRTC,  8);
    IRMD(GPIO,  DDRTD,  DDRTD,  8);
    IRMD(GPIO,  DDRUA,  DDRUA,  8);
    IRMD(GPIO,  SETA,   SETA,   8);
    IRMD(GPIO,  SETB,   SETB,   8);
    IRMD(GPIO,  SETC,   SETC,   8);
    IRMD(GPIO,  SETD,   SETD,   8);
    IRMD(GPIO,  SETE,   SETE,   8);
    IRMD(GPIO,  SETF,   SETF,   8);
    IRMD(GPIO,  SETG,   SETG,   8);
    IRMD(GPIO,  SETH,   SETH,   8);
    IRMD(GPIO,  SETJ,   SETJ,   8);
    IRMD(GPIO,  SETDD,  SETDD,  8);
    IRMD(GPIO,  SETEH,  SETEH,  8);
    IRMD(GPIO,  SETEL,  SETEL,  8);
    IRMD(GPIO,  SETAS,  SETAS,  8);
    IRMD(GPIO,  SETQS,  SETQS,  8);
    IRMD(GPIO,  SETSD,  SETSD,  8);
    IRMD(GPIO,  SETTC,  SETTC,  8);
    IRMD(GPIO,  SETTD,  SETTD,  8);
    IRMD(GPIO,  SETUA,  SETUA,  8);
    IRMD(GPIO,  CLRA,   CLRA,   8);
    IRMD(GPIO,  CLRB,   CLRB,   8);
    IRMD(GPIO,  CLRC,   CLRC,   8);
    IRMD(GPIO,  CLRD,   CLRD,   8);
    IRMD(GPIO,  CLRE,   CLRE,   8);
    IRMD(GPIO,  CLRF,   CLRF,   8);
    IRMD(GPIO,  CLRG,   CLRG,   8);
    IRMD(GPIO,  CLRH,   CLRH,   8);
    IRMD(GPIO,  CLRJ,   CLRJ,   8);
    IRMD(GPIO,  CLRDD,  CLRDD,  8);
    IRMD(GPIO,  CLREH,  CLREH,  8);
    IRMD(GPIO,  CLREL,  CLREL,  8);
    IRMD(GPIO,  CLRAS,  CLRQS,  8);
    IRMD(GPIO,  CLRQS,  CLRQS,  8);
    IRMD(GPIO,  CLRSD,  CLRSD,  8);
    IRMD(GPIO,  CLRTC,  CLRTC,  8);
    IRMD(GPIO,  CLRTD,  CLRTD,  8);
    IRMD(GPIO,  CLRUA,  CLRUA,  8);
    IRMD(GPIO,  PBCDPAR,    PBCDPAR,    8);
    IRMD(GPIO,  PFPAR,  PFPAR,  8);
    IRMD(GPIO,  PEPAR,  PEPAR,  16);
    IRMD(GPIO,  PJPAR,  PJPAR,  8);
    IRMD(GPIO,  PSDPAR, PSDPAR, 8);
    IRMD(GPIO,  PASPAR, PASPAR, 16);
    IRMD(GPIO,  PEHLPAR,    PEHLPAR,    8);
    IRMD(GPIO,  PQSPAR, PQSPAR, 8);
    IRMD(GPIO,  PTCPAR, PTCPAR, 8);
    IRMD(GPIO,  PTDPAR, PTDPAR, 8);
    IRMD(GPIO,  PUAPAR, PUAPAR, 8);
                                
    if (!display_all)
        printf(INVREG,reg);
}

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

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

    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_dma0 (char *reg, int regread, uint32 value)
{
    IRMD(DMA0,  SAR,    SAR,    32);
    IRMD(DMA0,  DAR,    DAR,    32);
    IRMD(DMA0,  DCR,    DCR,    32);
    IRMD(DMA0,  BCR,    BCR,    32);    /*User needs to determine if MPARK[BCR24Bit] = 1*/
    IRMD(DMA0,  DSR,    DSR,    8);
    
    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_dma1 (char *reg, int regread, uint32 value)
{
    IRMD(DMA1,  SAR,    SAR,    32);
    IRMD(DMA1,  DAR,    DAR,    32);
    IRMD(DMA1,  DCR,    DCR,    32);
    IRMD(DMA1,  BCR,    BCR,    32);    /*User needs to determine if MPARK[BCR24Bit] = 1*/
    IRMD(DMA1,  DSR,    DSR,    8);
    
    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_dma2 (char *reg, int regread, uint32 value)
{
    IRMD(DMA2,  SAR,    SAR,    32);
    IRMD(DMA2,  DAR,    DAR,    32);
    IRMD(DMA2,  DCR,    DCR,    32);
    IRMD(DMA2,  BCR,    BCR,    32);    /*User needs to determine if MPARK[BCR24Bit] = 1*/
    IRMD(DMA2,  DSR,    DSR,    8);
    
    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_dma3 (char *reg, int regread, uint32 value)
{
    IRMD(DMA3,  SAR,    SAR,    32);
    IRMD(DMA3,  DAR,    DAR,    32);
    IRMD(DMA3,  DCR,    DCR,    32);
    IRMD(DMA3,  BCR,    BCR,    32);    /*User needs to determine if MPARK[BCR24Bit] = 1*/
    IRMD(DMA3,  DSR,    DSR,    8);
    
    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_uart0 (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_NOWR(UART0,    UIP,    8);
    IRMD_NORD(UART0,    UOP1,   8);
    IRMD_NORD(UART0,    UOP0,   8);

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

/********************************************************************/
static void
irmd_uart1 (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);
    IRMD_NOWR(UART1,    UIP,    8);
    IRMD_NORD(UART1,    UOP1,   8);
    IRMD_NORD(UART1,    UOP0,   8);

    if (!display_all)
        printf(INVREG,reg);
}
/********************************************************************/
static void
irmd_uart2 (char *reg, int regread, uint32 value)
{
    IRMD(UART2, UMR,    UMR,    8);

⌨️ 快捷键说明

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