target.c

来自「基于mc908GR60的LIN通信例程」· C语言 代码 · 共 88 行

C
88
字号
/* ************************************************************************ */
/*                                                                          */
/*                  Volcano Communications technologies AB                  */
/*                            All rights reserved                           */
/*                                                                          */
/* ************************************************************************ */

/*         File: target.c                                                   */
/*  Description: Target specific functions for COS08SCI LTP example appli-  */
/*               cation                                                     */
/*                                                                          */

#include "target.h"

/* ************************************************************************ */
/* Perform initialisation of development system (if any)                    */
void init_environment(void)
{
} /* init_environment */

/* ************************************************************************ */
/* Perform initialisation of target. Initialise a free running counter at   */
/* 1Mhz.                                                                    */
void init_target(void)
{
  /* Initialize the Timebase interface module 1 */
  TIMERSC = INITTIMER;    /* Reset timer set prescaler */
/* # prescaler value of 4 when Mon08Cyclone clock is used */
/* # prescaler value of 2 when 8MHz clock source is used */  
  
  TIMERMOD = 0xFFFF;	  /* Disable modulo conter  */

  /* Enable LIN GZ48 EVB*/
  /*DDRB = 0xFF;
  PTB = 0x20;*/
  
  /* Enable LIN */
  DDRE = 0x04;
  PTE  = 0x04;

} /* init_target*/

/* ************************************************************************ */
/* Read timer channel A (free running counter at 1Mhz) and return current   */
/* value.                                                                   */
l_u16 l_get_us_counter (void)
{

volatile l_u16 tmp;

  tmp = TIMERCNTH;
  tmp = (tmp << 8) | TIMERCNTL;
  return(tmp);

} /* l_get_us_counter */

/* ************************************************************************ */
/* Restores interrupt level to the previous level, as indicated by the in-  */
/* put previous. On the hc08 family the interrupt level can only be either */
/* "interrupts enabled" or "interrupts disabled".                           */
void l_sys_irq_restore(l_irqmask previous)
{
  if (previous)
  {
    asm sei;  /* disable_interrupt */
  }
  else
  {
    asm cli;  /* enable_interrupt */
  }
} /* v_ctl_ints_restore */



/* ************************************************************************ */
/* Disable interrupts, and return the previous value of the interrupt le-   */
/* vel.                                                                     */
l_irqmask l_sys_irq_disable(void)
{
    l_irqmask x;
    
	asm sei; /* disable_interrupt */	
	x = __isflag_int_enabled();

	return(x);
    
} /* v_ctl_ints_disable */

⌨️ 快捷键说明

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