whycyhl
2022-05-05 683c912f9ac1935a7b109fb402bb276dba450f6b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/************************** Copyright (c) **********************************
**                 FUZHOU FUGUANG ELECTRONICS Co.,LTD.
**                        ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
**                       http://www.fuguang.com
**
**-------------- File Info -------------------------------------------------
** File name:            SystemInit.c
** Last modified Date:  2008-11-16
** Last Version:        1.0
** Descriptions:        Initialize all the device's driver and system state
**
**--------------------------------------------------------------------------
** Created by:            mxpopstar
** Created date:        2008-11-16
** Version:                1.0
** Descriptions:        The original version
**
**--------------------------------------------------------------------------
** Modified by:            mxpopstar
** Modified date:        2008-11-20
** Version:
** Descriptions:        Initialize all the device's driver and system state
**
***************************************************************************/
//
#include "SystemInit.h"
#include "NRF905_Driver.h" 
#include "SST25VF_Driver.h"
#include "AD7843_Driver.h"
#include "DS1302_Driver.h"
#include "Buzzer_Driver.h"
#include "M64USART_Driver.h"
#include "M64PWM_Driver.h"
#include "MainMenu.h"
#include "AboutPage.h"
#include "FileManage.h"
#include "WorkingPage.h"
#include <avr/wdt.h>
#include "USBModule_Driver.h"
#include "SYSSetPage.h"
#include "KeyBoard_Driver.h"
#include "TFT_Driver.h"
#include "74HC595_Driver.h"
#include "M64ADC_Driver.h"
#include "M64Timer1.h"
#include "SingleVol.h"
 
 
extern volatile FBO_Data GB_FBO_Data;
extern volatile SYS_State GB_SYS_State;
extern unsigned int GB_TestingParm[13];
 
void InitSystem(void)
{
    //------------ ³õʼ»¯¿´ÃŹ·(2s) -------------
    wdt_enable(WDTO_2S);
    wdt_reset();         //ι¹·
    //-------------------------------------------
    _delay_ms(100);
    
    //------------ ³õʼ»¯TFTLCDÇý¶¯ ------------
    InitIO_TFT();
    Config_TFT();
    BackColorCH();
    
    //------- ÑÓʱ100ms,ʹµçԴϵͳÎȶ¨ ---------
    _delay_ms(100);    
        
    //------------ ³õʼ»¯·äÃùÆ÷Çý¶¯ ------------
    InitIO_Buzzer();
    InitAlarmBeep();
    
    //------------ ³õʼ»¯¼üÅÌÇý¶¯ --------------
    InitIO_KeyBoard();
    
    //------------ ³õʼ»¯USARTÇý¶¯ -------------
    InitIO_M64USART0();
    Config_M64USART0(9600);
    
    //------------ ³õʼ»¯NRF905Ä£¿éÇý¶¯ --------
    InitIO_NRF905();    
    Write_Config905();
    
    //------------ ³õʼ»¯´¥ÃþÆÁÇý¶¯ ------------
    InitIo_AD7843();
    
    //------------ ³õʼ»¯flash´æ´¢Æ÷Çý¶¯ -------
    InitIO_SST25VF();
    Config_SST25VF();
    FileManageInit();
        
    //------------ ³õʼ»¯ÊµÊ±Ê±ÖÓÇý¶¯ ----------    
    InitIO_DS1302();
    Config_DS1302();
    
    //------------ ³õʼ»¯74HC595Çý¶¯ -----------
    InitIo_HC595();
    
    //------------ ³õʼ»¯PWMÇý¶¯ ---------------
    InitIO_M64PWM();
    Config_M64PWM();
    
    //------------ ³õʼ»¯ADCÇý¶¯ ---------------
    InitIO_M64ADC();
    Config_M64ADC();
    
    //------------ ³õʼ»¯PC232½Ó¿Ú -------------
    InitIO_M64USART0();
    Config_M64USART0(192);
    
    //------------ ³õʼ»¯UÅ̽ӿڠ----------------
    InitIO_M64USART1();
    Config_M64USART1(1152);
    
    //************ ³õʼ»¯¶¨Ê±¼ÆÊýÆ÷3 ***********     
    TIFR |= 0x04;
    TCCR1B = TCCR1A = 0;//¼ÆÊýÆ÷3¹¤×÷ÔÚÆÕͨµÄ¼ÆÊýģʽ
    TCNT1 = 0x8F7F;     //-----¼ÆÊý³õÖµ       
    //*******************************************     
        
    GetTestingParm(0);    
    GB_TestingParm[0] = 0;//ÉèÖÃΪÔÚÏ߷ŵç
    GB_TestingParm[1] = 0;//Í£Ö¹·Åµç
    
    GB_SYS_State.CurrentPage = DSPMainMenu;
    GB_SYS_State.GetInput = GetMenuSelected;
    GB_SYS_State.DealTimer1Up = M64Timer1UpNull;
    GB_SYS_State.TestType = TestTypeDischarge;
    GB_SYS_State.WorkState = Stopped;
    GB_SYS_State.SaveDateEN    = 0;
    
    GB_SYS_State.OnlineLowLimit    = 0;
    GB_SYS_State.OnlineVolLow = 0;
    GB_SYS_State.TempHighCount = 0;
    GetButtonIsBeep(1);
    GetExtClamprange(1);
}
// 
 
/********************** END OF FILE (SystemInit.c)*************************/