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

📄 jtgthcs12.c

📁 在Freescale16位单片机MC9s12dp256上移植了J1939源码和操作系统(ucOSII)。
💻 C
字号:
/*--------------------------------------------------------------------
       TGTHCS12.C
  --------------------------------------------------------------------
       Copyright (C) 1998-2003 Vector Informatik GmbH, Stuttgart

       Function: Target adaptation for the MC9S12DP256B microcontroller
  --------------------------------------------------------------------*/
                                


/*--------------------------------------------------------------------*/
/*  include files                                                     */
/*--------------------------------------------------------------------*/
#include "UCOS_II.h"
#include "JTarget.h"
#include  <mc9s12dp256.h>     /* derivative information */

#ifdef COSMIC12
#include <iob32.h>
#endif /* COSMIC12 */



/*--------------------------------------------------------------------*/
/*  local definitions                                                 */
/*--------------------------------------------------------------------*/
//#ifdef __MWERKS__
//volatile unsigned char CRGFLG @(0x37); /*! real time interrupt flag */
//volatile unsigned char CRGINT @(0x38); /*! real time interrupt enable */
//volatile unsigned char RTICTL @(0x3B); /*! real time interrupt control */
/* Register definitions for a ECT down count timer for benchmark */
//#define TIM_MOD_BASIC_ADR   0x40
//volatile unsigned char  TSCR1 @(TIM_MOD_BASIC_ADR+0x06); /*! real time interrupt control */
//volatile unsigned char  MCCTL @(TIM_MOD_BASIC_ADR+0x26); /*! real time interrupt control */
//volatile unsigned char  MCFLG @(TIM_MOD_BASIC_ADR+0x27); /*! real time interrupt control */
//volatile unsigned short MCCNT @(TIM_MOD_BASIC_ADR+0x36); /*! real time interrupt control */
//#endif /* __MWERKS__ */



/*--------------------------------------------------------------------*/
/*  external functions                                                */
/*--------------------------------------------------------------------*/
void Tim_PIT(void);
//void TERMIO_Init(void);


/*--------------------------------------------------------------------*/
/*  public functions                                                  */
/*--------------------------------------------------------------------*/

/*!
  \brief Configure connection between CAN and CPU.

  This function configures the connection between the CAN controller
  used and the microcontroller. It is called from the CAN module.
  Any initialization regarding interrupt behaviour and chip signaling
  should be done here.
*/
void Can_Configure(void)
{
#ifdef COSMIC12
  _asm("andcc #$EF\n");         /* enable all interrupts                */
#endif /* COSMIC12 */
//#ifdef __MWERKS__
  __asm {
    CLI                         ; enable all interrupts
  } /* asm */
//#endif /* __MWERKS__ */
}


/*!
  \brief Configure connection between timer and CPU.

  This function configures the connection between the timer used and
  the microcontroller. It is called from the timer module.
  Any initialization regarding interrupt behaviour, chip signaling
  and start values should be done here.
*/
void Tim_ConfigureTimer(void)
{
  MCCTL = 0xC2;                 /* configure timer control register       */
}                               /* enable underflow interrupt and set the */
						        /* prescaler to 8                         */

/*!
  \brief Enable timer.

  This function enables the timer. It is called from the timer module.
*/
void Tim_EnableTimer(void)
{
  /* NOTICE: this timings are for 8 MHz IPbus clock speed               */
  /*         timer prescaler is dimensiones to 8 -> resolution 1us      */
  /*         1 ms cycle with RTICTL = 0x03E8                            */
  /*         2 ms cycle with RTICTL = 0x07D0                            */
  /*         5 ms cycle with RTICTL = 0x1388                            */
  MCCTL |= 0x04;                    /* enable down count timer */
  MCCNT = (unsigned short) 0x1388;  /* timer delay of about 5 ms        */
  MCFLG = 0x80;  					/* clear underflow flag */
}


/*!
  \brief Disable timer.

  This function disables the timer. It is called from the timer module.
*/
void Tim_DisableTimer(void)
{
  MCCTL &= (~0x04);               /* disable timer                        */
}


/*!
  \brief Reload timer.

  This function reloads the timer. It is called from the timer module.
*/

#pragma CODE_SEG NON_BANKED

void Tim_ReloadTimer(void)
{
  ;	  /* nothing to do - auto reload */
}


/*!
  \brief Reset timer interrupt request.

  This function clears a pending timer interrupt request.
  It is called from the timer module.
*/

void Timer_ClearPendingInterrupt(void)
{
  MCFLG = 0x80;                /* clear timer interrupt flag           */
}
#pragma CODE_SEG DEFAULT_ROM

/*!
  \brief Prepare the environment.

  This function is called from the protocol stack to do necessary
  settings after module startup.
*/
void PrepareEnvironment(void)
{
#ifdef COSMIC12
  _asm("orcc #$10\n");          /* disable all interrupts               */
#endif /* COSMIC12 */
//#ifdef __MWERKS__
  __asm {
    SEI;   // disable all interrupts
  } /* asm */
 //TERMIO_Init();
//#endif /* __MWERKS__ */
}


/*!
  \brief Timer ISR.

  The timer interrupt service routine.
  \sa Tim_PIT()
*/
#pragma CODE_SEG NON_BANKED
			
#pragma TRAP_PROC
#ifdef COSMIC12
@interrupt void
#endif /* COSMIC12 */
//#ifdef __MWERKS__
#pragma TRAP_PROC
void interrupt 26  /* Modulus Down Counter Interrupt at vector #26   */
//#endif /* __MWERKS__ */
Tim_ISR(void) 
{
 //#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register     */
    //OS_CPU_SR  cpu_sr;
 //#endif
 //OS_ENTER_CRITICAL(); 
   Tim_PIT();
 
//OS_EXIT_CRITICAL();
}
#pragma CODE_SEG DEFAULT_ROM

/*--------------------------------------------------------------------*/
/*  documentation                                                     */
/*--------------------------------------------------------------------*/

/*!
  \file
  \brief Target adaptation for the MC9S12DP256B microcontroller.
  \par File name \$Workfile: tgthcs12.c $
  \version \$Revision: 3 $
  \date \$Date: 10.06.03 14:20 $
  \author (c) 1998-2003 by Vector Informatik GmbH, Stuttgart

  The definitions included determine the actual hardware layout
  of your board. Fit it to your requirements.

  Define the used compiler.
  Actually differentiated settings are
  - __MWERKS__ - Metrowerks CodeWarrior V1.2
  - COSMIC12   - Cosmic C Cross Compiler V4.2
  Other compilers might be used, but are not distinguished specifically.
*/

⌨️ 快捷键说明

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