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

📄 regs.h

📁 MC9S12C32 LIN-BUS源码(编译环境:CodeWarriorV3.1)
💻 H
字号:
#ifndef REGS_H
#define REGS_H
/******************************************************************************
*
*       Copyright (C) 2003 Motorola, Inc.
*       All Rights Reserved
*
* Filename:     $RCSfile: regs.h,v $
* Author:       $Author: ttz778 $
* Locker:       $Locker:  $
* State:        $State: Exp $
* Revision:     $Revision: 1.0 $
*
* Functions:    Register definition file
*
* History:      Use the RCS command log to display revision history
*               information.
*
* Description:  
*
* Notes:        In order to eliminate warning messages L1912 "Object xxx overlaps
*               with another", you can replace LIN_Reg definition 
*               extern volatile LIN_REGTYPE LIN_Reg; 
*               by: #define LIN_Reg (*(volatile LIN_REGTYPE*)0x1000) in regs.h file
*               and delete this declaration in lininit.c file.
*               Alternatively, you can disable this message.
*               Note that for the first mentioned approach, debug information 
*               for variables are not generated and they do not longer show up
*               in the map file.      
*
******************************************************************************/

/* Registers used for mapping RAM and I/O registers */

#if defined(COSMIC12)
#define   IOABS(address)  @address
volatile  LIN_BYTE LIN_INITRM IOABS(0x10);    /* RAM mapping register - location after reset */
volatile  LIN_BYTE LIN_INITRG IOABS(0x11);    /* IO mapping register - location after reset */
volatile  LIN_BYTE LIN_INITEE IOABS(0x12);    /* EEPROM mapping register - location after reset */
volatile  LIN_BYTE LIN_MISC   IOABS(0x13);    /* mapping control register - location after reset */
#endif /* defined(COSMIC12) */

#if defined(CW12)
#define IOBYTEABS(address) (*(( volatile LIN_BYTE*) (address)))
#define LIN_INITRM IOBYTEABS(0x10)  /* RAM mapping register - location after reset */
#define LIN_INITRG IOBYTEABS(0x11)  /* IO mapping register - location after reset */
#define LIN_INITEE IOBYTEABS(0x12)  /* EEPROM mapping register - location after reset */
#define LIN_MISC   IOBYTEABS(0x13)  /* mapping control register - location after reset */
#endif /* defined(CW12) */

/* Type that map registers into structure elements.                         */
/*      NB: order is important! Don't omit reserved or unused registers!    */

typedef struct {
    volatile LIN_BYTE porta;  /* 0x00 port a */
    volatile LIN_BYTE portb;  /* 0x01 port b */
    volatile LIN_BYTE ddra;   /* 0x02 data direction port a */
    volatile LIN_BYTE ddrb;   /* 0x03 data direction port b */
#if defined(C32)
    volatile LIN_BYTE reserved1[0x3C];  /* Timer section starts from 0x40 */ 
#endif /* defined(C32) */
    volatile LIN_BYTE tios;   /* time select */
    volatile LIN_BYTE cforc;  /* compare force */
    volatile LIN_BYTE oc7m;   /* oc7 mask */
    volatile LIN_BYTE oc7d;   /* oc7 data */
    volatile LIN_WORD  tcnt;  /* timer counter */
	volatile LIN_BYTE tscr;   /* timer system control */
#if defined(C32)
    volatile LIN_BYTE ttov;   /* timer toggle overflow */ 
#endif /* defined(C32) */
    volatile LIN_BYTE tctl1;  /* timer control 1 */
    volatile LIN_BYTE tctl2;  /* timer control 2 */
    volatile LIN_BYTE tctl3;  /* timer control 3 */
    volatile LIN_BYTE tctl4;  /* timer control 4 */
    volatile LIN_BYTE tmsk1;  /* timer interrupt mask 1 */
    volatile LIN_BYTE tmsk2;  /* timer interrupt mask 2 */
    volatile LIN_BYTE tflg1;  /* timer interrupt flag 1 */
    volatile LIN_BYTE tflg2;  /* timer interrupt flag 2 */
    volatile LIN_WORD  tc0;   /* timer capture/compare 0 */
    volatile LIN_WORD  tc1;   /* timer capture/compare 1 */
    volatile LIN_WORD  tc2;   /* timer capture/compare 2 */
    volatile LIN_WORD  tc3;   /* timer capture/compare 3 */
    volatile LIN_WORD  tc4;   /* timer capture/compare 4 */
    volatile LIN_WORD  tc5;   /* timer capture/compare 5 */
    volatile LIN_WORD  tc6;   /* timer capture/compare 6 */
    volatile LIN_WORD  tc7;   /* timer capture/compare 7 */
#if defined(C32)
    volatile LIN_BYTE reserved2[0x68];  /* SCI section starts from 0xC8 */ 
#endif /* defined(C32) */
    volatile LIN_BYTE sc0bdh; /* sci 0 baud rate high */
    volatile LIN_BYTE sc0bdl; /* sci 0 baud rate low */
    volatile LIN_BYTE sc0cr1; /* sci 0 control register 1 */
    volatile LIN_BYTE sc0cr2; /* sci 0 control register 2 */
    volatile LIN_BYTE sc0sr1; /* sci 0 status register 1 */
    volatile LIN_BYTE sc0sr2; /* sci 0 status register 2 */
    volatile LIN_BYTE sc0drh; /* sci 0 data register high */
    volatile LIN_BYTE sc0drl; /* sci 0 data register low */
#if defined(C32)
    volatile LIN_BYTE reserved3[0x188];  /* PortP section starts from 0x258 */
    volatile LIN_BYTE portp;  /* 0x258 port p */
    volatile LIN_BYTE ptip;   /* 0x259 input port p */
    volatile LIN_BYTE ddrp;   /* 0x25A data direction port p */	
#endif /* defined(C32) */

    /* can be continued */
} LIN_REGTYPE;

/* Extern declaration of common-purpose structure with registers definition */
#if defined(CW12)
#pragma DATA_SEG LinReg
#endif /* defined(CW12) */

#if defined(COSMIC12)
#pragma section [lin_reg]
#endif /* defined(COSMIC12) */

// extern volatile LIN_REGTYPE LIN_Reg; 
#define LIN_Reg (*(volatile LIN_REGTYPE*)0x1000)
/* See notes in the file header for more clarification when to use both approaches */

#if defined(CW12)
#pragma DATA_SEG DEFAULT
#endif /* defined(CW12) */

#if defined(COSMIC12)
#pragma section []
#endif /* defined(COSMIC12) */

/* Register definitions used in the driver sources */

#define LIN_PORTA  (*( (volatile LIN_BYTE*) &(LIN_Reg.porta) ))     /* port A */
#define LIN_PORTB  (*( (volatile LIN_BYTE*) &(LIN_Reg.portb) ))     /* port B */
#define LIN_DDRA   (*( (volatile LIN_BYTE*) &(LIN_Reg.ddra) ))      /* data direction port A */
#define LIN_DDRB   (*( (volatile LIN_BYTE*) &(LIN_Reg.ddrb) ))      /* data direction port B */
#define LIN_PORTP  (*( (volatile LIN_BYTE*) &(LIN_Reg.portp) ))     /* port P */
#define LIN_DDRP   (*( (volatile LIN_BYTE*) &(LIN_Reg.ddrp) ))      /* data direction port P */
#define LIN_PTIP   (*( (volatile LIN_BYTE*) &(LIN_Reg.ptip) ))      /* input port P */

#define LIN_TIOS   (*( (volatile LIN_BYTE*) &(LIN_Reg.tios) ))      /* time select */
#define LIN_CFORC  (*( (volatile LIN_BYTE*) &(LIN_Reg.cforc) ))     /* compare force */
#define LIN_OC7M   (*( (volatile LIN_BYTE*) &(LIN_Reg.oc7m) ))      /* oc7 mask */
#define LIN_OC7D   (*( (volatile LIN_BYTE*) &(LIN_Reg.oc7d) ))      /* oc7 data */
#define LIN_TCNT   (*( (volatile LIN_WORD*) &(LIN_Reg.tcnt) ))      /* timer counter */
#define LIN_TSCR   (*( (volatile LIN_BYTE*) &(LIN_Reg.tscr) ))      /* timer system control */
#if defined(C32)
#define LIN_TTOV   (*( (volatile LIN_BYTE*) &(LIN_Reg.ttov) ))      /* timer toggle overflow */
#endif /* defined(C32) */
#define LIN_TCTL1  (*( (volatile LIN_BYTE*) &(LIN_Reg.tctl1) ))     /* timer control 1 */
#define LIN_TCTL2  (*( (volatile LIN_BYTE*) &(LIN_Reg.tctl2) ))     /* timer control 2 */
#define LIN_TCTL3  (*( (volatile LIN_BYTE*) &(LIN_Reg.tctl3) ))     /* timer control 3 */
#define LIN_TCTL4  (*( (volatile LIN_BYTE*) &(LIN_Reg.tctl4) ))     /* timer control 4 */
#define LIN_TMSK1  (*( (volatile LIN_BYTE*) &(LIN_Reg.tmsk1) ))     /* timer interrupt mask 1 */
#define LIN_TMSK2  (*( (volatile LIN_BYTE*) &(LIN_Reg.tmsk2) ))     /* timer interrupt mask 2 */
#define LIN_TFLG1  (*( (volatile LIN_BYTE*) &(LIN_Reg.tflg1) ))     /* timer interrupt flag 1 */
#define LIN_TFLG2  (*( (volatile LIN_BYTE*) &(LIN_Reg.tflg2) ))     /* timer interrupt flag 2 */
#define LIN_TC0    (*( (volatile LIN_WORD*) &(LIN_Reg.tc0) ))       /* timer capture/compare 0 */
#define LIN_TC1    (*( (volatile LIN_WORD*) &(LIN_Reg.tc1) ))       /* timer capture/compare 1 */
#define LIN_TC2    (*( (volatile LIN_WORD*) &(LIN_Reg.tc2) ))       /* timer capture/compare 2 */
#define LIN_TC3    (*( (volatile LIN_WORD*) &(LIN_Reg.tc3) ))       /* timer capture/compare 3 */
#define LIN_TC4    (*( (volatile LIN_WORD*) &(LIN_Reg.tc4) ))       /* timer capture/compare 4 */
#define LIN_TC5    (*( (volatile LIN_WORD*) &(LIN_Reg.tc5) ))       /* timer capture/compare 5 */
#define LIN_TC6    (*( (volatile LIN_WORD*) &(LIN_Reg.tc6) ))       /* timer capture/compare 6 */
#define LIN_TC7    (*( (volatile LIN_WORD*) &(LIN_Reg.tc7) ))       /* timer capture/compare 7 */

#define LIN_SC0BDH (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0bdh) ))    /* SCI 0 baud rate high */
#define LIN_SC0BDL (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0bdl) ))    /* SCI 0 baud rate low */
#define LIN_SC0CR1 (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0cr1) ))    /* SCI 0 control register 1 */
#define LIN_SC0CR2 (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0cr2) ))    /* SCI 0 control register 2 */
#define LIN_SC0SR1 (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0sr1) ))    /* SCI 0 status register 1 */
#define LIN_SC0SR2 (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0sr2) ))    /* SCI 0 status register 2 */
#define LIN_SC0DRH (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0drh) ))    /* SCI 0 data register high */
#define LIN_SC0DRL (*( (volatile LIN_BYTE*) &(LIN_Reg.sc0drl) ))    /* SCI 0 data register low */

/******************* Bit masks *************************/

/* define bit mask for SCI */
#define     LIN_SCCR1_LOOPS     0x80        /* Loop Mode/Single Wire Mode Enable in SCCR1 */
#define     LIN_SCCR1_WOMS      0x40        /* Wired-or mode for serial pins     in SCCR1 */
#define     LIN_SCCR1_RSRC      0x20        /* Receive source                    in SCCR1 */
#define     LIN_SCCR1_M         0x10        /* Mode (character lenght)           in SCCR1 */
#define     LIN_SCCR1_WAKE      0x08        /* Wake-up by address Mark/Idle      in SCCR1 */
#define     LIN_SCCR1_ILT       0x04        /* Idle line type                    in SCCR1 */
#define     LIN_SCCR1_PE        0x02        /* Parity Ebable                     in SCCR1 */
#define     LIN_SCCR1_PT        0x01        /* Parity bit                        in SCCR1 */

#define     LIN_SCCR2_TIE       0x80        /* Transmit interrupt enable bit     in SCCR2 */
#define     LIN_SCCR2_TCIE      0x40        /* Transfer complited intrerrupt enable SCCR2 */
#define     LIN_SCCR2_RIE       0x20        /* Reciver interrupt enable          in SCCR2 */
#define     LIN_SCCR2_ILIE      0x10        /* Idle line interrupt ebable        in SCCR2 */
#define     LIN_SCCR2_TE        0x08        /* Transmitter enable                in SCCR2 */
#define     LIN_SCCR2_RE        0x04        /* Receiver enable                   in SCCR2 */
#define     LIN_SCCR2_RWU       0x02        /* Receiver wake-up                  in SCCR2 */
#define     LIN_SCCR2_SBK       0x01        /* Send Break                        in SCCR2 */

#define     LIN_SCSR1_TDRE      0x80       /* Transmit Data Register Empty Flag  in SCSR1 */
#define     LIN_SCSR1_TC        0x40       /* Transmit                           in SCSR1 */
#define     LIN_SCSR1_RDRF      0x20       /* Receiver data register full flag   in SCSR1 */
#define     LIN_SCSR1_IDLE      0x10       /* Idle line detected flag            in SCSR1 */
#define     LIN_SCSR1_OR        0x08       /* Overrun error flag                 in SCSR1 */
#define     LIN_SCSR1_NF        0x04       /* Noise error flag                   in SCSR1 */
#define     LIN_SCSR1_FE        0x02       /* Framing error flag                 in SCSR1 */
#define     LIN_SCSR1_PE        0x01       /* Parity error flag                  in SCSR1 */

#define     LIN_SCDRH_R8        0x80        /* Received bit 8                    in SCDRH */
#define     LIN_SCDRH_T8        0x40        /* Transmit bit 8                    in SCDRH */

/* bit masks for Timer Module (STM) */

#define     LIN_TM_TEN         0x80        /* STM Timer Enable bit */
#define     LIN_TM_TFFCA       0x10        /* STM fast flag clear bit */
#define     LIN_TM_PR          0x07        /* STM Prescaler bits */

#define     LIN_TM_IOS0        0x01        /* Channel 0 Input Capture/Output Compare select bit */
#define     LIN_TM_C0F         0x01        /* Channel 0 interrupt flag bit */
#define     LIN_TM_C0I         0x01        /* Channel 0 interrupt enable bit */
#define     LIN_TM_OL0         0x01        /* Channel 0 Output Level bit */
#define     LIN_TM_OM0         0x02        /* Channel 0 Output Mode bit */
#define     LIN_TM_EDG0A       0x01        /* Channel 0 Input Capture Edge control bit A */
#define     LIN_TM_EDG0B       0x02        /* Channel 0 Input Capture Edge control bit B */
            
#define     LIN_TM_IOS1        0x02        /* Channel 1 Input Capture/Output Compare select bit */
#define     LIN_TM_C1F         0x02        /* Channel 1 interrupt flag bit */
#define     LIN_TM_C1I         0x02        /* Channel 1 interrupt enable bit */
#define     LIN_TM_OL1         0x04        /* Channel 1 Output Level bit */
#define     LIN_TM_OM1         0x08        /* Channel 1 Output Mode bit */
#define     LIN_TM_EDG1A       0x04        /* Channel 1 Input Capture Edge control bit A */
#define     LIN_TM_EDG1B       0x08        /* Channel 1 Input Capture Edge control bit B */

/* general purpose I/O pins number */
#define     LIN_PIN0    0x01
#define     LIN_PIN1    0x02
#define     LIN_PIN2    0x04
#define     LIN_PIN3    0x08
#define     LIN_PIN4    0x10
#define     LIN_PIN5    0x20
#define     LIN_PIN6    0x40
#define     LIN_PIN7    0x80

#endif /* !define (REGS_H) */

⌨️ 快捷键说明

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