Browse Source

完成新需求

master
htujun 3 years ago
parent
commit
0d39db9498
  1. 7
      stm32/HARDWARE/LED/led.c
  2. 4
      stm32/HARDWARE/LED/led.h
  3. BIN
      stm32/OBJ/Template.axf
  4. 6
      stm32/OBJ/Template.build_log.htm
  5. 2851
      stm32/OBJ/Template.hex
  6. 1141
      stm32/OBJ/Template.htm
  7. 10
      stm32/OBJ/Template_Target 1.dep
  8. BIN
      stm32/OBJ/led.crf
  9. BIN
      stm32/OBJ/led.o
  10. BIN
      stm32/OBJ/main.crf
  11. BIN
      stm32/OBJ/main.o
  12. BIN
      stm32/OBJ/timer.crf
  13. BIN
      stm32/OBJ/timer.o
  14. 1213
      stm32/USER/Template.map
  15. 69
      stm32/USER/Template.uvguix.QY
  16. 2
      stm32/USER/Template.uvoptx
  17. 128
      stm32/USER/main.c

7
stm32/HARDWARE/LED/led.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
void LED_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
@ -25,8 +25,11 @@ void LED_Init() @@ -25,8 +25,11 @@ void LED_Init()
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_11 | GPIO_Pin_9 | GPIO_Pin_10;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}

4
stm32/HARDWARE/LED/led.h

@ -13,6 +13,10 @@ @@ -13,6 +13,10 @@
#define BEEP PCout(15)
#define LED PCout(14)
#define LED0 PAout(10)
#define LED1 PAout(9)
#define LED2 PBout(14)
void LED_Init(void);

BIN
stm32/OBJ/Template.axf

Binary file not shown.

6
stm32/OBJ/Template.build_log.htm

@ -34,13 +34,13 @@ compiling main.c... @@ -34,13 +34,13 @@ compiling main.c...
#define IN GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_8)//¶ÁÈ¡°´¼ü0
..\HARDWARE\KEY\key.h(7): warning: #47-D: incompatible redefinition of macro "OUT" (declared at line 13 of "..\HARDWARE\DS1302\DS1302.h")
#define OUT GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_9)//¶ÁÈ¡°´¼ü1
main.c(121): warning: #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
main.c(129): warning: #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
OLED_ShowString(0, 0, str, 16);
main.c(249): warning: #177-D: variable "pwm" was declared but never referenced
main.c(317): warning: #177-D: variable "pwm" was declared but never referenced
int x=0, pwm; //bh1750模å<EFBFBD>—获å<EFBFBD>–到的数æ<EFBFBD>®
main.c: 5 warnings, 0 errors
linking...
Program Size: Code=19908 RO-data=2340 RW-data=392 ZI-data=1440
Program Size: Code=20560 RO-data=2408 RW-data=408 ZI-data=1456
FromELF: creating hex file...
"..\OBJ\Template.axf" - 0 Error(s), 5 Warning(s).

2851
stm32/OBJ/Template.hex

File diff suppressed because it is too large Load Diff

1141
stm32/OBJ/Template.htm

File diff suppressed because it is too large Load Diff

10
stm32/OBJ/Template_Target 1.dep

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Dependencies for Project 'Template', Target 'Target 1': (DO NOT MODIFY !)
F (.\main.c)(0x627AA620)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\KEY -I ..\HARDWARE\MOTOR -I ..\HARDWARE\24CXX -I ..\HARDWARE\IIC -I ..\HARDWARE\BH1750 -I ..\HARDWARE\WDG -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\main.o --omf_browse ..\obj\main.crf --depend ..\obj\main.d)
I (..\HARDWARE\LED\led.h)(0x627A5FB6)
F (.\main.c)(0x62827284)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\KEY -I ..\HARDWARE\MOTOR -I ..\HARDWARE\24CXX -I ..\HARDWARE\IIC -I ..\HARDWARE\BH1750 -I ..\HARDWARE\WDG -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\main.o --omf_browse ..\obj\main.crf --depend ..\obj\main.d)
I (..\HARDWARE\LED\led.h)(0x62825E8E)
I (..\SYSTEM\sys\sys.h)(0x6256947A)
I (..\USER\stm32f10x.h)(0x6256947A)
I (..\CORE\core_cm3.h)(0x6256947A)
@ -111,8 +111,8 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_tim.h)(0x6256947A) @@ -111,8 +111,8 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_tim.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\stm32f10x_usart.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\misc.h)(0x6256947A)
F (..\HARDWARE\LED\led.c)(0x627A5D78)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\KEY -I ..\HARDWARE\MOTOR -I ..\HARDWARE\24CXX -I ..\HARDWARE\IIC -I ..\HARDWARE\BH1750 -I ..\HARDWARE\WDG -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\led.o --omf_browse ..\obj\led.crf --depend ..\obj\led.d)
I (..\HARDWARE\LED\led.h)(0x627A5FB6)
F (..\HARDWARE\LED\led.c)(0x62825C36)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\KEY -I ..\HARDWARE\MOTOR -I ..\HARDWARE\24CXX -I ..\HARDWARE\IIC -I ..\HARDWARE\BH1750 -I ..\HARDWARE\WDG -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\led.o --omf_browse ..\obj\led.crf --depend ..\obj\led.d)
I (..\HARDWARE\LED\led.h)(0x62825E8E)
I (..\SYSTEM\sys\sys.h)(0x6256947A)
I (..\USER\stm32f10x.h)(0x6256947A)
I (..\CORE\core_cm3.h)(0x6256947A)
@ -238,7 +238,7 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_tim.h)(0x6256947A) @@ -238,7 +238,7 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_tim.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\stm32f10x_usart.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\misc.h)(0x6256947A)
I (..\HARDWARE\LED\led.h)(0x627A5FB6)
I (..\HARDWARE\LED\led.h)(0x62825E8E)
I (..\SYSTEM\usart\usart.h)(0x6256947A)
I (D:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x599ECD2C)
F (..\HARDWARE\DS18B20\ds18b20.c)(0x6259AF4E)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\KEY -I ..\HARDWARE\MOTOR -I ..\HARDWARE\24CXX -I ..\HARDWARE\IIC -I ..\HARDWARE\BH1750 -I ..\HARDWARE\WDG -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\ds18b20.o --omf_browse ..\obj\ds18b20.crf --depend ..\obj\ds18b20.d)

BIN
stm32/OBJ/led.crf

Binary file not shown.

BIN
stm32/OBJ/led.o

Binary file not shown.

BIN
stm32/OBJ/main.crf

Binary file not shown.

BIN
stm32/OBJ/main.o

Binary file not shown.

BIN
stm32/OBJ/timer.crf

Binary file not shown.

BIN
stm32/OBJ/timer.o

Binary file not shown.

1213
stm32/USER/Template.map

File diff suppressed because it is too large Load Diff

69
stm32/USER/Template.uvguix.QY

File diff suppressed because one or more lines are too long

2
stm32/USER/Template.uvoptx

@ -391,7 +391,7 @@ @@ -391,7 +391,7 @@
<GroupNumber>2</GroupNumber>
<FileNumber>15</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\HARDWARE\24CXX\24cxx.c</PathWithFileName>

128
stm32/USER/main.c

@ -27,13 +27,18 @@ struct UserInfo{ @@ -27,13 +27,18 @@ struct UserInfo{
int num;
float light;
int light_threshold;
int num_th1;
int num_th2;
int num_th3;
int warn;
};
struct UserInfo userInfo;
struct timing nowTime;
u8 Settime[6]={0x22,0x04,0x27,0x19,0x17,0x20}; // 设置时间 22年 03月 27日 22:34:00
u8 Settime[6]={0x22,0x04,0x27,0x19,0x17,0x00}; // 设置时间 22年 03月 27日 22:34:00
int setModel = 0;
int change = 0;
@ -54,6 +59,10 @@ void UserInfo_Init() @@ -54,6 +59,10 @@ void UserInfo_Init()
userInfo.light_threshold = AT24CXX_ReadOneByte(3) * 255 + AT24CXX_ReadOneByte(4);
userInfo.num = AT24CXX_ReadOneByte(5);
userInfo.warn = 1;
userInfo.num_th1 = AT24CXX_ReadOneByte(6);
userInfo.num_th2 = AT24CXX_ReadOneByte(7);
userInfo.num_th3 = AT24CXX_ReadOneByte(8);
}
/**
@ -90,7 +99,7 @@ void Sys_Init(void) @@ -90,7 +99,7 @@ void Sys_Init(void)
{
delay_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
uart_init(115200);
//uart_init(115200);
LED_Init();
DS18B20_Init();
AT24CXX_Init(); //IIC初始化
@ -104,7 +113,6 @@ void Sys_Init(void) @@ -104,7 +113,6 @@ void Sys_Init(void)
bh_data_send(BHPowOn);
}
/**
* @description:
* @param {*}
@ -113,10 +121,10 @@ void Sys_Init(void) @@ -113,10 +121,10 @@ void Sys_Init(void)
void DisplayTask(void)
{
char str[60];
if(userInfo.model == 0) sprintf(str,"%2d-%2d %2d:%2d:%2d %0.1fLx,%dLx %d num:%d", nowTime.mon, nowTime.day, nowTime.hour, nowTime.min, \
nowTime.sec, userInfo.light, userInfo.light_threshold, userInfo.warn, userInfo.num);
else sprintf(str,"%3dLx %2d:%2d:%2d %d", userInfo.light_threshold,userInfo.SetTimer.hour, userInfo.SetTimer.min, \
userInfo.SetTimer.sec, change);
if(userInfo.model == 0) sprintf(str,"%2d-%2d %2d:%2d:%2d %0.1fLx,%dLx %d %2d,%2d,%2d num:%2d ", nowTime.mon, nowTime.day, nowTime.hour, nowTime.min, \
nowTime.sec, userInfo.light, userInfo.light_threshold, userInfo.warn, userInfo.num_th1,userInfo.num_th2,userInfo.num_th3 , userInfo.num);
else sprintf(str,"%3dLx %2d:%2d:%2d %2d,%2d,%2d %d ", userInfo.light_threshold,userInfo.SetTimer.hour, userInfo.SetTimer.min, \
userInfo.SetTimer.sec, userInfo.num_th1,userInfo.num_th2,userInfo.num_th3, change);
OLED_ShowString(0, 0, str, 16);
};
@ -143,7 +151,7 @@ void ChangeValue(int Value){ @@ -143,7 +151,7 @@ void ChangeValue(int Value){
case 0:
if(userInfo.light_threshold < 1000){
userInfo.light_threshold = userInfo.light_threshold * 10 + Value;
if(userInfo.light_threshold > 390) userInfo.light_threshold = 390;
if(userInfo.light_threshold > 1000) userInfo.light_threshold = 1000;
}
break;
case 1:
@ -164,6 +172,24 @@ void ChangeValue(int Value){ @@ -164,6 +172,24 @@ void ChangeValue(int Value){
if(userInfo.SetTimer.sec > 59) userInfo.SetTimer.sec = 59;
}
break;
case 4:
if(userInfo.num_th1 < 10){
userInfo.num_th1 = userInfo.num_th1 * 10 + Value;
if(userInfo.num_th1 > 99) userInfo.num_th1 = 99;
}
break;
case 5:
if(userInfo.num_th2 < 10){
userInfo.num_th2 = userInfo.num_th2 * 10 + Value;
if(userInfo.num_th2 > 99) userInfo.num_th2 = 99;
}
break;
case 6:
if(userInfo.num_th3 < 10){
userInfo.num_th3 = userInfo.num_th3 * 10 + Value;
if(userInfo.num_th3 > 99) userInfo.num_th3 = 99;
}
break;
}
}
@ -188,6 +214,15 @@ void DeleteValue() @@ -188,6 +214,15 @@ void DeleteValue()
case 3:
userInfo.SetTimer.sec /= 10;
break;
case 4:
userInfo.num_th1 /= 10;
break;
case 5:
userInfo.num_th2 /= 10;
break;
case 6:
userInfo.num_th3 /= 10;
break;
}
}
@ -197,18 +232,21 @@ void DeleteValue() @@ -197,18 +232,21 @@ void DeleteValue()
* @return {*}
*/
void keyHandling(){
static int flag = 0;
int key = 16;
int i = 0;
key = Key_Scan();
switch (key)
{
case 12:
userInfo.model++;
if(userInfo.model >= 2) userInfo.model = 0;
change = 0;
break;
case 13:
if(userInfo.model == 0) break;
change++;
if(change >= 4) change = 0;
if(change >= 7) change = 0;
break;
case 14:
if(userInfo.warn == 0) userInfo.warn = 1;
@ -226,15 +264,44 @@ void keyHandling(){ @@ -226,15 +264,44 @@ void keyHandling(){
OLED_Clear();
Warning();
}
key = KEY_Scan(0);
if(key == IN_PRES){
if(IN == 0){
delay_ms(10);
if(IN == 0){
if(flag == 3) flag = 4;
else if(flag == 0) flag = 1;
else flag = 0;
}
while((i<50)&&(IN==0)){
delay_ms(10);
i++;
}
i=0;
}
if(OUT == 0){
delay_ms(10);
if(OUT == 0){
if(flag == 1) flag = 2;
else if(flag == 0) flag = 3;
else flag = 0;
}
while((i<50)&&(OUT==0)){
delay_ms(10);
i++;
}
i=0;
}
if(flag == 2){
userInfo.num++;
if(userInfo.num >= 99) userInfo.num = 99;
}
else if(key == OUT_PRES){
flag = 0;
}else if(flag == 4){
userInfo.num--;
if(userInfo.num < 0) userInfo.num = 0;
}
flag = 0;
}
}
@ -246,6 +313,7 @@ void keyHandling(){ @@ -246,6 +313,7 @@ void keyHandling(){
*/
void TaskProcessing()
{
static int flag = 0,min = 0, sec = 0;
int x=0, pwm; //bh1750模块获取到的数据
bh_data_send(BHReset);
bh_data_send(BHModeH1);
@ -254,20 +322,44 @@ void TaskProcessing() @@ -254,20 +322,44 @@ void TaskProcessing()
userInfo.light = x/1.2;
keyHandling();
PWMA = userInfo.light_threshold * 1.3;
if(userInfo.warn == 0) flag = 0;
// 超过时间报警
if(getTimerResult()){
if(getTimerResult() && userInfo.warn){
if(flag == 0) {
min = userInfo.SetTimer.min + 1;
sec = userInfo.SetTimer.sec;
if(min >= 60){
min = min - 60;
}
flag = 1;
}else{
if(min == nowTime.min && sec == nowTime.sec){
userInfo.warn = 0;
flag = 0;
}
}
if(userInfo.warn) Warning();
}
LED0 = 0;
LED1 = 0;
LED2 = 0;
if(userInfo.num >= userInfo.num_th1) LED0 = 1;
if(userInfo.num >= userInfo.num_th2) LED1 = 1;
if(userInfo.num >= userInfo.num_th3) LED2 = 1;
if(userInfo.light > userInfo.light_threshold) LED0 = 0,LED1 = 0,LED2 = 0;
AT24CXX_WriteOneByte(0, userInfo.SetTimer.hour);
AT24CXX_WriteOneByte(1, userInfo.SetTimer.min);
AT24CXX_WriteOneByte(2, userInfo.SetTimer.sec);
AT24CXX_WriteOneByte(3, userInfo.light_threshold >> 8);
AT24CXX_WriteOneByte(4, userInfo.light_threshold & 0x00FF);
AT24CXX_WriteOneByte(5, userInfo.num);
AT24CXX_WriteOneByte(6, userInfo.num_th1);
AT24CXX_WriteOneByte(7, userInfo.num_th2);
AT24CXX_WriteOneByte(8, userInfo.num_th3);
}
/**

Loading…
Cancel
Save