📄 main.c
字号:
//头文件
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908GZ60.h> /* include peripheral declarations */
//
#include <mcu.h>
#include <can.h>
#include <adc.h>
#include <mc33389.h>
#include <mc33993.h>
#include <lcd_seg.h>
#include <lcd_ziku.h>
#include <lcd_b.h>
//#include <lcd.h>
#include <lcd_alarm.h>
#include <led.h>
#include <motor.h>
#include <jly.h>
#include <timer.h>
#include <TIME.H>
clock_t coun=0;
#include <gz60_sleep.h>
//主函数
void main(void){
//初始化
init_gz60(); //初始化控制器
init_spi(); //SPI初始化
init_port(); //端口初始化
init_tbm(); //时基初始化
init_tim1(); //定时器1初始化
init_adc(); //AD初始化
init_mscan(); //CAN初始化
//
BAT_EN=0; //使能2576-5.0工作
RST_6606=0; //sti6606复位
RST=0; //LCD复位
back_light_off; //开背光
delay5ms(6); //延时50ms
init_mc33389(); //mc33389初始化
//CAN及dog
LED=0; //指示灯亮
RST_6606=1; //sti6606使能
RST=1; //LCD使能
init_cgm(); //PLL倍频
EnableInterrupts; /* enable interrupts */
inti_mc33993(); //mc33993初始化
init_mil(); //上电读E2PROM初始化
init_pcf8576(); //里程/小LCD初始化
//at24_init(); //第一次使用E2PROM清零
init_lcd(); //初始化点阵LCD
motor_go0(); //仪表指针复位
init_led(); //led指示灯初始化
coun=clock();
//中断:时基,定时器1,CAN接收,
/* include your code here */
//使能中断后的初始化
first_wakeup_flag=0;
first_sleep_flag=1;
for(;;) {
//if(vcc_wakeup_flag || warn_wakeup_flag){
//can_wakeup_flag=0;
if(first_wakeup_flag){
wakeup();
first_wakeup_flag=0;
if(vcc_wakeup_flag) safe_flag=1;
}
gz60_sleep_flag=0;
first_sleep_flag=1; //第一次休眠
__RESET_WATCHDOG(); // feeds the dog
//主循环
mc993_status(); //以上读取33993状态
__RESET_WATCHDOG();
/*
if(xjql_b_flag){ //小计清零有效
distance_subclr();
disp_pcf8576();
xjql_b_flag=0;
} */
__RESET_WATCHDOG();
lcdbutton(); //时间调整按钮
__RESET_WATCHDOG();
ad_oper(); //AD转换
__RESET_WATCHDOG();
mc33389_fault(); //CAN故障检测
__RESET_WATCHDOG();
yb_step_first();
yqy_step_count();
zqy_step_count();
cs_step_count();
zs_step_count();
dy_step_count();
ry_step_count();
sw_step_count();
jy_step_count();
__RESET_WATCHDOG();
//以上电机计算步数
pcfdisplay(); //以上里程显示
__RESET_WATCHDOG();
statushow(); //LCD报警
__RESET_WATCHDOG();
lcd_clock_flash(); //LCD时钟
__RESET_WATCHDOG();
yb_step_first();
yqy_step_count();
zqy_step_count();
cs_step_count();
zs_step_count();
dy_step_count();
ry_step_count();
sw_step_count();
jy_step_count();
__RESET_WATCHDOG();
//以上电机计算步数
jly_oper(); //记录仪
led_status();
refresh_led(); //以上LED状态显示
__RESET_WATCHDOG();
//////////////
//}
//else
/*{ //进入休眠状态
gz60_sleep_flag=1;
first_wakeup_flag=1; //第一次唤醒
__RESET_WATCHDOG();
if(first_sleep_flag)
{
ready_sleep();
first_sleep_flag=0;
}
} */
//////
} /* loop forever */
/* please make sure that you never leave this function */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -