기능구현중

main
Imbis 6 months ago
parent f2cc324ece
commit 83df3d9269

@ -0,0 +1,5 @@
{
"files.associations": {
"driver_ds3231.h": "c"
}
}

File diff suppressed because one or more lines are too long

@ -28,7 +28,7 @@
<TargetOption> <TargetOption>
<CLKADS>12000000</CLKADS> <CLKADS>12000000</CLKADS>
<OPTTT> <OPTTT>
<gFlags>0</gFlags> <gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd> <BeepAtEnd>1</BeepAtEnd>
<RunSim>0</RunSim> <RunSim>0</RunSim>
<RunTarget>1</RunTarget> <RunTarget>1</RunTarget>
@ -103,7 +103,7 @@
<bEvRecOn>1</bEvRecOn> <bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf> <bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf> <bTchkAxf>0</bTchkAxf>
<nTsel>0</nTsel> <nTsel>3</nTsel>
<sDll></sDll> <sDll></sDll>
<sDllPa></sDllPa> <sDllPa></sDllPa>
<sDlgDll></sDlgDll> <sDlgDll></sDlgDll>
@ -114,28 +114,82 @@
<tDlgDll></tDlgDll> <tDlgDll></tDlgDll>
<tDlgPa></tDlgPa> <tDlgPa></tDlgPa>
<tIfile></tIfile> <tIfile></tIfile>
<pMon>BIN\UL2CM3.DLL</pMon> <pMon>BIN\CMSIS_AGDI.dll</pMon>
</DebugOpt> </DebugOpt>
<TargetDriverDllRegistry> <TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FD20000000 -FC1000 -FN2 -FF0A31G12x_series_FLASH.FLM -FS00 -FL010000 -FP0($$Device:A31G123$A31G12x\Flashloader\A31G12x_series_FLASH.FLM) -FF1A31G12x_series_CFG.FLM -FS11FFFF200 -FL1600 -FP1($$Device:A31G123$A31G12x\Flashloader\A31G12x_series_CFG.FLM)</Name>
</SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>UL2CM3</Key> <Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0A31G12x_series_FLASH -FS00 -FL010000 -FF1A31G12x_series_CFG -FS11FFFF200 -FL1600 -FP0($$Device:A31G123$A31G12x\Flashloader\A31G12x_series_FLASH.FLM) -FP1($$Device:A31G123$A31G12x\Flashloader\A31G12x_series_CFG.FLM))</Name> <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0A31G12x_series_FLASH -FS00 -FL010000 -FF1A31G12x_series_CFG -FS11FFFF200 -FL1600 -FP0($$Device:A31G123$A31G12x\Flashloader\A31G12x_series_FLASH.FLM) -FP1($$Device:A31G123$A31G12x\Flashloader\A31G12x_series_CFG.FLM))</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint/> <Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>132</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>3244</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Application\gpio_switch.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\S_DustSensorView\Application/gpio_switch.c\132</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>SW_Timer_Info</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>Gpio_Led_Ctrl_Info</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint> <Tracepoint>
<THDelay>0</THDelay> <THDelay>0</THDelay>
</Tracepoint> </Tracepoint>
<DebugFlag> <DebugFlag>
<trace>0</trace> <trace>0</trace>
<periodic>0</periodic> <periodic>0</periodic>
<aLwin>0</aLwin> <aLwin>1</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>0</aSer1> <aSer1>0</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
<aPa>0</aPa> <aPa>0</aPa>
<viewmode>0</viewmode> <viewmode>1</viewmode>
<vrSel>0</vrSel> <vrSel>0</vrSel>
<aSym>0</aSym> <aSym>0</aSym>
<aTbox>0</aTbox> <aTbox>0</aTbox>
@ -523,6 +577,30 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>30</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Application\spi13.c</PathWithFileName>
<FilenameWithoutPath>spi13.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>31</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Application\usart11_rs485.c</PathWithFileName>
<FilenameWithoutPath>usart11_rs485.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@ -533,7 +611,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>30</FileNumber> <FileNumber>32</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -545,7 +623,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>31</FileNumber> <FileNumber>33</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -557,7 +635,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>32</FileNumber> <FileNumber>34</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -569,7 +647,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>33</FileNumber> <FileNumber>35</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -581,7 +659,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>34</FileNumber> <FileNumber>36</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -593,7 +671,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>35</FileNumber> <FileNumber>37</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -605,7 +683,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>36</FileNumber> <FileNumber>38</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -617,7 +695,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>37</FileNumber> <FileNumber>39</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -629,7 +707,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>38</FileNumber> <FileNumber>40</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -641,7 +719,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>39</FileNumber> <FileNumber>41</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -653,7 +731,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>40</FileNumber> <FileNumber>42</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -665,7 +743,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>41</FileNumber> <FileNumber>43</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -677,7 +755,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>42</FileNumber> <FileNumber>44</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -689,7 +767,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>43</FileNumber> <FileNumber>45</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -701,7 +779,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>44</FileNumber> <FileNumber>46</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -713,7 +791,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>45</FileNumber> <FileNumber>47</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -725,7 +803,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>46</FileNumber> <FileNumber>48</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -737,7 +815,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>47</FileNumber> <FileNumber>49</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -757,7 +835,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>48</FileNumber> <FileNumber>50</FileNumber>
<FileType>2</FileType> <FileType>2</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -777,7 +855,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>49</FileNumber> <FileNumber>51</FileNumber>
<FileType>5</FileType> <FileType>5</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -789,7 +867,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>50</FileNumber> <FileNumber>52</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -801,7 +879,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>51</FileNumber> <FileNumber>53</FileNumber>
<FileType>5</FileType> <FileType>5</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -821,7 +899,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>52</FileNumber> <FileNumber>54</FileNumber>
<FileType>2</FileType> <FileType>2</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -841,7 +919,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>53</FileNumber> <FileNumber>55</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -853,7 +931,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>54</FileNumber> <FileNumber>56</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -865,7 +943,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>55</FileNumber> <FileNumber>57</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -877,7 +955,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>56</FileNumber> <FileNumber>58</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -889,7 +967,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>57</FileNumber> <FileNumber>59</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -901,7 +979,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>58</FileNumber> <FileNumber>60</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>

@ -528,6 +528,16 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>.\Application\uart_packet.c</FilePath> <FilePath>.\Application\uart_packet.c</FilePath>
</File> </File>
<File>
<FileName>spi13.c</FileName>
<FileType>1</FileType>
<FilePath>.\Application\spi13.c</FilePath>
</File>
<File>
<FileName>usart11_rs485.c</FileName>
<FileType>1</FileType>
<FilePath>.\Application\usart11_rs485.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>

@ -9,11 +9,58 @@
#include "rtc_process.h" #include "rtc_process.h"
#include "save_file.h" #include "save_file.h"
#define KEY_POWER KEY_PUSH_SW1
#define KEY_MODE_SET KEY_PUSH_SW2
#define KEY_UP KEY_PUSH_SW3
#define KEY_DOWN KEY_PUSH_SW4
typedef enum _control_step
{
CONTROL_STEP_INIT,
CONTROL_STEP_INIT_BUZZER_ON,
CONTROL_STEP_INIT_ALL_LED_ON,
CONTROL_STEP_INIT_ALL_LED_ON_WAIT,
CONTROL_STEP_INIT_VERSION_ON,
CONTROL_STEP_INIT_VERSION_ON_WAIT,
CONTROL_STEP_INIT_POWER_ON_KEY_SET,
CONTROL_STEP_INIT_COMPLETE,
CONTROL_STEP_ACTION_IDLE,
CONTROL_STEP_ACTION_RUN_NOW_SENSOR_DATA,
CONTROL_STEP_ACTION_RUN_MAX_SENSOR_DATA,
CONTROL_STEP_ACTION_RUN_MIN_SENSOR_DATA,
CONTROL_STEP_ACTION_RUN_SET_MAX_SENSOR_DATA,
CONTROL_STEP_ACTION_RUN_SET_MIN_SENSOR_DATA,
CONTROL_STEP_ACTION_RUN_COMPLETE,
}CONTROL_STEP;
typedef struct _control_info typedef struct _control_info
{ {
bool isActionRun; bool isInitView;
uint32_t Co2_MaxValue; bool isActionRun;
uint32_t Co2_MinValue; CONTROL_STEP Step;
uint32_t StartTickCount;
uint32_t Co2_Now;
uint32_t Co2_MaxValue;
uint32_t Co2_MinValue;
}CONTROL_INFO; }CONTROL_INFO;
@ -25,12 +72,36 @@ static CONTROL_INFO Control_Info;
static void Action_Process(void); static void Action_Process(void);
static void Action_PowerOn_Init_Process(void);
static void Action_PowerOn_Process(void);
static void Action_Power_On_Key_Set(void);
static void Action_Power_On_Key_Push_Callback(void);
static void Action_Power_Off_Key_Set(void);
static void Action_Power_Off_Key_Push_Callback(void);
static void Action_Mode_Key_Push(void);
static void Action_Set_Key_Push(void);
static void Action_Up_Key_Push(void);
static void Action_Down_Key_Push(void);
#if 0
static void Action_PowerKey_Push(void); static void Action_PowerKey_Push(void);
static void Action_PowerKey_LongPush(void); static void Action_PowerKey_LongPush(void);
static void Action_Sensor_Read_Process(void); static void Action_Sensor_Read_Process(void);
#endif
void Action_Initialization(void) void Action_Initialization(void)
{ {
Control_Info.isInitView = false;
Control_Info.Step = CONTROL_STEP_INIT;
Gpio_Swtich_Set_Callback(KEY_MODE_SET, Action_Mode_Key_Push, Action_Set_Key_Push, NULL);
Gpio_Swtich_Set_Callback(KEY_UP, Action_Up_Key_Push, NULL, NULL);
Gpio_Swtich_Set_Callback(KEY_DOWN, Action_Down_Key_Push, NULL, NULL);
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, Action_Process); SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, Action_Process);
} }
@ -38,13 +109,187 @@ void Action_Initialization(void)
static void Action_Process(void) static void Action_Process(void)
{ {
if(Control_Info.isInitView == false)
{
Action_PowerOn_Init_Process();
}
else
{
if(Control_Info.isActionRun == true)
Action_PowerOn_Process();
}
}
static void Action_PowerOn_Init_Process(void)
{
uint8_t i;
switch(Control_Info.Step)
{
case CONTROL_STEP_INIT:
Control_Info.Step = CONTROL_STEP_INIT_BUZZER_ON;
break;
case CONTROL_STEP_INIT_BUZZER_ON:
Buzzer_On(500);
Control_Info.Step = CONTROL_STEP_INIT_ALL_LED_ON;
break;
case CONTROL_STEP_INIT_ALL_LED_ON:
Segment_All_Set_Data(0xFF);
for(i = 0 ; i < GPIO_LED_MAX ; i++)
{
Gpio_Led_OutputSet(i, GPIO_LED_MODE_ON, 0, 0);
}
Control_Info.StartTickCount = millis();
Control_Info.Step = CONTROL_STEP_INIT_ALL_LED_ON_WAIT;
break;
case CONTROL_STEP_INIT_ALL_LED_ON_WAIT:
if((millis() - Control_Info.StartTickCount) >= ACTION_INIT_LED_ON_WAIT_TIME)
{
Control_Info.Step = CONTROL_STEP_INIT_VERSION_ON;
}
break;
case CONTROL_STEP_INIT_VERSION_ON:
Segment_Show_Version();
Control_Info.StartTickCount = millis();
Control_Info.Step = CONTROL_STEP_INIT_VERSION_ON_WAIT;
break;
case CONTROL_STEP_INIT_VERSION_ON_WAIT:
if((millis() - Control_Info.StartTickCount) >= ACTION_INIT_LED_ON_WAIT_TIME)
{
Segment_All_Set_Data(0x00);
for(i = 0 ; i < GPIO_LED_MAX ; i++)
{
Gpio_Led_OutputSet(i, GPIO_LED_MODE_OFF, 0, 0);
}
Control_Info.Step = CONTROL_STEP_INIT_POWER_ON_KEY_SET;
}
break;
case CONTROL_STEP_INIT_POWER_ON_KEY_SET:
Gpio_Led_OutputSet(GPIO_LED_LE1, GPIO_LED_MODE_TOGGLE, ACTION_LE1_IDLE_ON_TIME, ACTION_LE1_IDLE_OFF_TIME);
Action_Power_On_Key_Set();
Control_Info.Step = CONTROL_STEP_INIT_COMPLETE;
break;
case CONTROL_STEP_INIT_COMPLETE:
Control_Info.isInitView = true;
break;
}
} }
static void Action_PowerOn_Process(void)
{
switch (Control_Info.Step)
{
case CONTROL_STEP_INIT:
Action_Power_Off_Key_Set();
Gpio_Led_OutputSet(GPIO_LED_LE1, GPIO_LED_MODE_TOGGLE, ACTION_LE1_RUN_ON_TIME, ACTION_LE1_RUN_OFF_TIME);
Gpio_Led_OutputSet(GPIO_LED_D1, GPIO_LED_MODE_OFF, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D2, GPIO_LED_MODE_ON, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D3, GPIO_LED_MODE_OFF, 0, 0);
if(EEPROM_Read_SettingValue(&Control_Info.Co2_MaxValue, &Control_Info.Co2_MinValue) == false)
{
Control_Info.Co2_MaxValue = DEFAULT_SENSOR_MAX_DATA;
Control_Info.Co2_MinValue = DEFAULT_SENSOR_MIN_DATA;
}
Control_Info.Step = CONTROL_STEP_ACTION_RUN_NOW_SENSOR_DATA;
break;
case CONTROL_STEP_ACTION_RUN_NOW_SENSOR_DATA:
Segment_Show_Time();
Segment_Show_SensorData(Control_Info.Co2_Now);
break;
case CONTROL_STEP_ACTION_RUN_MAX_SENSOR_DATA:
Segment_Show_Time();
Segment_Show_SensorData(Control_Info.Co2_MaxValue);
break;
case CONTROL_STEP_ACTION_RUN_MIN_SENSOR_DATA:
Segment_Show_Time();
Segment_Show_SensorData(Control_Info.Co2_MinValue);
break;
case CONTROL_STEP_ACTION_RUN_SET_MAX_SENSOR_DATA:
break;
case CONTROL_STEP_ACTION_RUN_SET_MIN_SENSOR_DATA:
break;
case CONTROL_STEP_ACTION_RUN_COMPLETE:
Gpio_Led_OutputSet(GPIO_LED_LE1, GPIO_LED_MODE_TOGGLE, ACTION_LE1_IDLE_ON_TIME, ACTION_LE1_IDLE_OFF_TIME);
Action_Power_On_Key_Set();
Segment_All_Set_Data(0x00);
EEPROM_Write_SettingValue(Control_Info.Co2_MaxValue, Control_Info.Co2_MinValue);
Control_Info.Step = CONTROL_STEP_INIT;
Control_Info.isActionRun = false;
break;
}
}
static void Action_Power_On_Key_Set(void)
{
Gpio_Swtich_Set_PushCount(KEY_POWER, DEFAULT_KEY_PUSH_COUNT, KEY_POWER_ON_CHECK_PUSH_COUNT);
Gpio_Swtich_Set_Callback(KEY_POWER, NULL, Action_Power_On_Key_Push_Callback, NULL);
}
static void Action_Power_Off_Key_Set(void)
{
Gpio_Swtich_Set_PushCount(KEY_POWER, DEFAULT_KEY_PUSH_COUNT, KEY_POWER_OFF_CHECK_PUSH_COUNT);
Gpio_Swtich_Set_Callback(KEY_POWER, NULL, Action_Power_Off_Key_Push_Callback, NULL);
}
static void Action_Power_On_Key_Push_Callback(void)
{
Buzzer_On(DEFAULT_KEY_PUSH_BUZZER_TIME_COUNT);
Control_Info.isActionRun = true;
Control_Info.Step = CONTROL_STEP_INIT;
dbg_printf("power on\r\n");
}
static void Action_Power_Off_Key_Push_Callback(void)
{
Buzzer_On(DEFAULT_KEY_PUSH_BUZZER_TIME_COUNT);
Control_Info.Step = CONTROL_STEP_ACTION_RUN_COMPLETE;
dbg_printf("power off\r\n");
}
static void Action_Mode_Key_Push(void)
{
switch(Control_Info.Step)
{
case CONTROL_STEP_ACTION_RUN_NOW_SENSOR_DATA:
Buzzer_On(DEFAULT_KEY_PUSH_BUZZER_TIME_COUNT);
Gpio_Led_OutputSet(GPIO_LED_D1, GPIO_LED_MODE_ON, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D2, GPIO_LED_MODE_OFF, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D3, GPIO_LED_MODE_OFF, 0, 0);
Control_Info.Step = CONTROL_STEP_ACTION_RUN_MAX_SENSOR_DATA;
break;
case CONTROL_STEP_ACTION_RUN_MAX_SENSOR_DATA:
Buzzer_On(DEFAULT_KEY_PUSH_BUZZER_TIME_COUNT);
Gpio_Led_OutputSet(GPIO_LED_D1, GPIO_LED_MODE_OFF, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D2, GPIO_LED_MODE_OFF, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D3, GPIO_LED_MODE_ON, 0, 0);
Control_Info.Step = CONTROL_STEP_ACTION_RUN_MIN_SENSOR_DATA;
break;
case CONTROL_STEP_ACTION_RUN_MIN_SENSOR_DATA:
Buzzer_On(DEFAULT_KEY_PUSH_BUZZER_TIME_COUNT);
Gpio_Led_OutputSet(GPIO_LED_D1, GPIO_LED_MODE_OFF, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D2, GPIO_LED_MODE_ON, 0, 0);
Gpio_Led_OutputSet(GPIO_LED_D3, GPIO_LED_MODE_OFF, 0, 0);
Control_Info.Step = CONTROL_STEP_ACTION_RUN_NOW_SENSOR_DATA;
break;
}
}
static void Action_Set_Key_Push(void)
{
}
static void Action_Up_Key_Push(void)
{
}
static void Action_Down_Key_Push(void)
{
}

@ -1,12 +1,6 @@
#include "dbg_printf.h" #include "dbg_printf.h"
#include "uart1.h" #include "uart1.h"
/*-------------------------------------------------------------------------*//** /*-------------------------------------------------------------------------*//**
* @brief Puts a character to file * @brief Puts a character to file
* @param[in] ch * @param[in] ch

@ -57,19 +57,51 @@
#define VERSION_MAJOR 0 // max 9 #define VERSION_MAJOR 1 // max 9
#define VERSION_MINOR 0 // max 9 #define VERSION_MINOR 0 // max 9
#define VERSION_PATCH 1 // max 99
#define SEGMENT_CHECK_WAIT_TIME 300 //
#define SEGMENT_VERSION_WAIT_TIME 1000 #define ACTION_INIT_LED_ON_WAIT_TIME 2000
#define ACTION_LE1_IDLE_ON_TIME 250
#define ACTION_LE1_IDLE_OFF_TIME 750
#define ACTION_LE1_RUN_ON_TIME 500
#define ACTION_LE1_RUN_OFF_TIME 1500
#define DEFAULT_KEY_PUSH_COUNT 50 #define DEFAULT_KEY_PUSH_COUNT 50
#define DEFAULT_LONGKEY_PUSH_COUNT 1000 #define DEFAULT_LONGKEY_PUSH_COUNT 1000
#define KEY_POWER_ON_CHECK_PUSH_COUNT 1000
#define KEY_POWER_OFF_CHECK_PUSH_COUNT 2000
#define DEFAULT_SENSOR_MAX_DATA 3000
#define DEFAULT_SENSOR_MIN_DATA 0
#define DEFAULT_KEY_PUSH_BUZZER_TIME_COUNT 80
#if 0
#define SEGMENT_CHECK_WAIT_TIME 300 //
#define SEGMENT_VERSION_WAIT_TIME 1000
#define DUST_SENSOR_POWER_ON_WAIT_TIME_COUNT 100 #define DUST_SENSOR_POWER_ON_WAIT_TIME_COUNT 100
#define DUST_SENSOR_POWER_OFF_WAIT_TIME_COUNT 100 #define DUST_SENSOR_POWER_OFF_WAIT_TIME_COUNT 100
@ -89,7 +121,7 @@
#define SEGMENT_TOGGLE_TIME 250 #define SEGMENT_TOGGLE_TIME 250
#endif
#endif #endif

@ -9,8 +9,9 @@ typedef union _eeprom_info
struct struct
{ {
uint8_t isSave; uint8_t isSave;
uint8_t Mode; uint16_t SensorMAX;
uint8_t Reserved[SECTOR_SIZE_BYTE - 3]; uint16_t SensorMIN;
uint8_t Reserved[SECTOR_SIZE_BYTE - 6];
uint8_t CheckSum; uint8_t CheckSum;
}eeprom_data; }eeprom_data;
uint8_t eeprom_buffer[SECTOR_SIZE_BYTE]; uint8_t eeprom_buffer[SECTOR_SIZE_BYTE];
@ -59,7 +60,7 @@ void FlashMEM_Clock_Initialization(void)
bool EEPROM_Read_Mode(uint8_t* pMode) bool EEPROM_Read_SettingValue(uint16_t* pGetMax, uint16_t* pGetMin)
{ {
uint8_t i; uint8_t i;
uint16_t checksum_init = 0x5AA5; uint16_t checksum_init = 0x5AA5;
@ -93,14 +94,15 @@ bool EEPROM_Read_Mode(uint8_t* pMode)
if((checksum_result & 0xFF) == eeprom_info.eeprom_data.CheckSum) if((checksum_result & 0xFF) == eeprom_info.eeprom_data.CheckSum)
{ {
*pMode = eeprom_info.eeprom_data.Mode; *pGetMax = eeprom_info.eeprom_data.SensorMAX;
*pGetMin = eeprom_info.eeprom_data.SensorMIN;
return true; return true;
} }
return false; return false;
} }
bool EEPROM_Write_Mode(uint8_t Mode) bool EEPROM_Write_SettingValue(uint16_t SetMax, uint16_t SetMin)
{ {
uint8_t i; uint8_t i;
uint16_t checksum_init = 0x5AA5; uint16_t checksum_init = 0x5AA5;
@ -108,13 +110,14 @@ bool EEPROM_Write_Mode(uint8_t Mode)
if(eeprom_info.eeprom_data.isSave == true) if(eeprom_info.eeprom_data.isSave == true)
{ {
if(eeprom_info.eeprom_data.Mode == Mode) if(eeprom_info.eeprom_data.SensorMAX == SetMax && eeprom_info.eeprom_data.SensorMIN == SetMin)
return true; return true;
} }
memset(&eeprom_info.eeprom_buffer[0], 0, SECTOR_SIZE_BYTE); memset(&eeprom_info.eeprom_buffer[0], 0, SECTOR_SIZE_BYTE);
eeprom_info.eeprom_data.isSave = true; eeprom_info.eeprom_data.isSave = true;
eeprom_info.eeprom_data.Mode = Mode; eeprom_info.eeprom_data.SensorMAX = SetMax;
eeprom_info.eeprom_data.SensorMIN = SetMin;
// CRC Block Calculation // CRC Block Calculation
CRC->INIT = checksum_init; CRC->INIT = checksum_init;
@ -145,62 +148,3 @@ bool EEPROM_Write_Mode(uint8_t Mode)
return true; return true;
} }
#if 0
void EEPROM_Read_Setting_Data(void)
{
#if 0
__disable_irq();
memcpy(&Save_control_Info, (uint32_t *)CONFIG_ADDRESS, SECTOR_SIZE_BYTE);
__enable_irq();
if(Save_control_Info.SaveFlag != EEPROM_SAVE_CHECK_FLAG_DATA)
{
Save_control_Info.SaveFlag = EEPROM_SAVE_CHECK_FLAG_DATA; // 1
Save_control_Info.SaveActionMode = ACTION_MODE_ACTION_AUTO_1; // 2
Save_control_Info.isPowerOnReservation = FALSE; // 3
Save_control_Info.isPowerOnSaturDay = FALSE; // 4
Save_control_Info.PowerOn_Hour = 0; // 5
Save_control_Info.PowerOn_Min = 0; // 6
Save_control_Info.isPowerOffReservation = FALSE; // 7
Save_control_Info.PowerOff_Hour = 0; // 8
Save_control_Info.PowerOff_Min = 0; // 9
Save_control_Info.FanActionTime_1 = 0; // 10
Save_control_Info.FanActionTime_2 = 0; // 11
}
#endif
}
void EEPROM_Write_Seting_Data(void)
{
#if 0
if(Control_Info.isEepromSave == TRUE)
{
Control_Info.isEepromSave = FALSE;
__disable_irq();
FlashMem_Do_PageEr(CONFIG_ADDRESS);
FlashMem_Do_PageWt(CONFIG_ADDRESS, (uint32_t *)&Save_control_Info);
__enable_irq();
}
#endif
}
#endif

@ -10,8 +10,10 @@
void FlashMEM_Clock_Initialization(void); void FlashMEM_Clock_Initialization(void);
bool EEPROM_Read_Mode(uint8_t* pMode);
bool EEPROM_Write_Mode(uint8_t Mode);
bool EEPROM_Read_SettingValue(uint16_t* pGetMax, uint16_t* pGetMin);
bool EEPROM_Write_SettingValue(uint16_t SetMax, uint16_t SetMin);
#endif #endif

@ -59,8 +59,8 @@
#define I2C2_SDA_PORT PC #define I2C2_SDA_PORT PC
#define I2C2_SCL_PORT PC #define I2C2_SCL_PORT PC
#define I2C2_SDA_PIN 5 #define I2C2_SDA_PIN 6
#define I2C2_SCL_PIN 6 #define I2C2_SCL_PIN 5
#define I2C2_DELAY 30 #define I2C2_DELAY 30

@ -2,9 +2,139 @@
#include "sw_timer.h" #include "sw_timer.h"
#define GPIO_LED_LE1_PORT (Pn_Type*)PF
#define GPIO_LED_LE1_PIN_NUM 4
#define GPIO_LED_D1_PORT (Pn_Type*)PE
#define GPIO_LED_D1_PIN_NUM 4
#define GPIO_LED_D2_PORT (Pn_Type*)PE
#define GPIO_LED_D2_PIN_NUM 3
#define GPIO_LED_D3_PORT (Pn_Type*)PE
#define GPIO_LED_D3_PIN_NUM 2
#define GPIO_LED_D4_PORT (Pn_Type*)PE
#define GPIO_LED_D4_PIN_NUM 1
static void State_Led_Output_Process(void); static void State_Led_Output_Process(void);
static void State_Led_Off(GPIO_LED_LIST gpio_led_index);
static void State_Led_On(GPIO_LED_LIST gpio_led_index);
typedef void (*GPIO_LED_ON_OFF_FUNC)(GPIO_LED_LIST gpio_led_index);
typedef struct
{
Pn_Type* Port;
uint8_t Pin;
GPIO_LED_MODE Mode;
bool isLedOn;
uint32_t nCheckTime;
uint32_t nOnTime;
uint32_t nOffTime;
GPIO_LED_ON_OFF_FUNC LedOnFunction;
GPIO_LED_ON_OFF_FUNC LedOffunction;
}GPIO_STATE_LED_INFO;
static GPIO_STATE_LED_INFO Gpio_Led_Ctrl_Info[GPIO_LED_MAX] =
{
{GPIO_LED_LE1_PORT, GPIO_LED_LE1_PIN_NUM, GPIO_LED_MODE_OFF, 0, 0, NULL, NULL},
{GPIO_LED_D1_PORT, GPIO_LED_D1_PIN_NUM, GPIO_LED_MODE_OFF, 0, 0, NULL, NULL},
{GPIO_LED_D2_PORT, GPIO_LED_D2_PIN_NUM, GPIO_LED_MODE_OFF, 0, 0, NULL, NULL},
{GPIO_LED_D3_PORT, GPIO_LED_D3_PIN_NUM, GPIO_LED_MODE_OFF, 0, 0, NULL, NULL},
{GPIO_LED_D4_PORT, GPIO_LED_D4_PIN_NUM, GPIO_LED_MODE_OFF, 0, 0, NULL, NULL},
};
void Gpio_StateLed_Initialization(void)
{
uint8_t i;
for(i = 0 ; i < GPIO_LED_MAX ; i++)
{
HAL_GPIO_ConfigOutput(Gpio_Led_Ctrl_Info[i].Port, Gpio_Led_Ctrl_Info[i].Pin, PUSH_PULL_OUTPUT);
HAL_GPIO_ConfigPullup(Gpio_Led_Ctrl_Info[i].Port, Gpio_Led_Ctrl_Info[i].Pin, PUPDx_EnablePU);
Gpio_Led_Ctrl_Info[i].LedOnFunction = State_Led_On;
Gpio_Led_Ctrl_Info[i].LedOffunction = State_Led_Off;
}
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, State_Led_Output_Process);
}
void Gpio_Led_OutputSet(GPIO_LED_LIST gpio_led_index, GPIO_LED_MODE gpio_led_mode, uint32_t OnTime, uint32_t OffTime)
{
Gpio_Led_Ctrl_Info[gpio_led_index].Mode = gpio_led_mode;
Gpio_Led_Ctrl_Info[gpio_led_index].isLedOn = true;
Gpio_Led_Ctrl_Info[gpio_led_index].nCheckTime = millis();
Gpio_Led_Ctrl_Info[gpio_led_index].nOnTime = OnTime;
Gpio_Led_Ctrl_Info[gpio_led_index].nOffTime = OffTime;
}
static void State_Led_Off(GPIO_LED_LIST gpio_led_index)
{
HAL_GPIO_SetPin(Gpio_Led_Ctrl_Info[gpio_led_index].Port, _BIT(Gpio_Led_Ctrl_Info[gpio_led_index].Pin));
}
static void State_Led_On(GPIO_LED_LIST gpio_led_index)
{
HAL_GPIO_ClearPin(Gpio_Led_Ctrl_Info[gpio_led_index].Port, _BIT(Gpio_Led_Ctrl_Info[gpio_led_index].Pin));
}
static void State_Led_Output_Process(void)
{
uint8_t i;
GPIO_STATE_LED_INFO* pControlInfo;
for(i = 0 ; i < GPIO_LED_MAX ; i++)
{
pControlInfo = &Gpio_Led_Ctrl_Info[i];
switch (pControlInfo->Mode)
{
case GPIO_LED_MODE_OFF:
pControlInfo->LedOffunction(i);
break;
case GPIO_LED_MODE_ON:
pControlInfo->LedOnFunction(i);
break;
case GPIO_LED_MODE_TOGGLE:
if(pControlInfo->isLedOn == true)
{
if((millis() - pControlInfo->nCheckTime) > pControlInfo->nOnTime )
{
pControlInfo->nCheckTime = millis();
pControlInfo->isLedOn = false;
}
pControlInfo->LedOnFunction(i);
}
else
{
if((millis() - pControlInfo->nCheckTime) > pControlInfo->nOffTime )
{
pControlInfo->nCheckTime = millis();
pControlInfo->isLedOn = true;
}
pControlInfo->LedOffunction(i);
}
break;
}
}
}
#if 0
static STATE_LED_MODE StateLedMode = STATE_LED_MODE_UNKNOW; static STATE_LED_MODE StateLedMode = STATE_LED_MODE_UNKNOW;
static STATE_LED_STEP StateLedStep = STATE_LED_STEP_INIT; static STATE_LED_STEP StateLedStep = STATE_LED_STEP_INIT;
static STATE_LED_ONOFF_TIME StateLedTime; static STATE_LED_ONOFF_TIME StateLedTime;
@ -81,3 +211,4 @@ static void State_Led_Output_Process(void)
} }
#endif

@ -5,6 +5,30 @@
#include "define.h" #include "define.h"
#include "board_config.h" #include "board_config.h"
typedef enum
{
GPIO_LED_LE1,
GPIO_LED_D1,
GPIO_LED_D2,
GPIO_LED_D3,
GPIO_LED_D4,
GPIO_LED_MAX,
}GPIO_LED_LIST;
typedef enum
{
GPIO_LED_MODE_OFF,
GPIO_LED_MODE_ON,
GPIO_LED_MODE_TOGGLE,
}GPIO_LED_MODE;
void Gpio_StateLed_Initialization(void);
void Gpio_Led_OutputSet(GPIO_LED_LIST gpio_led_index, GPIO_LED_MODE gpio_led_mode, uint32_t OnTime, uint32_t OffTime);
#if 0
#define GPIO_STATE_LED_PORT (Pn_Type*)PF #define GPIO_STATE_LED_PORT (Pn_Type*)PF
#define GPIO_STATE_LED_PIN_NUM 4 #define GPIO_STATE_LED_PIN_NUM 4
#define GPIO_STATE_LED_ON HAL_GPIO_ClearPin(GPIO_STATE_LED_PORT, _BIT(GPIO_STATE_LED_PIN_NUM)) #define GPIO_STATE_LED_ON HAL_GPIO_ClearPin(GPIO_STATE_LED_PORT, _BIT(GPIO_STATE_LED_PIN_NUM))
@ -43,3 +67,5 @@ void Gpio_StateLed_Set_Mode(STATE_LED_MODE mode);
STATE_LED_MODE Gpio_StateLed_Get_Mode(void); STATE_LED_MODE Gpio_StateLed_Get_Mode(void);
#endif #endif
#endif

@ -5,8 +5,17 @@
#if 1 #if 1
#define GPIO_PUSH_SW1_PORT (Pn_Type*)PB #define GPIO_PUSH_SW1_PORT (Pn_Type*)PC
#define GPIO_PUSH_SW1_PIN_NUM 8 #define GPIO_PUSH_SW1_PIN_NUM 0
#define GPIO_PUSH_SW2_PORT (Pn_Type*)PC
#define GPIO_PUSH_SW2_PIN_NUM 1
#define GPIO_PUSH_SW3_PORT (Pn_Type*)PC
#define GPIO_PUSH_SW3_PIN_NUM 2
#define GPIO_PUSH_SW4_PORT (Pn_Type*)PC
#define GPIO_PUSH_SW4_PIN_NUM 3
#else #else
#define GPIO_PUSH_SW1_PORT (Pn_Type*)PF #define GPIO_PUSH_SW1_PORT (Pn_Type*)PF
#define GPIO_PUSH_SW1_PIN_NUM 6 #define GPIO_PUSH_SW1_PIN_NUM 6
@ -32,20 +41,29 @@ typedef struct
static KEY_CHECK KeyCheckInfo[KEY_PUSH_SW_MAX] = static KEY_CHECK KeyCheckInfo[KEY_PUSH_SW_MAX] =
{ {
{GPIO_PUSH_SW1_PORT, GPIO_PUSH_SW1_PIN_NUM, DEFAULT_KEY_PUSH_COUNT, DEFAULT_LONGKEY_PUSH_COUNT, NULL, NULL, NULL, false, false, 0}, {GPIO_PUSH_SW1_PORT, GPIO_PUSH_SW1_PIN_NUM, DEFAULT_KEY_PUSH_COUNT, DEFAULT_LONGKEY_PUSH_COUNT, NULL, NULL, NULL, false, false, 0},
{GPIO_PUSH_SW2_PORT, GPIO_PUSH_SW2_PIN_NUM, DEFAULT_KEY_PUSH_COUNT, DEFAULT_LONGKEY_PUSH_COUNT, NULL, NULL, NULL, false, false, 0},
{GPIO_PUSH_SW3_PORT, GPIO_PUSH_SW3_PIN_NUM, DEFAULT_KEY_PUSH_COUNT, DEFAULT_LONGKEY_PUSH_COUNT, NULL, NULL, NULL, false, false, 0},
{GPIO_PUSH_SW4_PORT, GPIO_PUSH_SW4_PIN_NUM, DEFAULT_KEY_PUSH_COUNT, DEFAULT_LONGKEY_PUSH_COUNT, NULL, NULL, NULL, false, false, 0},
}; };
static void Gpio_Switch_Check_Process(void); static void Gpio_Switch_Check_Process(void);
static void Gpio_Switch_TestCallback(KEY_LIST key);
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
void Gpio_Switch_Port_Initialization(void) void Gpio_Switch_Port_Initialization(void)
{ {
HAL_GPIO_ConfigOutput((Pn_Type*)GPIO_PUSH_SW1_PORT, GPIO_PUSH_SW1_PIN_NUM, INPUT); uint8_t i;
HAL_GPIO_ConfigPullup((Pn_Type*)GPIO_PUSH_SW1_PORT, GPIO_PUSH_SW1_PIN_NUM, PUPDx_EnablePU); for(i = 0 ; i < KEY_PUSH_SW_MAX ; i++)
HAL_GPIO_SetDebouncePin((Pn_Type*)GPIO_PUSH_SW1_PORT, GPIO_PUSH_SW1_PIN_NUM, DBCLK_HCLK64); {
HAL_GPIO_ConfigOutput((Pn_Type*)KeyCheckInfo[i].Port, KeyCheckInfo[i].Pin, INPUT);
HAL_GPIO_ConfigPullup((Pn_Type*)KeyCheckInfo[i].Port, KeyCheckInfo[i].Pin, PUPDx_EnablePU);
HAL_GPIO_SetDebouncePin((Pn_Type*)KeyCheckInfo[i].Port, KeyCheckInfo[i].Pin, DBCLK_HCLK64);
Gpio_Swtich_Set_Callback(i, Gpio_Switch_TestCallback, NULL, NULL);
}
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, Gpio_Switch_Check_Process); SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, Gpio_Switch_Check_Process);
@ -70,7 +88,10 @@ void Gpio_Swtich_Set_Callback(KEY_LIST key, GPIO_SW_CALLBACK_FN Push_Callback, G
} }
} }
static void Gpio_Switch_TestCallback(KEY_LIST key)
{
printf("%d key push\r\n", key);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
static void Gpio_Switch_Check_Process(void) static void Gpio_Switch_Check_Process(void)
@ -95,7 +116,7 @@ static void Gpio_Switch_Check_Process(void)
KeyCheckInfo[i].isLongKeyPush = true; KeyCheckInfo[i].isLongKeyPush = true;
if(KeyCheckInfo[i].LongPush_Callback != NULL) if(KeyCheckInfo[i].LongPush_Callback != NULL)
{ {
KeyCheckInfo[i].LongPush_Callback(); KeyCheckInfo[i].LongPush_Callback(i);
} }
} }
} }
@ -108,14 +129,14 @@ static void Gpio_Switch_Check_Process(void)
{ {
if(KeyCheckInfo[i].Push_Callback != NULL) if(KeyCheckInfo[i].Push_Callback != NULL)
{ {
KeyCheckInfo[i].Push_Callback(); KeyCheckInfo[i].Push_Callback(i);
} }
} }
} }
if(KeyCheckInfo[i].Release_Callback != NULL) if(KeyCheckInfo[i].Release_Callback != NULL)
{ {
KeyCheckInfo[i].Release_Callback(); KeyCheckInfo[i].Release_Callback(i);
} }
KeyCheckInfo[i].isPush = false; KeyCheckInfo[i].isPush = false;
KeyCheckInfo[i].isLongKeyPush = false; KeyCheckInfo[i].isLongKeyPush = false;

@ -8,10 +8,13 @@
typedef enum typedef enum
{ {
KEY_PUSH_SW1, KEY_PUSH_SW1,
KEY_PUSH_SW2,
KEY_PUSH_SW3,
KEY_PUSH_SW4,
KEY_PUSH_SW_MAX KEY_PUSH_SW_MAX
}KEY_LIST; }KEY_LIST;
typedef void (*GPIO_SW_CALLBACK_FN) (void); typedef void (*GPIO_SW_CALLBACK_FN) (KEY_LIST key);

@ -3,6 +3,7 @@
#include "gpio_state_led.h" #include "gpio_state_led.h"
#include "gpio_switch.h" #include "gpio_switch.h"
#include "uart1.h" #include "uart1.h"
#include "usart11_rs485.h"
#include "spi10.h" #include "spi10.h"
#include "spi13.h" #include "spi13.h"
#include "timer12.h" #include "timer12.h"
@ -20,9 +21,26 @@
void timer_test(void) void timer_test(void)
{ {
static bool istoggle = true;
uint8_t i;
uint8_t TxBuff[10];
for(i = 0 ; i < 10 ; i++)
TxBuff[i] = i;
//Buzzer_On(50); Usart11_TransmitData(TxBuff, 10);
//Segment_In_Set_Humidity(12);
#if 0
if(istoggle == true)
{
istoggle = false;
I2C2_SCL_HIGH;
}
else
{
istoggle = true;
I2C2_SCL_LOW;
}
#endif
} }
@ -34,41 +52,73 @@ int main(void)
Systick_Initialization(1); Systick_Initialization(1);
FlashMEM_Clock_Initialization(); FlashMEM_Clock_Initialization();
Timer12_Initialization(); Usart11_Initialization(38400, USART1n_DATA_BIT_8, USART1n_PARITY_BIT_NONE, USART1n_STOP_BIT_1);
Uart1_Initialization(115200, UARTn_DATA_BIT_8, UARTn_PARITY_BIT_NONE, UARTn_STOP_BIT_1); Uart1_Initialization(115200, UARTn_DATA_BIT_8, UARTn_PARITY_BIT_NONE, UARTn_STOP_BIT_1);
SPI10_Initialization(1000000, SPI10_MODE0, false); Uart_Packet_Initialization();
GPIO_I2C2_Initialization();
RTC_Process_Initialization();
Buzzer_Initialization();
Gpio_StateLed_Initialization();
Gpio_Switch_Port_Initialization(); Gpio_Switch_Port_Initialization();
Gpio_StateLed_Initialization();
Timer12_Initialization();
SPI10_Initialization(1000000, SPI10_MODE0, false);
SPI13_Initialization(1000000, SPI13_MODE0, false);
Segment_Initialization();
Action_Initialization();
__enable_irq();
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 250, timer_test);
while(true)
{
SW_Timer_Callback_Process();
}
#if 0
Gpio_Sensor_PWR_Initialization(); Gpio_Sensor_PWR_Initialization();
GPIO_I2C0_Initialization(); GPIO_I2C0_Initialization();
GPIO_I2C1_Initialization(); GPIO_I2C1_Initialization();
GPIO_I2C2_Initialization();
Segment_Initialization();
__enable_irq();
RTC_Process_Initialization();
Buzzer_Initialization();
Action_Initialization(); Action_Initialization();
Uart_Packet_Initialization();
//Sensor_Save_SDCard_Process(); //Sensor_Save_SDCard_Process();
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 500, timer_test);
//Timer12_Set_Match_Interrupt_Callback(timer_test); //Timer12_Set_Match_Interrupt_Callback(timer_test);
#endif
while(true)
{
SW_Timer_Callback_Process();
}
} }

@ -31,7 +31,7 @@ static void RTC_Get_IC_Time_Process(void)
rtc_Time.rtc_Min = t.minute; rtc_Time.rtc_Min = t.minute;
rtc_Time.rtc_Sec = t.second; rtc_Time.rtc_Sec = t.second;
dbg_printf("Read RTC : %04d-%02d-%02d %02d:%02d:%02d\r\n", rtc_Time.rtc_Year, rtc_Time.rtc_Month, rtc_Time.rtc_Date, rtc_Time.rtc_Hour, rtc_Time.rtc_Min, rtc_Time.rtc_Sec);
} }

@ -1,5 +1,6 @@
#include "segment.h" #include "segment.h"
#include "segment_74hc595d.h" #include "segment_74hc595d.h"
#include "rtc_process.h"
const uint8_t SegmentData[SEG_INDEX_MAX] = const uint8_t SegmentData[SEG_INDEX_MAX] =
{ {
@ -50,6 +51,146 @@ const uint8_t SegmentData[SEG_INDEX_MAX] =
uint8_t Segment_OutputBuff[SEGMENT_SELECT_MAX_INDEX][SEGMENT_MAX_DATA_INDEX]; uint8_t Segment_OutputBuff[SEGMENT_SELECT_MAX_INDEX][SEGMENT_MAX_DATA_INDEX];
void Segment_Sensor_Error(void)
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_MINUS];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_MINUS];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_MINUS];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[SEG_MINUS];
}
void Segment_All_Set_Data(uint8_t SegmentData)
{
uint8_t i;
for(i = SEGMENT_COM1 ; i < SEGMENT_SELECT_MAX_INDEX ; i++)
{
Segment_OutputBuff[i][SEGMENT_F1] = SegmentData;
Segment_OutputBuff[i][SEGMENT_F2] = SegmentData;
}
}
void Segment_Show_Version(void)
{
uint8_t temp;
Segment_All_Set_Data(0x00);
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F1] = SegmentData[SEG_V];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F1] = SegmentData[SEG_E];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F1] = SegmentData[SEG_R];
temp = VERSION_MAJOR;
if(temp >= 99)
{
temp = 99;
}
if(VERSION_MAJOR < 10)
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
}
else
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[temp/10];
}
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[temp%10] | 0x80;
temp = VERSION_MINOR;
if(temp >= 99)
{
temp = 99;
}
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[temp/10];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[temp%10];
}
void Segment_Show_Time(void)
{
uint32_t colon_on = millis() % 1000;;
RTC_TIME rtc_time = RTC_Get_Time();
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F1] = SegmentData[rtc_time.rtc_Hour/10];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F1] = SegmentData[rtc_time.rtc_Hour%10];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F1] = SegmentData[rtc_time.rtc_Min/10];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F1] = SegmentData[rtc_time.rtc_Min%10];
if(colon_on > 500)
{
Segment_OutputBuff[SEGMENT_EXT][SEGMENT_F1] = 0x02;
}
else
{
Segment_OutputBuff[SEGMENT_EXT][SEGMENT_F1] = SegmentData[SEG_CLEAR];
}
}
void Segment_Show_SensorData(uint32_t SensorData)
{
if(SensorData >= 9999)
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_9];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_9];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_9];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[SEG_9];
}
else if(SensorData >= 1000)
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SensorData/1000];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[(SensorData%1000)/100];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[(SensorData%100)/10];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
}
else if(SensorData >= 100)
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[(SensorData%1000)/100];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[(SensorData%100)/10];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
}
else if(SensorData >= 10)
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_CLEAR];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[(SensorData%100)/10];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
}
else
{
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_CLEAR];
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_CLEAR];
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
}
}
#if 0
void Segment_In_Set_PM_1p0(uint32_t OutputData) void Segment_In_Set_PM_1p0(uint32_t OutputData)
{ {
Segment_Toggle_In = false; Segment_Toggle_In = false;
@ -581,3 +722,4 @@ void Segment_Out_Sensor_Error(void)
Segment_OutputBuff[SEGMENT_F4C1][SEGMENT_DATA_4] = SegmentData[SEG_MINUS]; Segment_OutputBuff[SEGMENT_F4C1][SEGMENT_DATA_4] = SegmentData[SEG_MINUS];
Segment_OutputBuff[SEGMENT_F4C2][SEGMENT_DATA_4] = SegmentData[SEG_MINUS]; Segment_OutputBuff[SEGMENT_F4C2][SEGMENT_DATA_4] = SegmentData[SEG_MINUS];
} }
#endif

@ -49,23 +49,27 @@ typedef enum
typedef enum typedef enum
{ {
SEGMENT_F1C1, SEGMENT_COM1,
SEGMENT_F1C2, SEGMENT_COM2,
SEGMENT_F2C1, SEGMENT_COM3,
SEGMENT_F2C2, SEGMENT_COM4,
SEGMENT_F3C1, SEGMENT_COM5,
SEGMENT_F3C2,
SEGMENT_F4C1,
SEGMENT_F4C2,
SEGMENT_SELECT_MAX_INDEX, SEGMENT_SELECT_MAX_INDEX,
}SEGMENT_SELECT_INDEX; }SEGMENT_SELECT_INDEX;
typedef enum typedef enum
{ {
SEGMENT_DATA_1, SEGMENT_1000,
SEGMENT_DATA_2, SEGMENT_100,
SEGMENT_DATA_3, SEGMENT_10,
SEGMENT_DATA_4, SEGMENT_1,
SEGMENT_EXT,
}SEGMENT_SELECT_NAME;
typedef enum
{
SEGMENT_F1,
SEGMENT_F2,
SEGMENT_MAX_DATA_INDEX, SEGMENT_MAX_DATA_INDEX,
}SEGMENT_DATA_INDEX; }SEGMENT_DATA_INDEX;
@ -74,24 +78,10 @@ extern uint8_t Segment_OutputBuff[SEGMENT_SELECT_MAX_INDEX][SEGMENT_MAX_DATA_IND
extern const uint8_t SegmentData[SEG_INDEX_MAX]; extern const uint8_t SegmentData[SEG_INDEX_MAX];
void Segment_In_Set_PM_1p0(uint32_t OutputData); void Segment_Sensor_Error(void);
void Segment_In_Set_PM_2p5(uint32_t OutputData);
void Segment_In_Set_PM_4p0(uint32_t OutputData);
void Segment_In_Set_PM_10(uint32_t OutputData);
void Segment_In_Set_Humidity(uint32_t OutputData);
void Segment_In_Set_Temperature(int32_t OutputData);
void Segment_In_Sensor_Error(void);
void Segment_Out_Set_PM_1p0(uint32_t OutputData);
void Segment_Out_Set_PM_2p5(uint32_t OutputData);
void Segment_Out_Set_PM_4p0(uint32_t OutputData);
void Segment_Out_Set_PM_10(uint32_t OutputData);
void Segment_Out_Set_Humidity(uint32_t OutputData);
void Segment_Out_Set_Temperature(int32_t OutputData);
void Segment_Out_Sensor_Error(void);
void Segment_All_Set_Data(uint8_t SegmentData); void Segment_All_Set_Data(uint8_t SegmentData);
void Segment_Show_Version(void); void Segment_Show_Version(void);
void Segment_Show_Mode(uint8_t Mode); void Segment_Show_Time(void);
void Segment_Show_SensorData(uint32_t SensorData);
#endif #endif

@ -12,19 +12,8 @@ typedef enum
}LSB_MSB_MODE; }LSB_MSB_MODE;
#define SEGMENT_74HC595D_SDATA_PORT (Pn_Type*)PE
#define SEGMENT_74HC595D_SDATA_PIN 8
#define SEGMENT_74HC595D_SDATA_HIGH HAL_GPIO_SetPin(SEGMENT_74HC595D_SDATA_PORT,_BIT(SEGMENT_74HC595D_SDATA_PIN))
#define SEGMENT_74HC595D_SDATA_LOW HAL_GPIO_ClearPin(SEGMENT_74HC595D_SDATA_PORT,_BIT(SEGMENT_74HC595D_SDATA_PIN))
#define SEGMENT_74HC595D_SCK_PORT (Pn_Type*)PE
#define SEGMENT_74HC595D_SCK_PIN 9
#define SEGMENT_74HC595D_SCK_HIGH HAL_GPIO_SetPin(SEGMENT_74HC595D_SCK_PORT,_BIT(SEGMENT_74HC595D_SCK_PIN))
#define SEGMENT_74HC595D_SCK_LOW HAL_GPIO_ClearPin(SEGMENT_74HC595D_SCK_PORT,_BIT(SEGMENT_74HC595D_SCK_PIN))
#define SEGMENT_74HC595D_LATCH_PORT (Pn_Type*)PE #define SEGMENT_74HC595D_LATCH_PORT (Pn_Type*)PE
#define SEGMENT_74HC595D_LATCH_PIN_NUM 10 #define SEGMENT_74HC595D_LATCH_PIN_NUM 11
#define SEGMENT_74HC595D_LATCH_H HAL_GPIO_SetPin(SEGMENT_74HC595D_LATCH_PORT, _BIT(SEGMENT_74HC595D_LATCH_PIN_NUM)) #define SEGMENT_74HC595D_LATCH_H HAL_GPIO_SetPin(SEGMENT_74HC595D_LATCH_PORT, _BIT(SEGMENT_74HC595D_LATCH_PIN_NUM))
#define SEGMENT_74HC595D_LATCH_L HAL_GPIO_ClearPin(SEGMENT_74HC595D_LATCH_PORT, _BIT(SEGMENT_74HC595D_LATCH_PIN_NUM)) #define SEGMENT_74HC595D_LATCH_L HAL_GPIO_ClearPin(SEGMENT_74HC595D_LATCH_PORT, _BIT(SEGMENT_74HC595D_LATCH_PIN_NUM))
#define SEGMENT_74HC595D_LATCH_T HAL_GPIO_TogglePin(SEGMENT_74HC595D_LATCH_PORT, _BIT(SEGMENT_74HC595D_LATCH_PIN_NUM)) #define SEGMENT_74HC595D_LATCH_T HAL_GPIO_TogglePin(SEGMENT_74HC595D_LATCH_PORT, _BIT(SEGMENT_74HC595D_LATCH_PIN_NUM))
@ -34,20 +23,15 @@ typedef union
{ {
struct struct
{ {
uint8_t HC595_4; uint8_t HC595_1_COM1 : 1;
uint8_t HC595_3; uint8_t HC595_1_COM2 : 1;
uint8_t HC595_1_COM3 : 1;
uint8_t HC595_5_F1C1 : 1; uint8_t HC595_1_COM4 : 1;
uint8_t HC595_5_F1C2 : 1; uint8_t HC595_1_COM5 : 1;
uint8_t HC595_5_F2C1 : 1; uint8_t HC595_1_RESERVED : 3;
uint8_t HC595_5_F2C2 : 1;
uint8_t HC595_5_F3C1 : 1;
uint8_t HC595_5_F3C2 : 1;
uint8_t HC595_5_F4C1 : 1;
uint8_t HC595_5_F4C2 : 1;
uint8_t HC595_2; uint8_t HC595_2;
uint8_t HC595_1; uint8_t HC595_3;
}HC595_Data; }HC595_Data;
uint8_t HC595_TxBuff[SEGMENT_74HC595D_IC_TOTAL_NUM]; uint8_t HC595_TxBuff[SEGMENT_74HC595D_IC_TOTAL_NUM];
}HC595_OUTPUT_DATA; }HC595_OUTPUT_DATA;
@ -70,19 +54,11 @@ static void Segment_Output_Data(uint8_t* pTxData, uint8_t TxSize);
void Segment_Initialization(void) void Segment_Initialization(void)
{ {
HAL_GPIO_ConfigOutput(SEGMENT_74HC595D_SDATA_PORT, SEGMENT_74HC595D_SDATA_PIN, PUSH_PULL_OUTPUT);
HAL_GPIO_ConfigPullup(SEGMENT_74HC595D_SDATA_PORT, SEGMENT_74HC595D_SDATA_PIN, PUPDx_EnablePU);
HAL_GPIO_ConfigOutput(SEGMENT_74HC595D_SCK_PORT, SEGMENT_74HC595D_SCK_PIN, PUSH_PULL_OUTPUT);
HAL_GPIO_ConfigPullup(SEGMENT_74HC595D_SCK_PORT, SEGMENT_74HC595D_SCK_PIN, PUPDx_EnablePU);
HAL_GPIO_ConfigOutput(SEGMENT_74HC595D_LATCH_PORT, SEGMENT_74HC595D_LATCH_PIN_NUM, PUSH_PULL_OUTPUT); HAL_GPIO_ConfigOutput(SEGMENT_74HC595D_LATCH_PORT, SEGMENT_74HC595D_LATCH_PIN_NUM, PUSH_PULL_OUTPUT);
HAL_GPIO_ConfigPullup(SEGMENT_74HC595D_LATCH_PORT, SEGMENT_74HC595D_LATCH_PIN_NUM, PUPDx_EnablePU); HAL_GPIO_ConfigPullup(SEGMENT_74HC595D_LATCH_PORT, SEGMENT_74HC595D_LATCH_PIN_NUM, PUPDx_EnablePU);
SEGMENT_74HC595D_LATCH_H; SEGMENT_74HC595D_LATCH_H;
SEGMENT_74HC595D_SCK_LOW;
SEGMENT_74HC595D_SDATA_HIGH;
//Segmet_Output_Process(); //Segmet_Output_Process();
ToggleTickCount = millis(); ToggleTickCount = millis();
@ -96,63 +72,27 @@ static void Segemet_Output_Process(void)
memset(HC595_OutputData.HC595_TxBuff, 0, SEGMENT_74HC595D_IC_TOTAL_NUM); memset(HC595_OutputData.HC595_TxBuff, 0, SEGMENT_74HC595D_IC_TOTAL_NUM);
if((millis() - ToggleTickCount) >= SEGMENT_TOGGLE_TIME)
{
ToggleTickCount = millis();
isToggle = !isToggle;
}
switch(SegmentOutputStep) switch(SegmentOutputStep)
{ {
case SEGMENT_OUTPUT_F1C1: case SEGMENT_OUTPUT_COM1:
HC595_OutputData.HC595_Data.HC595_5_F1C1 = true; HC595_OutputData.HC595_Data.HC595_1_COM1 = true;
break;
case SEGMENT_OUTPUT_F1C2:
HC595_OutputData.HC595_Data.HC595_5_F1C2 = true;
break; break;
case SEGMENT_OUTPUT_F2C1: case SEGMENT_OUTPUT_COM2:
HC595_OutputData.HC595_Data.HC595_5_F2C1 = true; HC595_OutputData.HC595_Data.HC595_1_COM2 = true;
break; break;
case SEGMENT_OUTPUT_F2C2: case SEGMENT_OUTPUT_COM3:
HC595_OutputData.HC595_Data.HC595_5_F2C2 = true; HC595_OutputData.HC595_Data.HC595_1_COM3 = true;
break; break;
case SEGMENT_OUTPUT_F3C1: case SEGMENT_OUTPUT_COM4:
HC595_OutputData.HC595_Data.HC595_5_F3C1 = true; HC595_OutputData.HC595_Data.HC595_1_COM4 = true;
break; break;
case SEGMENT_OUTPUT_F3C2: case SEGMENT_OUTPUT_COM5:
HC595_OutputData.HC595_Data.HC595_5_F3C2 = true; HC595_OutputData.HC595_Data.HC595_1_COM5 = true;
break;
case SEGMENT_OUTPUT_F4C1:
HC595_OutputData.HC595_Data.HC595_5_F4C1 = true;
break;
case SEGMENT_OUTPUT_F4C2:
HC595_OutputData.HC595_Data.HC595_5_F4C2 = true;
break; break;
} }
HC595_OutputData.HC595_Data.HC595_1 = Segment_OutputBuff[SegmentOutputStep][0]; HC595_OutputData.HC595_Data.HC595_3 = Segment_OutputBuff[SegmentOutputStep][SEGMENT_F1];
HC595_OutputData.HC595_Data.HC595_2 = Segment_OutputBuff[SegmentOutputStep][1]; HC595_OutputData.HC595_Data.HC595_2 = Segment_OutputBuff[SegmentOutputStep][SEGMENT_F2];
HC595_OutputData.HC595_Data.HC595_3 = Segment_OutputBuff[SegmentOutputStep][2];
HC595_OutputData.HC595_Data.HC595_4 = Segment_OutputBuff[SegmentOutputStep][3];
if(Segment_Toggle_In == true && isToggle == true)
{
if(SegmentOutputStep == DUST_SENSOR_PM40_SELECT_1 || SegmentOutputStep == DUST_SENSOR_PM40_SELECT_2)
{
HC595_OutputData.HC595_Data.HC595_1 = 0x00;
HC595_OutputData.HC595_Data.HC595_2 = 0x00;
}
}
if(Segment_Toggle_Out == true && isToggle == true)
{
if(SegmentOutputStep == DUST_SENSOR_PM40_SELECT_1 || SegmentOutputStep == DUST_SENSOR_PM40_SELECT_2)
{
HC595_OutputData.HC595_Data.HC595_3 = 0x00;
HC595_OutputData.HC595_Data.HC595_4 = 0x00;
}
}
SEGMENT_74HC595D_LATCH_L; SEGMENT_74HC595D_LATCH_L;
Segment_Output_Data(HC595_OutputData.HC595_TxBuff, SEGMENT_74HC595D_IC_TOTAL_NUM); Segment_Output_Data(HC595_OutputData.HC595_TxBuff, SEGMENT_74HC595D_IC_TOTAL_NUM);
@ -161,60 +101,13 @@ static void Segemet_Output_Process(void)
SegmentOutputStep++; SegmentOutputStep++;
if(SegmentOutputStep >= SEGMENT_OUTPUT_MAX) if(SegmentOutputStep >= SEGMENT_OUTPUT_MAX)
{ {
SegmentOutputStep = SEGMENT_OUTPUT_F1C1; SegmentOutputStep = SEGMENT_OUTPUT_COM1;
} }
} }
static void Segment_Output_Data(uint8_t* pTxData, uint8_t TxSize) static void Segment_Output_Data(uint8_t* pTxData, uint8_t TxSize)
{ {
uint8_t Temp; SPI13_Transmit(pTxData, TxSize);
uint8_t i, j;
if(HC595_OutputMode == LSB_FIRST)
{
for(i = 0 ; i < TxSize ; i++)
{
Temp = pTxData[i];
for(j = 0 ; j < 8 ; j++)
{
if((Temp & 0x01))
{
SEGMENT_74HC595D_SDATA_HIGH;
}
else
{
SEGMENT_74HC595D_SDATA_LOW;
}
SEGMENT_74HC595D_SCK_HIGH;
SEGMENT_74HC595D_SCK_LOW;
Temp = Temp >> 1;
}
}
}
else
{
for(i = 0 ; i < TxSize ; i++)
{
Temp = pTxData[i];
for(j = 0 ; j < 8 ; j++)
{
if((Temp & 0x80))
{
SEGMENT_74HC595D_SDATA_HIGH;
}
else
{
SEGMENT_74HC595D_SDATA_LOW;
}
SEGMENT_74HC595D_SCK_HIGH;
SEGMENT_74HC595D_SCK_LOW;
Temp = Temp << 1;
}
}
}
SEGMENT_74HC595D_SDATA_HIGH;
} }

@ -6,7 +6,7 @@
#include "board_config.h" #include "board_config.h"
#define SEGMENT_74HC595D_IC_DATA_NUM 4 #define SEGMENT_74HC595D_IC_DATA_NUM 2
#define SEGMENT_74HC595D_IC_SELECT_NUM 1 #define SEGMENT_74HC595D_IC_SELECT_NUM 1
#define SEGMENT_74HC595D_IC_TOTAL_NUM (SEGMENT_74HC595D_IC_DATA_NUM + SEGMENT_74HC595D_IC_SELECT_NUM) #define SEGMENT_74HC595D_IC_TOTAL_NUM (SEGMENT_74HC595D_IC_DATA_NUM + SEGMENT_74HC595D_IC_SELECT_NUM)
@ -25,14 +25,11 @@
typedef enum typedef enum
{ {
SEGMENT_OUTPUT_F1C1, SEGMENT_OUTPUT_COM1,
SEGMENT_OUTPUT_F1C2, SEGMENT_OUTPUT_COM2,
SEGMENT_OUTPUT_F2C1, SEGMENT_OUTPUT_COM3,
SEGMENT_OUTPUT_F2C2, SEGMENT_OUTPUT_COM4,
SEGMENT_OUTPUT_F3C1, SEGMENT_OUTPUT_COM5,
SEGMENT_OUTPUT_F3C2,
SEGMENT_OUTPUT_F4C1,
SEGMENT_OUTPUT_F4C2,
SEGMENT_OUTPUT_MAX, SEGMENT_OUTPUT_MAX,
}SEGMENT_OUTPUT_STEP; }SEGMENT_OUTPUT_STEP;

@ -1,14 +1,9 @@
#include "usart11.h" #include "usart11_rs485.h"
#include "ring_buffer.h" #include "ring_buffer.h"
#include "sw_timer.h" #include "sw_timer.h"
#include "gpio_uart_led.h"
#define USARTn_TX_INTERRUTP_ENABLE FALSE #define USARTn_TX_INTERRUTP_ENABLE FALSE
#define USARTn_PERIPHERAL USART11 #define USARTn_PERIPHERAL USART11
#define USARTn_INTERRUPT_HANDLER USART11_IRQn #define USARTn_INTERRUPT_HANDLER USART11_IRQn
#define USARTn_INTERRUPT_MASK MSK_USART11 #define USARTn_INTERRUPT_MASK MSK_USART11
@ -19,10 +14,19 @@
#define USARTn_RX_PORT PD #define USARTn_RX_PORT PD
#define USARTn_RX_PIN_NUM 3 #define USARTn_RX_PIN_NUM 3
#define USARTn_TX_BUFFER_SIZE 600 #define USARTn_TX_BUFFER_SIZE 100
#define USARTn_RX_BUFFER_SIZE 100 #define USARTn_RX_BUFFER_SIZE 100
#define USARTn_RS485_REDE_PORT (Pn_Type*)PD
#define USARTn_RS485_REDE_NUM 4
#define USARTn_RS485_RECEIVE HAL_GPIO_ClearPin(USARTn_RS485_REDE_PORT, _BIT(USARTn_RS485_REDE_NUM))
#define USARTn_RS485_TRANSMIT HAL_GPIO_SetPin(USARTn_RS485_REDE_PORT, _BIT(USARTn_RS485_REDE_NUM))
static uint8_t Tx_Buffer[USARTn_TX_BUFFER_SIZE]; static uint8_t Tx_Buffer[USARTn_TX_BUFFER_SIZE];
static uint8_t Rx_Buffer[USARTn_RX_BUFFER_SIZE]; static uint8_t Rx_Buffer[USARTn_RX_BUFFER_SIZE];
@ -62,6 +66,10 @@ void Usart11_Initialization(uint32_t Baudrate, USART1n_DATA_BIT_Type Databit, US
HAL_USART_Init( ( USART1n_Type* )USARTn_PERIPHERAL, &USART1n_Config ); HAL_USART_Init( ( USART1n_Type* )USARTn_PERIPHERAL, &USART1n_Config );
HAL_GPIO_ConfigOutput(USARTn_RS485_REDE_PORT, USARTn_RS485_REDE_NUM, PUSH_PULL_OUTPUT);
HAL_GPIO_ConfigPullup(USARTn_RS485_REDE_PORT, USARTn_RS485_REDE_NUM, PUPDx_EnablePU);
USARTn_RS485_RECEIVE;
/* Enable UART Rx interrupt */ /* Enable UART Rx interrupt */
HAL_USART_ConfigInterrupt((USART1n_Type*)USARTn_PERIPHERAL, USART1n_INTCFG_RXC, ENABLE ); HAL_USART_ConfigInterrupt((USART1n_Type*)USARTn_PERIPHERAL, USART1n_INTCFG_RXC, ENABLE );
#if (USARTn_TX_INTERRUTP_ENABLE == TRUE) #if (USARTn_TX_INTERRUTP_ENABLE == TRUE)
@ -188,21 +196,37 @@ static void Usart11_Init_TransmitSet(void)
#else #else
static void Usart11_Transmit_Process(void) static void Usart11_Transmit_Process(void)
{ {
if(RingBuffer_Get_DataSize(&RingBuffer_Tx) != 0) uint32_t TxCount = RingBuffer_Get_DataSize(&RingBuffer_Tx);
if(TxCount != 0)
{ {
uint8_t TxData; uint8_t TxData;
GPIO_UART_RS232_RX_LED_ON; USARTn_RS485_TRANSMIT;
RingBuffer_GetData(&RingBuffer_Tx, &TxData); RingBuffer_GetData(&RingBuffer_Tx, &TxData);
if(HAL_USART_Transmit((USART1n_Type*)USARTn_PERIPHERAL, &TxData, 1, NONE_BLOCKING)) if(TxCount <= 2)
{ {
/* Update transmit ring FIFO tail pointer */ if(HAL_USART_CheckBusy((UARTn_Type *)USARTn_PERIPHERAL) == RESET)
RingBuffer_PopData(&RingBuffer_Tx); {
if(HAL_USART_Transmit((USART1n_Type*)USARTn_PERIPHERAL, &TxData, 1, BLOCKING))
{
/* Update transmit ring FIFO tail pointer */
RingBuffer_PopData(&RingBuffer_Tx);
}
}
}
else
{
if(HAL_USART_Transmit((USART1n_Type*)USARTn_PERIPHERAL, &TxData, 1, NONE_BLOCKING))
{
/* Update transmit ring FIFO tail pointer */
RingBuffer_PopData(&RingBuffer_Tx);
}
} }
} }
else else
{ {
GPIO_UART_RS232_RX_LED_OFF; if(HAL_USART_CheckBusy((UARTn_Type *)USARTn_PERIPHERAL) == RESET)
USARTn_RS485_RECEIVE;
} }
} }
#endif #endif

@ -1,7 +1,8 @@
/** \file usart11.h */ /** \file usart11.h */
#if !defined(USART11_H__358CA7DD_31CD_4E7D_9BFE_5B68A5DAD39D__INCLUDED_) #if !defined(USART11_RS485_H__358CA7DD_31CD_4E7D_9BFE_5B68A5DAD39D__INCLUDED_)
#define USART11_H__358CA7DD_31CD_4E7D_9BFE_5B68A5DAD39D__INCLUDED_ #define USART11_RS485_H__358CA7DD_31CD_4E7D_9BFE_5B68A5DAD39D__INCLUDED_
#include "board_config.h"
#include "define.h" #include "define.h"
void Usart11_Initialization(uint32_t Baudrate, USART1n_DATA_BIT_Type Databit, USART1n_PARITY_BIT_Type Paritybit, USART1n_STOP_BIT_Type Stopbit); void Usart11_Initialization(uint32_t Baudrate, USART1n_DATA_BIT_Type Databit, USART1n_PARITY_BIT_Type Paritybit, USART1n_STOP_BIT_Type Stopbit);

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save