Browse Source

完成全部功能

master
htujun 3 years ago
parent
commit
f07e33cc10
  1. 171
      stm32/HARDWARE/ADC/adc.c
  2. 22
      stm32/HARDWARE/ADC/adc.h
  3. 4
      stm32/HARDWARE/DS18B20/ds18b20.c
  4. 9
      stm32/HARDWARE/DS18B20/ds18b20.h
  5. BIN
      stm32/OBJ/Template.axf
  6. 4
      stm32/OBJ/Template.build_log.htm
  7. 2031
      stm32/OBJ/Template.hex
  8. 927
      stm32/OBJ/Template.htm
  9. 15
      stm32/OBJ/Template_Target 1.dep
  10. BIN
      stm32/OBJ/adc.crf
  11. 3
      stm32/OBJ/adc.d
  12. BIN
      stm32/OBJ/adc.o
  13. BIN
      stm32/OBJ/ds18b20.crf
  14. BIN
      stm32/OBJ/ds18b20.o
  15. BIN
      stm32/OBJ/main.crf
  16. BIN
      stm32/OBJ/main.o
  17. 3
      stm32/USER/.vscode/keil-assistant.log
  18. 15
      stm32/USER/.vscode/uv4.log
  19. 2
      stm32/USER/.vscode/uv4.log.lock
  20. 1091
      stm32/USER/Template.map
  21. 81
      stm32/USER/Template.uvguix.QY
  22. 4
      stm32/USER/Template.uvoptx
  23. 23
      stm32/USER/main.c

171
stm32/HARDWARE/ADC/adc.c

@ -1,109 +1,86 @@
#include "adc.h" /*
#include "delay.h" * @Author: your name
* @Date: 2022-04-23 14:47:47
* @LastEditTime: 2022-04-26 21:25:14
#define ADC1_DR_Address ((u32)0x40012400+0x4c) * @LastEditors: your name
uint16_t ADC_ConvertedValue[3]; * @Description: koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
/******************************************************************************* * @FilePath: \USERe:\\\20220423-IndoorEnvSystem\stm32\HARDWARE\ADC\adc.c
* : ADCx_Init */
* : ADC初始化 #include "ADC.h"
* :
* : u32 ADC_SUM_BUF = 0;
*******************************************************************************/
void ADCx_Init(void) u16 ADC_AVG = 0;
void ADC_Init_MY(void)
{ {
GPIO_InitTypeDef GPIO_InitStructure; //定义结构体变量 GPIO_InitTypeDef GPIO_InitStructure;
ADC_InitTypeDef ADC_InitStructure; ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOA|RCC_APB2Periph_ADC1|RCC_APB2Periph_AFIO,ENABLE);
RCC_ADCCLKConfig(RCC_PCLK2_Div6);//设置ADC分频因子6 72M/6=12,ADC最大时间不能超过14M GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;//模拟输入
DMA_DeInit(DMA1_Channel1); GPIO_Init(GPIOA, &GPIO_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr =(u32)&ADC1->DR;
DMA_InitStructure.DMA_MemoryBaseAddr =(u32)&ADC_ConvertedValue; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
DMA_InitStructure.DMA_BufferSize = 2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;//模拟输入
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; GPIO_Init(GPIOA, &GPIO_InitStructure);
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;//adc模式独立模式
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; ADC_InitStructure.ADC_ScanConvMode = DISABLE;//扫描模式
DMA_InitStructure.DMA_Priority = DMA_Priority_High; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;//连续模式
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;//配置规则组触发模式软件出发
DMA_Init(DMA1_Channel1, &DMA_InitStructure); ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;//数据对其方式16位寄存器12位数据左对齐右对齐
DMA_Cmd(DMA1_Channel1, ENABLE); ADC_InitStructure.ADC_NbrOfChannel = 1;//规则通道序列长度
ADC_InjectedChannelConfig(ADC1,ADC_Channel_0,1,ADC_SampleTime_239Cycles5);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1;//ADC ADC_InjectedChannelConfig(ADC1,ADC_Channel_1,1,ADC_SampleTime_239Cycles5);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AIN; //模拟输入 ADC_Init(ADC1, &ADC_InitStructure);
//GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure); ADC_Cmd(ADC1,ENABLE);
//下面四个校准函数
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1;//ADC ADC_ResetCalibration(ADC1);//重置ADC校准寄存器
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AIN; //模拟输入 while(ADC_GetResetCalibrationStatus(ADC1));//等待重置结束
//GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; ADC_StartCalibration(ADC1);//开始校准ADC
GPIO_Init(GPIOB,&GPIO_InitStructure); while(ADC_GetCalibrationStatus(ADC1));//等待校准结束
ADC_DeInit(ADC1);//?? ADC1,?? ADC1,
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;//扫描模式
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;//开启连续转换
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;//禁止触发检测,使用软件触发
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;//右对齐
ADC_InitStructure.ADC_NbrOfChannel = 2;//1个转换在规则序列中 也就是只转换规则序列1
ADC_Init(ADC1, &ADC_InitStructure);//ADC初始化
ADC_DMACmd(ADC1, ENABLE);
ADC_Cmd(ADC1, ENABLE);//开启AD转换器
ADC_ResetCalibration(ADC1);//重置指定的ADC的校准寄存器
while(ADC_GetResetCalibrationStatus(ADC1));//获取ADC重置校准寄存器的状态
ADC_StartCalibration(ADC1);//开始指定ADC的校准状态
while(ADC_GetCalibrationStatus(ADC1));//获取指定ADC的校准程序
ADC_SoftwareStartConvCmd(ADC1, ENABLE);//使能或者失能指定的ADC的软件转换启动功能
} }
/******************************************************************************* u16 ADC_Get_Data(void)//获取adc某一通道一次转换结果
* : Get_ADC_Value
* : ch的转换值times次,
* : ch:
times:
* : ch的times次转换结果平均值
*******************************************************************************/
u16 Get_ADC_Value(u8 ch,u8 times)
{ {
u32 temp_val=0; ADC_ExternalTrigInjectedConvConfig(ADC1,ADC_ExternalTrigInjecConv_None);//配置注入组触发模式
u8 t; ADC_InjectedSequencerLengthConfig(ADC1, 1);//注入组长度
//设置指定ADC的规则组通道,一个序列,采样时间 ADC_InjectedChannelConfig(ADC1,ADC_Channel_0,1,ADC_SampleTime_239Cycles5);//配置规则通道
ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_239Cycles5); //ADC1,ADC通道,239.5个周期,提高采样时间可以提高精确度 ADC_SoftwareStartInjectedConvCmd(ADC1, ENABLE);//开启软件转换
while(!ADC_GetFlagStatus(ADC1,ADC_FLAG_JEOC)); // 清除转换结束标志位等待转换结束
return(ADC_GetInjectedConversionValue(ADC1,ADC_InjectedChannel_1));//得到转换结果
for(t=0;t<times;t++)
{
//ADC_SoftwareStartConvCmd(ADC1, ENABLE);//使能指定的ADC1的软件转换启动功能
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ));//等待转换结束
//temp_val+=ADC_GetConversionValue(ADC1);
temp_val+=ADC_ConvertedValue[0];
delay_ms(5);
}
return temp_val/times;
} }
u16 Get_ADC1_Value(u8 ch,u8 times) u16 ADC_Get_AVG_Data(void)
{ {
u32 temp_val=0; u16 i = 0;
u8 t; for(i = 0;i < 500;i++)
//设置指定ADC的规则组通道,一个序列,采样时间
ADC_RegularChannelConfig(ADC1, ch, 2, ADC_SampleTime_239Cycles5); //ADC1,ADC通道,239.5个周期,提高采样时间可以提高精确度
for(t=0;t<times;t++)
{ {
//ADC_SoftwareStartConvCmd(ADC1, ENABLE);//使能指定的ADC1的软件转换启动功能 ADC_SUM_BUF = ADC_SUM_BUF + ADC_Get_Data();
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ));//等待转换结束
//temp_val+=ADC_GetConversionValue(ADC1);
temp_val+=ADC_ConvertedValue[1];
delay_ms(5);
} }
return temp_val/times;
ADC_AVG = ADC_SUM_BUF /500;
ADC_SUM_BUF = 0;
return(ADC_AVG);
}
u16 ADC_Get_Data1(void)//获取adc某一通道一次转换结果
{
ADC_ExternalTrigInjectedConvConfig(ADC1,ADC_ExternalTrigInjecConv_None);//配置注入组触发模式
ADC_InjectedSequencerLengthConfig(ADC1, 1);//注入组长度
ADC_InjectedChannelConfig(ADC1,ADC_Channel_1,1,ADC_SampleTime_239Cycles5);//配置规则通道
ADC_SoftwareStartInjectedConvCmd(ADC1, ENABLE);//开启软件转换
while(!ADC_GetFlagStatus(ADC1,ADC_FLAG_JEOC)); // 清除转换结束标志位等待转换结束
return(ADC_GetInjectedConversionValue(ADC1,ADC_InjectedChannel_1));//得到转换结果
} }

22
stm32/HARDWARE/ADC/adc.h

@ -1,11 +1,17 @@
#ifndef _adc_H /*
#define _adc_H * @Author: your name
* @Date: 2022-04-23 14:47:47
* @LastEditTime: 2022-04-26 21:25:06
* @LastEditors: your name
* @Description: koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \USERe:\\\20220423-IndoorEnvSystem\stm32\HARDWARE\ADC\adc.h
*/
#ifndef _ADC_H_
#define _ADC_H_
#include "sys.h" #include "sys.h"
void ADCx_Init(void); void ADC_Init_MY(void);
u16 Get_ADC_Value(u8 ch,u8 times); u16 ADC_Get_Data(void);
u16 Get_ADC1_Value(u8 ch,u8 times); u16 ADC_Get_AVG_Data(void);
u16 ADC_Get_Data1(void);
#endif #endif

4
stm32/HARDWARE/DS18B20/ds18b20.c

@ -118,12 +118,12 @@ u8 DS18B20_Init(void)
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //使能PORTA口时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //使能PORTA口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PORTA0 推挽输出 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; //PORTA0 推挽输出
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_0); //输出1 GPIO_SetBits(GPIOA,GPIO_Pin_3); //输出1
DS18B20_Rst(); DS18B20_Rst();

9
stm32/HARDWARE/DS18B20/ds18b20.h

@ -23,11 +23,12 @@
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
//IO方向设置 //IO方向设置
#define DS18B20_IO_IN() {GPIOA->CRL&=0XFFFFFFF0;GPIOA->CRL|=8<<0;} #define DS18B20_IO_IN() {GPIOA->CRL&=0XFFFF0FFF;GPIOA->CRL|=8<<12;}
#define DS18B20_IO_OUT() {GPIOA->CRL&=0XFFFFFFF0;GPIOA->CRL|=3<<0;} #define DS18B20_IO_OUT() {GPIOA->CRL&=0XFFFF0FFF;GPIOA->CRL|=3<<12;}
////IO操作函数 ////IO操作函数
#define DS18B20_DQ_OUT PAout(0) //数据端口 PA0 #define DS18B20_DQ_OUT PAout(3) //数据端口 PA0
#define DS18B20_DQ_IN PAin(0) //数据端口 PA0 #define DS18B20_DQ_IN PAin(3) //数据端口 PA0
u8 DS18B20_Init(void); //初始化DS18B20 u8 DS18B20_Init(void); //初始化DS18B20
short DS18B20_Get_Temp(void); //获取温度 short DS18B20_Get_Temp(void); //获取温度

BIN
stm32/OBJ/Template.axf

Binary file not shown.

4
stm32/OBJ/Template.build_log.htm

@ -38,7 +38,7 @@ main.c(78): warning: #993-D: subtraction of pointer types "char *" and "u8 *" i
target2 = strstr((const char*)USART_RX_BUF, ")") - USART_RX_BUF; target2 = strstr((const char*)USART_RX_BUF, ")") - USART_RX_BUF;
main.c: 4 warnings, 0 errors main.c: 4 warnings, 0 errors
linking... linking...
Program Size: Code=16092 RO-data=376 RW-data=60 ZI-data=1348 Program Size: Code=15508 RO-data=384 RW-data=64 ZI-data=1344
FromELF: creating hex file... FromELF: creating hex file...
"..\OBJ\Template.axf" - 0 Error(s), 4 Warning(s). "..\OBJ\Template.axf" - 0 Error(s), 4 Warning(s).
@ -54,7 +54,7 @@ Package Vendor: Keil
D:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include D:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include
<h2>Collection of Component Files used:</h2> <h2>Collection of Component Files used:</h2>
Build Time Elapsed: 00:00:01 Build Time Elapsed: 00:00:00
</pre> </pre>
</body> </body>
</html> </html>

2031
stm32/OBJ/Template.hex

File diff suppressed because it is too large Load Diff

927
stm32/OBJ/Template.htm

File diff suppressed because it is too large Load Diff

15
stm32/OBJ/Template_Target 1.dep

@ -1,5 +1,5 @@
Dependencies for Project 'Template', Target 'Target 1': (DO NOT MODIFY !) Dependencies for Project 'Template', Target 'Target 1': (DO NOT MODIFY !)
F (.\main.c)(0x6266BEB9)(-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\DCmotor -I ..\HARDWARE\DS1302 -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) F (.\main.c)(0x626DFA39)(-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\DCmotor -I ..\HARDWARE\DS1302 -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)(0x6266AADD) I (..\HARDWARE\LED\led.h)(0x6266AADD)
I (..\SYSTEM\sys\sys.h)(0x550F951B) I (..\SYSTEM\sys\sys.h)(0x550F951B)
I (..\USER\stm32f10x.h)(0x5E83791A) I (..\USER\stm32f10x.h)(0x5E83791A)
@ -36,10 +36,10 @@ I (D:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x599ECD2C)
I (..\HARDWARE\ESP8266\wifi.h)(0x5E5164A3) I (..\HARDWARE\ESP8266\wifi.h)(0x5E5164A3)
I (..\HARDWARE\DHT11\dht11.h)(0x62525B1C) I (..\HARDWARE\DHT11\dht11.h)(0x62525B1C)
I (..\HARDWARE\LCD1602\lcd1602.h)(0x5D0BE688) I (..\HARDWARE\LCD1602\lcd1602.h)(0x5D0BE688)
I (..\HARDWARE\ADC\adc.h)(0x6266B913) I (..\HARDWARE\ADC\adc.h)(0x6267F2B3)
I (..\HARDWARE\TIMER\timer.h)(0x532BBAA7) I (..\HARDWARE\TIMER\timer.h)(0x532BBAA7)
I (D:\Keil_v5\ARM\ARMCC\include\string.h)(0x599ECD2C) I (D:\Keil_v5\ARM\ARMCC\include\string.h)(0x599ECD2C)
I (..\HARDWARE\DS18B20\ds18b20.h)(0x6255C13A) I (..\HARDWARE\DS18B20\ds18b20.h)(0x626DF9B9)
I (D:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x599ECD2C) I (D:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x599ECD2C)
I (..\HARDWARE\DCmotor\motor.h)(0x625A6ACE) I (..\HARDWARE\DCmotor\motor.h)(0x625A6ACE)
F (.\stm32f10x_it.c)(0x4EBEACB0)(-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\DCmotor -I ..\HARDWARE\DS1302 -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\stm32f10x_it.o --omf_browse ..\obj\stm32f10x_it.crf --depend ..\obj\stm32f10x_it.d) F (.\stm32f10x_it.c)(0x4EBEACB0)(-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\DCmotor -I ..\HARDWARE\DS1302 -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\stm32f10x_it.o --omf_browse ..\obj\stm32f10x_it.crf --depend ..\obj\stm32f10x_it.d)
@ -231,8 +231,8 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x4D783BB4)
I (..\STM32F10x_FWLib\inc\misc.h)(0x4D783BB4) I (..\STM32F10x_FWLib\inc\misc.h)(0x4D783BB4)
I (..\SYSTEM\delay\delay.h)(0x55CC2E59) I (..\SYSTEM\delay\delay.h)(0x55CC2E59)
I (..\SYSTEM\sys\sys.h)(0x550F951B) I (..\SYSTEM\sys\sys.h)(0x550F951B)
F (..\HARDWARE\ADC\adc.c)(0x6266BABA)(-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\DCmotor -I ..\HARDWARE\DS1302 -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\adc.o --omf_browse ..\obj\adc.crf --depend ..\obj\adc.d) F (..\HARDWARE\ADC\adc.c)(0x6267F2BB)(-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\DCmotor -I ..\HARDWARE\DS1302 -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\adc.o --omf_browse ..\obj\adc.crf --depend ..\obj\adc.d)
I (..\HARDWARE\ADC\adc.h)(0x6266B913) I (..\HARDWARE\ADC\ADC.h)(0x6267F2B3)
I (..\SYSTEM\sys\sys.h)(0x550F951B) I (..\SYSTEM\sys\sys.h)(0x550F951B)
I (..\USER\stm32f10x.h)(0x5E83791A) I (..\USER\stm32f10x.h)(0x5E83791A)
I (..\CORE\core_cm3.h)(0x4D523B58) I (..\CORE\core_cm3.h)(0x4D523B58)
@ -262,7 +262,6 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_tim.h)(0x4D783BB4)
I (..\STM32F10x_FWLib\inc\stm32f10x_usart.h)(0x504F415E) I (..\STM32F10x_FWLib\inc\stm32f10x_usart.h)(0x504F415E)
I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x4D783BB4) I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x4D783BB4)
I (..\STM32F10x_FWLib\inc\misc.h)(0x4D783BB4) I (..\STM32F10x_FWLib\inc\misc.h)(0x4D783BB4)
I (..\SYSTEM\delay\delay.h)(0x55CC2E59)
F (..\HARDWARE\TIMER\timer.c)(0x5E565583)(-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\DCmotor -I ..\HARDWARE\DS1302 -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\timer.o --omf_browse ..\obj\timer.crf --depend ..\obj\timer.d) F (..\HARDWARE\TIMER\timer.c)(0x5E565583)(-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\DCmotor -I ..\HARDWARE\DS1302 -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\timer.o --omf_browse ..\obj\timer.crf --depend ..\obj\timer.d)
I (..\HARDWARE\TIMER\timer.h)(0x532BBAA7) I (..\HARDWARE\TIMER\timer.h)(0x532BBAA7)
I (..\SYSTEM\sys\sys.h)(0x550F951B) I (..\SYSTEM\sys\sys.h)(0x550F951B)
@ -296,8 +295,8 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x4D783BB4)
I (..\STM32F10x_FWLib\inc\misc.h)(0x4D783BB4) I (..\STM32F10x_FWLib\inc\misc.h)(0x4D783BB4)
I (..\HARDWARE\LED\led.h)(0x6266AADD) I (..\HARDWARE\LED\led.h)(0x6266AADD)
I (..\HARDWARE\ESP8266\wifi.h)(0x5E5164A3) I (..\HARDWARE\ESP8266\wifi.h)(0x5E5164A3)
F (..\HARDWARE\DS18B20\ds18b20.c)(0x6255C148)(-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\DCmotor -I ..\HARDWARE\DS1302 -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) F (..\HARDWARE\DS18B20\ds18b20.c)(0x626DF9CC)(-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\DCmotor -I ..\HARDWARE\DS1302 -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)
I (..\HARDWARE\DS18B20\ds18b20.h)(0x6255C13A) I (..\HARDWARE\DS18B20\ds18b20.h)(0x626DF9B9)
I (..\SYSTEM\sys\sys.h)(0x550F951B) I (..\SYSTEM\sys\sys.h)(0x550F951B)
I (..\USER\stm32f10x.h)(0x5E83791A) I (..\USER\stm32f10x.h)(0x5E83791A)
I (..\CORE\core_cm3.h)(0x4D523B58) I (..\CORE\core_cm3.h)(0x4D523B58)

BIN
stm32/OBJ/adc.crf

Binary file not shown.

3
stm32/OBJ/adc.d

@ -1,5 +1,5 @@
..\obj\adc.o: ..\HARDWARE\ADC\adc.c ..\obj\adc.o: ..\HARDWARE\ADC\adc.c
..\obj\adc.o: ..\HARDWARE\ADC\adc.h ..\obj\adc.o: ..\HARDWARE\ADC\ADC.h
..\obj\adc.o: ..\SYSTEM\sys\sys.h ..\obj\adc.o: ..\SYSTEM\sys\sys.h
..\obj\adc.o: ..\USER\stm32f10x.h ..\obj\adc.o: ..\USER\stm32f10x.h
..\obj\adc.o: ..\CORE\core_cm3.h ..\obj\adc.o: ..\CORE\core_cm3.h
@ -30,4 +30,3 @@
..\obj\adc.o: ..\STM32F10x_FWLib\inc\stm32f10x_usart.h ..\obj\adc.o: ..\STM32F10x_FWLib\inc\stm32f10x_usart.h
..\obj\adc.o: ..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h ..\obj\adc.o: ..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h
..\obj\adc.o: ..\STM32F10x_FWLib\inc\misc.h ..\obj\adc.o: ..\STM32F10x_FWLib\inc\misc.h
..\obj\adc.o: ..\SYSTEM\delay\delay.h

BIN
stm32/OBJ/adc.o

Binary file not shown.

BIN
stm32/OBJ/ds18b20.crf

Binary file not shown.

BIN
stm32/OBJ/ds18b20.o

Binary file not shown.

BIN
stm32/OBJ/main.crf

Binary file not shown.

BIN
stm32/OBJ/main.o

Binary file not shown.

3
stm32/USER/.vscode/keil-assistant.log vendored

@ -6,3 +6,6 @@
[info] Log at : 2022/4/25|22:10:40|GMT+0800 [info] Log at : 2022/4/25|22:10:40|GMT+0800
[info] Log at : 2022/4/26|21:02:00|GMT+0800
[info] project closed: Template

15
stm32/USER/.vscode/uv4.log vendored

@ -1,13 +1,2 @@
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin' Load "..\\OBJ\\Template.axf"
Build target 'Target 1' Erase Done.Programming Done.Verify OK.Flash Load finished at 21:29:01
compiling adc.c...
linking...
..\OBJ\Template.axf: Error: L6218E: Undefined symbol DMA_Cmd (referred from adc.o).
..\OBJ\Template.axf: Error: L6218E: Undefined symbol DMA_DeInit (referred from adc.o).
..\OBJ\Template.axf: Error: L6218E: Undefined symbol DMA_Init (referred from adc.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 3 error messages.
"..\OBJ\Template.axf" - 3 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01

2
stm32/USER/.vscode/uv4.log.lock vendored

@ -1 +1 @@
2022/4/25 23:07:52 2022/4/26 21:29:01

1091
stm32/USER/Template.map

File diff suppressed because it is too large Load Diff

81
stm32/USER/Template.uvguix.QY

File diff suppressed because one or more lines are too long

4
stm32/USER/Template.uvoptx

@ -307,7 +307,7 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>8</FileNumber> <FileNumber>8</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\HARDWARE\ADC\adc.c</PathWithFileName> <PathWithFileName>..\HARDWARE\ADC\adc.c</PathWithFileName>
@ -331,7 +331,7 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>10</FileNumber> <FileNumber>10</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\HARDWARE\DS18B20\ds18b20.c</PathWithFileName> <PathWithFileName>..\HARDWARE\DS18B20\ds18b20.c</PathWithFileName>

23
stm32/USER/main.c

@ -56,12 +56,12 @@ void Data_Deal()
{ {
u16 adcx; u16 adcx;
userInfo.temp_value = DS18B20_Get_Temp() / 10; userInfo.temp_value = DS18B20_Get_Temp() / 10;
adcx = Get_ADC1_Value(ADC_Channel_9,20); adcx = ADC_Get_Data();
userInfo.smog = (float)adcx*(3.3/4096); userInfo.smog = (float)adcx*(100.0/4096);
adcx = Get_ADC_Value(ADC_Channel_1,20); adcx = ADC_Get_Data1();
userInfo.PoisonousGas = (float)adcx*(3.3/4096); userInfo.PoisonousGas = (float)adcx*(100.0/4096);
if(getResult()) Warning(); if(getResult()) Warning();
else BEEP = 0; else BEEP = 1;
} }
@ -87,20 +87,22 @@ void Receive_data(void)
{ {
// 接受到数据 // 接受到数据
if(USART_RX_STA & 0x8000){ if(USART_RX_STA & 0x8000){
// 模式切换 // 模式切换
if(strstr((const char*)USART_RX_BUF, "getInfo") != NULL){ if(strstr((const char*)USART_RX_BUF, "getInfo") != NULL){
printf("temp:%d, temp_threshold:%d,smog:%0.2f, PoisonousGas%0.2f, smog_threshold:%d, PoisonousGas_threshold:%d\r\n", \ printf("temp:%d C,temp_threshold:%dC,smog:%0.2f%%,smog_threshold:%d%%, PoisonousGas:%0.2f%%, PoisonousGas_threshold:%d%%\r\n", \
userInfo.temp_value,userInfo.temp_threshold, userInfo.smog, userInfo.PoisonousGas, userInfo.smog_threshold, userInfo.PoisonousGas_threshold); userInfo.temp_value,userInfo.temp_threshold, userInfo.smog, userInfo.smog_threshold,userInfo.PoisonousGas,userInfo.PoisonousGas_threshold);
} }
if(strstr((const char*)USART_RX_BUF, "setTemp") != NULL){ if(strstr((const char*)USART_RX_BUF, "setTemp") != NULL){
userInfo.temp_threshold = getValue(); userInfo.temp_threshold = getValue();
printf("setTemp OK\r\n");
} }
if(strstr((const char*)USART_RX_BUF, "setSmog") != NULL){ if(strstr((const char*)USART_RX_BUF, "setSmog") != NULL){
userInfo.smog_threshold = getValue(); userInfo.smog_threshold = getValue();
printf("setSmog OK\r\n");
} }
if(strstr((const char*)USART_RX_BUF, "setPoisonousGas") != NULL){ if(strstr((const char*)USART_RX_BUF, "setPoisonousGas") != NULL){
userInfo.PoisonousGas_threshold = getValue(); userInfo.PoisonousGas_threshold = getValue();
printf("setPoisonousGas OK\r\n");
} }
memset(USART_RX_BUF, 0, sizeof(USART_RX_BUF)); memset(USART_RX_BUF, 0, sizeof(USART_RX_BUF));
USART_RX_STA = 0x00; USART_RX_STA = 0x00;
@ -115,7 +117,7 @@ void Sys_Init(void)
uart_init(115200); uart_init(115200);
LED_Init(); LED_Init();
DS18B20_Init(); DS18B20_Init();
ADCx_Init(); ADC_Init_MY();
userInfo.temp_threshold = 28; userInfo.temp_threshold = 28;
userInfo.smog_threshold = 28; userInfo.smog_threshold = 28;
@ -128,11 +130,12 @@ int main(void)
BEEP = 0; BEEP = 0;
delay_ms(1000); delay_ms(1000);
BEEP = 1; BEEP = 1;
printf("start"); printf("start\r\n");
while(1) while(1)
{ {
Data_Deal(); Data_Deal();
Receive_data(); Receive_data();
delay_ms(100);
} }
} }

Loading…
Cancel
Save