📄 freescale
字号:
/** ###################################################################
** Filename : Smoke_Detector.C
** Project : Smoke_Detector
** Processor : MC9S08JM60CLHE
** Version : Driver 01.11
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2009-10-21, 18:24
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** (c) Copyright UNIS, spol. s r.o. 1997-2008
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE Smoke_Detector */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "LIGHT_AD.h"
#include "IRLED.h"
#include "OAPOWER.h"
#include "LED.h"
#include "Timer_Variable.h"
#include "KEY.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "AD_Process.h"
void main(void)
{
/* Write your local variable definition here */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
for(;;)
{
Sample();
Average();
if (light_average > (dark_average + 30))
{
if (alarm_flag == 0)
{
smoke_detect_count++; // Increment detection counter
smoke_detect_count &= 0x03; // Only count values of up to 3
if (smoke_detect_count == 1)
Timer_Variable_SetDutyMS(4000); //This cuts the sample period in half to 4s
// This cuts the sample period in half to 4s
else if (smoke_detect_count == 2)
Timer_Variable_SetDutyMS(1000); // which makes the sample period 1s
else if (smoke_detect_count == 3)
{
alarm_flag = 1; // Set alarm flag
LED_SetVal(); // Turn on visible LED
}
}
}
else // light_average not > dark_average+30
{
LED_ClrVal(); // Turn off visible LED, but leave pull-up
alarm_flag = 0; // If no smoke present, clear alarm flag
smoke_detect_count = 0; // Clear smoke detect counter
Timer_Variable_SetDutyMS(8000);
}
}
}
/* END Smoke_Detector */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 3.03 [04.07]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -