|
/******************************************************************************
|
* Copyright (C) 2014-2015 HangZhou SiZhu Co.,LTD.
|
*
|
*-----------------------------------------------------------------------------
|
* File: main.c
|
* Description: main test code used for test all hardware
|
* Author: Lishoujian (867693272@qq.com)
|
* Date: Jan 8, 2015
|
*****************************************************************************/
|
|
//eMBPoll()Öе÷ÓÃ״̬»ú½ÓÊÜÊý¾Ý´¦ÀíºóÇл»µ½·¢ËÍ״̬£¬ÔÚµ±Ç°ÏµÍ³¹¤×÷ģʽÏ»ᵼÖ³¬Ê±´íÎó£¬Òò´Ë²»Ê¹ÓÃ״̬»ú¡£
|
|
//MODBUS¸ÄΪDMA·½Ê½½ÓÊÕ£¬ÐÞ¸Ä4´¦¡£
|
//Ò»¡¢eMBEnable()ÄڵĶ¨Ê±Æ÷ºÍ½ÓÊÜÖжϿªÆôº¯ÊýpvMBFrameStartCur( )×¢ÊÍ¡£
|
//¶þ¡¢485Çý¶¯ÖжÏÅäÖøÄΪDMA¡£
|
//Èý¡¢eMBPoll()ÖÐʹÓÃxMBRTUReceiveCheck();
|
//ËÄ¡¢eMBRTUSend()ÄÚÊý¾Ý·¢ËÍÖжϿªÆôvMBPortSerialEnable( FALSE, TRUE )×¢ÊÍ¡£
|
|
/* ----------------------- Platform includes --------------------------------*/
|
#include "main.h"
|
#include "ad421.h"
|
|
#define DEBUG_V20
|
#define DEBUG_TEM_AND_PRE
|
#define DATA_UPDATA
|
#define DEBUG_KEY_AND_LED
|
#define DEBUG_MODBUS
|
|
#define OLED_SHOW
|
|
//
|
volatile u16 TempBuf[16] __attribute__((at(0x08007800))) = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff};
|
/******************************************
|
* func: main
|
* desc: main test code used for test all hardware
|
* input: none
|
* output: none
|
* return: none
|
*****************************************/
|
int main(void)
|
{
|
/*µØÖ·×ª»»*/
|
SCB->VTOR = FLASH_BASE | 0x8000; /* Vector Table Relocation in Internal FLASH. */
|
/*ÍâÉè³õʼ»¯*/
|
All_clock_Init();
|
Delay_init();
|
All_GPIO_Init(); //¶Ë¿Ú³õʼ»¯
|
All_SPI_Init();
|
/*test for ads1120*/
|
|
/*²ÎÊý³õʼ»¯*/
|
para_init();
|
/*´®¿Ú ÐèÒªÔÚ²ÎÊýºóÃæ½øÐгõʼ»¯*/
|
all_uart_init();
|
/*ϵͳÍâÉè³õʼ»¯*/
|
system_init_detection();
|
|
// // while(1);
|
// data_save_test();
|
while(1)
|
{
|
//IWDG_Init();
|
while(SYSTEM_ONLY_WORK_MODE == v20_system_para_g.system_mode)
|
{
|
|
//³õʼ»¯¶¨Ê±Æ÷£¬¿ªÊ¼ÖÜÆÚÐÔ¹¤×÷
|
//All_clock_Init();
|
work_process_para_init();
|
|
while(SYSTEM_ONLY_WORK_MODE == v20_system_para_g.system_mode )
|
{
|
|
// µÈ´ýʱ¼äÖÜÆÚµ½
|
|
if( (system_time_ev_g.time_period_flag == TRUE) && (v20_system_para_g.system_extern_power_connect_flag == ACTIVE) )
|
{
|
// All_GPIO_Init();
|
// Test_GPIO_High;
|
//****************²âÁ¿Î¶ÈѹÁ¦ + *********************//
|
Pulse_Output();
|
lower_pluse_out();
|
current_output();
|
|
measure_process_new_state1();
|
// #ifdef DEBUG_TEM_AND_PRE
|
//
|
// #endif
|
|
// #ifdef OLED_SHOW
|
//
|
// #endif
|
measure_process_new_state2(1);
|
pressure_and_temperature_process(3,1);
|
|
|
//get_pushdown_flag();
|
//ת»»Êý¾Ý
|
//µÃµ½Ë²Ê±½á¹û,ת»»½á¹û
|
|
#ifdef DATA_UPDATA
|
/*Ìúµç´æ´¢Êý¾Ý*/
|
data_trans_reg();
|
|
#endif
|
sys_menu();
|
// flash_save_process();
|
|
#ifdef DEBUG_MODBUS
|
//¼ì²é´®¿ÚÊý¾Ý
|
rx_pc_485_task();
|
bt_process(1);
|
|
#endif
|
|
|
#if 1
|
|
gprs_handle();
|
#endif
|
|
|
//create_log_process();
|
/*ϵͳ
|
¼ì²é*/
|
system_working_detection();
|
// while(1);
|
system_time_ev_g.time_period_flag = FALSE;
|
system_jump();
|
// GPIO_IPD_Init();
|
/*¿´ÃŹ·Î¹¹·*/
|
IWDG_Feed();
|
// PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
|
|
|
}
|
|
/*²»½ÓÍâµçµÄÇé¿öÏÂÐÝÃß*/
|
|
|
}
|
}
|
|
while(SYSTEM_LOWPOWER_WORK_MODE == v20_system_para_g.system_mode)
|
{
|
//³õʼ»¯¶¨Ê±Æ÷£¬¿ªÊ¼ÖÜÆÚÐÔ¹¤×÷
|
low_power_process_para_init();
|
while(SYSTEM_LOWPOWER_WORK_MODE == v20_system_para_g.system_mode )
|
{
|
|
if( (system_time_ev_g.time_period_flag == TRUE) && (v20_system_para_g.system_extern_power_connect_flag == NOACTIVE) )
|
{
|
|
|
All_GPIO_Lowpower_Init(); //¶Ë¿Ú³õʼ»¯
|
lower_pluse_out();
|
current_output();
|
|
measure_process_new_low_power_state1();
|
|
measure_process_new_low_power_state2(1);
|
|
|
/*´æ´¢µÄÊÇÉÏÒ»ÃëµÄÊý¾Ý£¬Ö»ÊÇÕë¶ÔµÍ¹¦ºÄģʽÏÂ*/
|
|
|
/*GPRSÊý¾Ý´¦Àíº¯Êý*/
|
#if 1
|
gprs_handle();
|
#endif
|
|
/*µÈ´ýʱ£¬´¦Àí±ðµÄÊÂÎñ*/
|
#ifdef DEBUG_TEM_AND_PRE
|
|
pressure_and_temperature_process(60,0);
|
#endif
|
|
data_trans_reg();
|
#ifdef DEBUG_MODBUS
|
//¼ì²é´®¿ÚÊý¾ÝºÍÀ¶ÑÀͨÐÅÊý¾Ý
|
/*ÈÕÖ¾´æ´¢*/
|
create_log_process();
|
|
bt_process(0);
|
#endif
|
/*flash ´æ´¢Êý¾Ý*/
|
// flash_save_process();
|
sys_menu();
|
//ת»»Êý¾Ý
|
//µÃµ½Ë²Ê±½á¹û,ת»»½á¹û
|
|
system_working_detection();
|
|
system_time_ev_g.time_period_flag = FALSE;
|
|
/*¿´ÃŹ·Î¹¹·*/
|
IWDG_Feed();
|
if(0 == system_connect())
|
{
|
GPIO_IPD_Init();
|
//ex_rtc_nv_config_disable();
|
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
|
|
All_clock_Init();
|
|
}
|
|
}
|
}
|
|
}
|
|
|
/*DEBUG MODE*/
|
while(SYSTEM_DEBUG_MODE == v20_system_para_g.system_mode)
|
{
|
system_debug_para_init();
|
//system_in_debug_fpga_init();
|
while(SYSTEM_DEBUG_MODE == v20_system_para_g.system_mode )
|
{
|
debug_pc_485_task();
|
delay_ms(10);
|
v20_system_para_g.system_mode = debug_task();
|
/*¿´ÃŹ·Î¹¹·*/
|
IWDG_Feed();
|
}
|
system_debug_para_out();
|
|
}
|
|
/*UPDATA MODE*/
|
while(SYSTEM_UPDATA_MODE == v20_system_para_g.system_mode)
|
{
|
|
while(SYSTEM_UPDATA_MODE == v20_system_para_g.system_mode )
|
{
|
|
enter_void();
|
}
|
|
|
|
}
|
}
|
}
|