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

📄 lin_isr.c

📁 芯科原厂所有c8051fxx程序的例子。
💻 C
字号:
// Copyright (c) 2006 SILICON LABORATORIES, INC.
//
// FILE NAME   : LIN_ISR.c
// TARGET MCU  : C8051F52x-53x
// DESCRIPTION : LIN interrupt service routine for Core LIN API
//
// This file handles LIN interrupts.
//


//-----------------------------------------------------------------------------
// Header Files
//-----------------------------------------------------------------------------
//
#include <c8051F520.h>
#include "LIN.h"


//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// LIN_ISR ()
//-----------------------------------------------------------------------------
//
// Services LIN interrupts.
//
void LIN_ISR (void) interrupt INTERRUPT_LIN
{
   l_u8  status;

#if (LIN_MODE == LIN_SLAVE)
   l_bool   frame_data_valid;
#endif

   // Get the value of LINST.
   _LIN_IREG_READ (LINST, status);

   // Handle any LIN interrupt source.

#if (LIN_MODE == LIN_SLAVE)

   // Bus Idle Timeout
   if (status & IDLTOUT)
   {
      l_slave_go_to_sleep ();
   }

   // Aborted Transmission
   if (status & ABORT)
   {

   }

   // Data Requested
   if (status & DTREQ)
   {
      l_data_requested ();
   }

   // Communication Error
   if (status & ERROR)
   {
      l_ifc_update_status_std_ifc (TRUE);
   }

#endif   // LIN_MODE == LIN_SLAVE

   // Wake-up Request
   if (status & WAKEUP)
   {
      // Reset the SLEEP bit.
      _LIN_IREG_CLEAR_BITS (LINCTRL, SLEEP);

      // Ignore the DONE bit.
      // DONE is not cleared when a WAKEUP event occurs, so it should
      // be ignored as data in the LINDT registers is not valid.
      status &= ~DONE;

#if (LIN_MODE == LIN_MASTER)

      // Point to schedule table to start frame header transmission.
      l_sch_set_std_ifc (normal_schedule, 0);

      // Disable LIN interrupts.
      l_sys_irq_disable ();

#endif   // LIN_MODE == LIN_MASTER

   }

#if (LIN_MODE == LIN_SLAVE)

   // Transmission Complete
   if (status & DONE)
   {
      // Initialize frame_data_valid to TRUE.
      frame_data_valid = TRUE;

      // If the frame was received, call l_ifc_rx_std_ifc ().
      if (frame_direction == IN_FRAME)
      {
         l_ifc_rx_std_ifc ();
      }

      // If the frame was transmitted, call l_ifc_tx_std_ifc ().
      else if (frame_direction == OUT_FRAME)
      {
         l_ifc_tx_std_ifc ();
      }
   }

   // If in slave mode, clear the interrupt bits after servicing
   // the interrupt.
   l_clear_status ();

#endif   // LIN_MODE == LIN_SLAVE

}

⌨️ 快捷键说明

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