#include "includes.h" //static unsigned char sucRedLedFlash=0; //static unsigned char sucRedLedSleep=0; unsigned char sucRedLedFlash=0; unsigned char sucRedLedSleep=0; static unsigned char sucBlueLedFlash=0; static unsigned char sucBlueLedSleep=0; static LED_INDICATOR LedIndicator; LED_INDICATOR g_LedInd; void LedInit(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = MODEM_LED1_PIN; GPIO_Init(MODEM_LED1_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = MODEM_LED2_PIN; GPIO_Init(MODEM_LED2_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = FLASH_LIGHT_PIN; GPIO_Init(FLASH_LIGHT_PORT, &GPIO_InitStructure); MODEM_LED1_LOW; MODEM_LED2_LOW; } timer_t ledTimer; void LedProcess(unsigned char reset) { static unsigned int sucCt=0; static unsigned char RedLedCt=0; static unsigned char RedLedMaxCt=0; static unsigned char RedLedFlash2=0; static unsigned char LastRedLedFlash=0xff; static unsigned char LastRedLedSleep=0xff; static unsigned char BlueLedCt=0; static unsigned char BlueLedMaxCt=0; static unsigned char BlueLedFlash2=0; static unsigned char LastBlueLedFlash=0xff; static unsigned char LastBlueLedSleep=0xff; if(reset){ sucCt=0; RedLedCt=0; RedLedMaxCt=0; RedLedFlash2=0; LastRedLedFlash=0xff; LastRedLedSleep=0xff; BlueLedCt=0; BlueLedMaxCt=0; BlueLedFlash2=0; LastBlueLedFlash=0xff; LastBlueLedSleep=0xff; MODEM_LED1_LOW; MODEM_LED2_LOW; return; } //red led control if(sucRedLedFlash==0){ //³¤Ãð MODEM_LED1_LOW; }else if(sucRedLedSleep==0){//³¤ÁÁ MODEM_LED1_HIGH; }else{ if(LastRedLedFlash!=sucRedLedFlash || LastRedLedSleep!=sucRedLedSleep){ RedLedCt=0; BlueLedCt=0; LastRedLedFlash=sucRedLedFlash; LastRedLedSleep=sucRedLedSleep; RedLedFlash2=sucRedLedFlash*2; RedLedMaxCt=RedLedFlash2+LastRedLedSleep*2; } if(++RedLedCt>RedLedMaxCt)RedLedCt=0; //if(RedLedCtBlueLedMaxCt)BlueLedCt=0; //if(BlueLedCt255){ return; } sucRedLedFlash=flash; sucRedLedSleep=sleep; } void SetBlueLed(unsigned char flash,unsigned char sleep) { int t=(flash+sleep)*2; if(t>255){ return; } sucBlueLedFlash=flash; sucBlueLedSleep=sleep; } void SetLedStatus(LED_STATUS LedStatus) { switch(LedStatus){ case NotBright: //¾ù²»ÁÁ SetRedLed(0,0); SetBlueLed(0,0); break; case RedBright: //ºìµÆ³£ÁÁ SetRedLed(1,0); SetBlueLed(0,0); break; case RedFastFlash: //ºìµÆ¿ìÉÁ SetRedLed(1,1); SetBlueLed(0,0); break; case RedSlowFlash: //ºìµÆÂýÉÁ SetRedLed(1,10); SetBlueLed(0,0); break; case BlueBright: //À¶µÆ³£ÁÁ SetRedLed(0,0); SetBlueLed(1,0); break; case BlueFastFlash: //À¶µÆ¿ìÉÁ SetRedLed(0,0); SetBlueLed(1,1); break; case BlueSlowFlash: //À¶µÆÂýÉÁ SetRedLed(0,0); SetBlueLed(1,10); break; case RedBlueBright: //ºìÀ¶³£ÁÁ SetRedLed(1,0); SetBlueLed(1,0); break; case RedBlueFastFlash: //ºìÀ¶¿ìÉÁ SetRedLed(1,1); SetBlueLed(1,1); break; case RedBlueSlowFlash: //ºìÀ¶ÂýÉÁ SetRedLed(1,10); SetBlueLed(1,10); break; } } void SetLedIndicator(LED_INDICATOR LedInd) { switch(LedInd){ case IndModemErr: g_LedInd=IndModemErr; SetLedStatus(RedBright); break; case IndNoNet: g_LedInd=IndNoNet; SetLedStatus(BlueFastFlash); break; case IndStandby: g_LedInd=IndStandby; SetLedStatus(BlueSlowFlash); break; case IndRX: g_LedInd=IndRX; SetLedStatus(BlueBright); break; case IndTX: g_LedInd=IndTX; SetLedStatus(RedBright); break; } }