📄 g20modem.c
字号:
#include <mega128.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "typedef.h"
#include "app.h"
#include "attention.h"
#include "g20modem.h"
#include "g20serialdrv.h"
#include "rtc.h"
#include "serialdrv.h"
#include "timer.h"
#include "UDP.h"
#include "protocol.h"
#define POWER_ON PORTB.7=0
#define POWER_OFF PORTB.7=1
#define G20_RESET PINB.5
MODEMSTATUS my_mdm_status;
void g20_mdm_init()
{
DDRB |= 0x80;
PORTB |= 0x80;
my_mdm_status.bModemOn = TRUE;
my_mdm_status.bModemReset = FALSE;
if(g20_mdm_rest() == FALSE)
{
return;
}
}
unsigned char g20_mdm_off()
{
TIMERTICK *pTimer = NULL;
pTimer = timer_settimer(20000);
// while((PINB & 0x20) == 0x20)
while(G20_RESET)
{
wdr();
POWER_ON;
timer_delay(3000);
POWER_OFF;
timer_delay(2000);
if(timer_checktimeout(pTimer) == TRUE)
{
return FALSE;
}
}
#if defined (DEBUG_MODE)
sp_send("\r\n关闭MODEM\r\n");
#endif
return TRUE;
}
unsigned char g20_mdm_on()
{
TIMERTICK *pTimer = NULL;
pTimer = timer_settimer(20000);
// while((PINB & 0x20) != 0x20)
while(G20_RESET == 0)
{
wdr();
POWER_ON;
timer_delay(3000);
POWER_OFF;
timer_delay(5000);
if(timer_checktimeout(pTimer) == TRUE)
{
return FALSE;
}
}
#if defined (DEBUG_MODE)
sp_send("\r\n打开MODEM\r\n");
#endif
return TRUE;
}
unsigned char g20_mdm_rest()
{
TIMERTICK *pTimer;
pTimer = timer_settimer(60000);
if(pTimer == NULL)
return FALSE;
while(timer_checktimeout(pTimer) != TRUE)
{
wdr();
if((g20_mdm_off())&&(g20_mdm_on()))
{
return TRUE;
}
}
return FALSE;
}
void g20_mdm_proc()
{
system_initial_flag = FALSE;
WORK_LED = 0;
g20_mdm_rest();
attention_init();
attention_dialproc();
attention_udpproc();
timer_delay(100);
system_initial_flag = TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -