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

📄 monitor.c

📁 本程序为ST公司开发的源代码
💻 C
字号:
/**************************************************
 *
 * monitor.c
 *
 * CVS ID:   $Id: monitor.c,v 1.24 2007/09/26 15:06:52 dellorto Exp $
 * Author:   Raffaele Belardi [RB] - STM
 * Date:     $Date: 2007/09/26 15:06:52 $
 * Revision: $Revision: 1.24 $
 *
 * Description:
 *
 *   Main entry point for the Monitor task.
 *
 ***************************************************
 *
 * COPYRIGHT (C) ST Microelectronics  2005
 *            All Rights Reserved
 *
 ***************************************************
 *
 * STM CVS Log:
 *
 * $Log: monitor.c,v $ * Revision 1.24  2007/09/26 15:06:52  dellorto * modified monitor timeslice to 1ms * * Revision 1.23  2007/04/11 14:20:14  belardi * Integration of HAVE_CD_MECHA modification by [GP] *
 * Revision 1.22  2006/12/04 14:45:12  dellorto
 * no message
 *
 * Revision 1.21  2006/11/25 08:51:21  belardi
 * Coditional compilatio for HAVE_TEMP_SENSOR
 *
 * Revision 1.20  2006/11/24 11:17:46  zhong
 * Karbin for Temperature sensor detect
 *
 * Revision 1.19  2006/10/09 15:18:20  dellorto
 * no message
 *
 * Revision 1.18  2006/09/18 09:55:24  belardi
 * Corrected CVS keyword usage
 *
 * Revision 1.17  2006/09/18 09:24:52  belardi
 * Added Log CVS keyword into file header
 *
 *
 ***************************************************/

#include "gendef.h"
#include "hwreg.h"
#include "osal.h"

#include "srvinc.h"

#include "utility.h"
#include "loader.h"
#include "temper.h"
#include "monitor.h"


/******************************************************************************/
/* Function:  InitMonitor                                                     */
/*                                                                            */
/*! \brief    Initalize the Monitor variables
 *  \param    void
 *  \return   void
 *  \remark
 */
/******************************************************************************/
void InitMonitor(void)
{
#if (1 == HAVE_TEMP_SENSOR)
  temperature_init();
#endif
  // The important start_timer is in accordoptimer.c!!!
  start_timer(MONITOR_TIMESLICE, T1ms);
}

/******************************************************************************/
/* Function:  Monitor                                                         */
/*                                                                            */
/*! \brief    Checks some switches and variables and wakes up relevant tasks if needed
 *  \param    void
 *  \return   void
 *  \remark
 */
/******************************************************************************/

void Monitor(void)
{
#if (1 == HAVE_TEMP_SENSOR)
  temperature_fsm();
#endif
}


#ifndef APM_PICKUP

#define HW_EJECT_SET_OUT_EVENT(x)   do { event_out[HW_EJECT_EVENT].event = (x); } while(0)

/* HW Eject switch states */
typedef enum
{
  HW_EJECT_S_RELEASED_OR_CHANGING,
  HW_EJECT_S_PRESSED_AND_STABLE
} t_hw_eject_state;

#if (HAVE_CD_MECHA == 1)
static uint8              hw_eject_switch_val;   /*!<\brief Current switch value */
static t_hw_eject_state   hw_eject_state;        /*!<\brief State maschine in ldrCheckSwitch */
#endif

void hw_eject_switch_init(void)
{
#if (HAVE_CD_MECHA == 1)
  hw_eject_state      = HW_EJECT_S_RELEASED_OR_CHANGING;
  hw_eject_switch_val = HW_EJECT_RELEASED;
#endif
}


#if (HAVE_CD_MECHA == 1)
void check_hw_eject_switch_isr(void)
{
  uint8 actual_switch_val;

  actual_switch_val = SW_HW_EJECT;

  if (actual_switch_val != hw_eject_switch_val)
  {
    hw_eject_state = HW_EJECT_S_RELEASED_OR_CHANGING;
    hw_eject_switch_val = actual_switch_val;
    if (HW_EJECT_PRESSED == hw_eject_switch_val)
    {
      start_timer(HW_EJECT_TIMER, T100ms);
    }
    else
    {
      stop_timer(HW_EJECT_TIMER);
    }
    HW_EJECT_SET_OUT_EVENT(HW_EJECT_SW_STATUS | hw_eject_switch_val);
  }
  else if ((hw_eject_state != HW_EJECT_S_PRESSED_AND_STABLE)
        && (hw_eject_switch_val == HW_EJECT_PRESSED)
        && (!timer_in_progress(HW_EJECT_TIMER)))
  {
    hw_eject_state = HW_EJECT_S_PRESSED_AND_STABLE;
    HW_EJECT_SET_OUT_EVENT(HW_EJECT_SW_STATUS | HW_EJECT_REQUEST | hw_eject_switch_val);
  }

  event_disable_scheduling();
  event_out_shedule(HW_EJECT_EVENT);
  event_enable_scheduling();
}
#endif // HAVE_CD_MECHA

#endif

⌨️ 快捷键说明

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