版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
11STM32GPIO1 STM32GPIO/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*//*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*//*Privtedfine*//*USERCODEBEGINPD*///色defineBEEPCN且qIitePin(CPIGPI罕 1,(千IOPIN芷扣efineBEEP_Q工坚 I陌te_i;(I,I型 1,J..型 —声岱ER0立 PD*/在主函数while循环里补充有关蜂鸣器发声的代码:/*Infiniteloop*//*岱ERCCIEBEGN旧LE*/曲ile(1){P" 鸟压Ia.(200); I" BEEPCFF· 」— '业斗_氏I_ay(2500)_;』/*岱ERCCIEEND旧LE*/岱ER画 N3*/}/*岱ERCCIEEND3*/项目2 码管模拟显示温度补充代码随堂笔记展开项代码main.c在方框中头文tml650.h添加的数值(,例如36.5摄度对应数值为365:#include"rmin.h"#include"gpio.h"令2喝/*Privteicludes*//*USERCODEBEGINIncludes*/#include"tm160.h"/*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*//*Privtedfine*//*USERCODEBEGINPD*//*USERCODEENDPD*//*Privtemcro*//*USERCODEBEGINPM*//*USERCODEENDPM*//*Privtevriables*//*USERCODEBEGINPV*//*USERCODEENDPV*//*Privtefnctionprototypes*/voidSyteCock_Cnfg(void);3/*USERCODEBEGINPFP*//*USERCODEENDPFP*//*Privteuercode*//*USERCODEBEGIN0*//*USERCODEEND0*//**@brefTheapplitionetrypoint.@retvalint*/intmai(voi){/*USRCODEBEGIN1//*USERCODEEND1*//*MCUConfiguatio*//*Reetofallprpherals,niializstheFlashinterfaeandtheSystick.*/HAL_Iit(;/*USRCODEBEGINnit*//*USERCODEENDInit*//*Cofiguretheytemclock*/SysteClok_Cofi();/*USRCODEBEGINysInit*/4/*USRCODEENDyInit*//*Initializeallconfiguredperipherals*/MX_GPO_Iit();/*USRCODEBEGIN2*//*USERCODEEND2*//*Infiniteloop*//*USRCODEBEGINHILE*/Disply_Iit();//while(1){Disply_Tmp(365,);// HAL_Dlay1000); // *USRCODEENDHLE*/*USRCODEBEGN3*/}/*USERCODEEND3*/}/*Infiniteloop*//*USRCODEBEGINHILE*/#incldetm16.h"uint8_tdata_nu[10]{0x3f,x6,0x5b,0xf,x66,06d0x7d,0x7,0x7f,0x6};//uint8_tdata_alphabet[6]={0x77,0x7c,0x39,0x5e,0x79,0x71};//a-f5uint8_tdispy_adres[4={06e,x6c,0xa,x68};//uint8_tdisplaybrigtness[8]={0x11,021,031,0x1,x51,0x61,0x71,0x01;//-7voidDiplySend_ata(uint8_taddess,uint_tdata){uint8_tbuff=0;TIM_SCL_1;TIM_SDA_1;delay_us(1);TIM_SDA_0;delay_us(1);TIM_SCL_0;delay_us(2);for(uint8ti=0;i8;i++){buff=(addess>>(-i))&01);// ;;}if(buff==1){TIif(buff==1){TIM_SDA1}{TIM_SDA0}TIM_SCL0;delay_us(1);TIM_SCL1;delay_us(1);TIM_SCL0;delay_us(1);TIM_SCL1;delay_us(2);TIM_SCL_0;delay_us(2);for(uint8ti=0;i8;i++){buff=(data>>(-))&001;if(buff==1){TIM_SDA1;}else{TIM_SD_0;}TIM_SCL_0;delay_us(1);TIM_SCL_1;delay_us(1);TIM_SCL_0;delay_us(1);}TIM_SCL_1;delay_us(1);TIM_SCL_0;delay_us(1);TIM_SCL1;TIM_SDA0; TIM_SDA1; delay_us(1);}73 ADC /*USERCODEENDHeader*//*Includes*/#include"mainh"#include"adc."#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*//*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*//*Privtedfine*//*USERCODEBEGINPD*///1~3200220029000180025008#defineADC_KEY1_MAX 200#defineAD_KY_MIN 0#defineADC_KEY2_MAX 2200#defineAD_KY_MIN 1800#defineADC_KEY3_MAX 2900#defineAD_KY_MIN 2500#defineBEEP_ONHAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET)//#defineBEEP_OFFHAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET)///*USERCODEENDPD*//*Privtemcro*//*USERCODEBEGINPM*//*USERCODEENDPM*//*Privtevriables*//*USERCODEBEGINPV*//*USERCODEENDPV*//*Privtefnctionprototypes*/voidSyteCock_Cnfg(void);/*USERCODEBEGINPFP*/9/*USERCODEENDPFP*/HAL_Ini();/*USRCODEBEGINnit*//*USERCODEENDInit*//*Cofiguretheytemclock*/SysteClok_Cofi();/*USRCODEBEGINysInit*//*USRCODEENDyInit*//*Initializeallconfiguredperipherals*/MX_GPO_Iit();MX_AD1_Iit();/*USRCODEBEGIN2*/uint16_tadc_value=0;/*USERCODEEND2*//*Infiniteloop*//*USRCODEBEGINHILE*/BEEP_FF;while(1){HAL_ADCStar(&had1);// ADCHAL_Dely(10;adc_vale=L_AD_GtVaue(hadc);// ADC if(adcalue>=AD_KY1_MIN&&ad_value=ADC_KEY_MAX)//{ BEEP_ON;} elseifadc_lue=DC_EY2MIN&adcvalue<=10ADC_KEY_MAX) //{BEEP_OF;}elseifadc_lue=DC_EY3MIN&&adcvaue<=*USRCODEENDHLE*/*USRCODEBEGN3*/}/*USERCODEEND3*/}/**@brefystemCockConfiuation@retvalNone*/voidSyteCock_Cnfg(void){RCC_OscIitTypeDefRCC_OscIitStruct={0;RCC_CkInitTypeDefRCC_ClkIitStruct={0;RCC_PriphCLKInityeDefPeriphCkInit=0;/**IitializesteRCCOscilatrsacodingtohespecifidpaametersinheCC_OcIitTypeDefsructure.*/RCC_OcIntStrct.OscilatorType=RCC_OSCLLATRTYPE_HSE;RCC_OcIntStrct.HSEStte=RCC_SE_O;RCC_OcIntStrct.HSEPrdivValue=RC_SEPREDIV_DV1;RCC_OcIntStrct.HSIStte=RCC_SI_O;RCC_OcIntStrct.PLL.PLLSte=RCC_PL_N;RCC_OsIntStrct.PLL.PLLSrce=RCC_LLOURCE_H;RCC_OcIntStrct.PLL.PLLMUL=RC_PLLMU9;ADC_KEADC_KEY_MAX) //{BEEP_OF;}if(HAL_RC_OsConfg&RCC_scIntStrut)!=HAL_K){Error_andlr();}/**IitializesteCPU,AHBndAPBbssclocks*/RCC_CkIntStrct.Clockype=RCC_CLOKTYP_HCLK|RCC_CLOCKTPE_SSCLK|RCC_CLCKTYE_PCLK1|RCC_CLOCTYPEPCLK2;RCC_CkIntStrct.SYSCLSource=RCC_SYSLKSORCE_PLLCLK;RCC_CkIntStrct.AHBCLDivider=RCC_YSLK_DIV1;RCC_CkIntStrct.APB1CKDivider=RCHCK_DIV2;RCC_CkIntStrct.APB2CKDivider=RCHCK_DIV1;if(HAL_RC_ClckCofg(&RC_ClknitStuc,FLASH_LTENC_2)!=HAL_OK){Error_andlr();}PeripClknit.eriplockSeectin=RCCPRIPHCLKADC;PeriphClknit.dcClkSelecion=RCC_DCCLK2_DI;if(HAL_RCEx_eripCKConfg(&PriphCkIit)!=HAL_OK){Error_andlr();}}124 oledfont.h/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"i2c."#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*/#include"olediic.h"#include"oledont.h"/*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*//*Privtedfine13*//*USERCODEBEGINPD*//*USERCODEENDPD*/intmai(voi){/*USRCODEBEGIN1*//*USERCODEEND1*//*MCUConfiguatio*//*Reetofallprpherals,niializstheFlashinterfaeandtheSystick.*/HAL_Iit(;/*USRCODEBEGINnit*//*USERCODEENDInit*//*Cofiguretheytemclock*/SysteClok_Cofi();/*USRCODEBEGINysInit*//*USERODEENDSysIit*//*Initializeallconfiguredperipherals*/MX_GPO_Iit();MX_I22_Iit();/*USRCODEBEGIN2*///OLEDOLED_Int();//14OLED_CL();//OLEDOLED_ShwStr0,0,(uint8t*)chenousen",2);/*USERCODEEND2*//*Infiniteloop*//*USRCODEBEGINHILE*/while(1){*USRCODEENDHLE*/*USRCODEBEGN3*/}/*USERCODEEND3*/}#include"olediic.h"#include"oledont.h"#include"mainh"#include"dela.h"voidWrtemd(uinttI2C_Comand)/{HAL_I2CMem_rite(hic2,OLED0561_ADD,CO,IC_MEMADD_SIZE_8IT,&2C_Comman,1,100);}inlineoidritet(int8tI2C_Daa)//{HAL_I2CMem_rite(hic2,OLED0561_ADD,DA,IC_MEMADD_SIZE_8IT,&2C_Data,1,100);}voidOLD_nt(voi){delay_m(100;// 15WriteCm(0xA);//isayoff WriteCm(0x2);//SetMmoryddresigMdeWriteCm(0x1);//00,HoizonalAddressingMode;01VertcalAdrssingMde;10PageddressingMode(RESET)11,Ivalid WriteCm(0xb);//SetPgeSartAddressforageAddressngMde,0-7 WriteCm(0xc);//SetCMOuputScanDirectinWriteCm(0x0);//--etlwolumnaddrss WriteCm(0x1);//--ethghcolunaddessWriteCm(0x4);//-ststartlineadres WriteCm(0x8);//-stcontrstcntolreisterWriteCm(0xf);// 0x00~0xff WriteCm(0xa);//-stsegmetremap0to127WriteCm(0xa);//-stnormaldislay WriteCm(0xa);//-stmultilexato(1to64)WriteCm(0x3);// WriteCm(0xa);//xaOutputfollwsRAMcontent0xa5OutputignoresRMcotent WriteCm(0xd);//setdsplayoffetWriteCm(0x0);//notofset WriteCm(0xd);//-stdisplyclckdiideratio/oscillatorfrequencyWriteCm(0xf);//-stdividerato WriteCm(0xd);//-stpre-cargeperiodWriteCm(0x2);// WriteCm(0xd;//-stcompnsrdwareconfigurationWriteCm(0x1); WriteCm(0xd);//-stvcomhWriteCm(0x2);//x20.77xVc WriteCm(0x8);//-stDC-DCenbeWriteCm(0x1);// WriteCm(0xa);//-trnonoedpnel}OEDvoidOLD_ePos(uint_tx,uint8ty)//{16WriteCm(0xb+y);WriteCm(((x0xf0)>4|0x10);WriteCm((x&x0f)|x0);}voidOLD_il(uint8tfillDta)//OLED{uint8_tm,n;for(m=0<8;m++){WriteCm(0xb+m);WriteCd(0x00);WriteCm(0x1);for(n=0<128;n++){WriteDa(fill_Data;}}}void{OLED_Fil(0x0);}//OLEDvoidOLD_Nvoid){WriteCm(0X8); WriteCm(0X1); WriteCm(0XA);}//OLEDvoidOLD_FF(void){WriteCm(0X8); WriteCm(0X1); WriteCm(0XA);17}55oled_iic.holedfont.h bluetooth.h string.h/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"adc."#include"dma."#include"i2c."#include"usart.h"#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*/#include"olediic.h"#include"oledont.h"#include"blueooth.h"#include"stdi.h"#include"strig.h"/*USERCODEENDIncludes*//*Privtetpedef*/18//*USERCODEBEGINPTD*//*USERCODEENDPTD*/点开bluetooth.c,在下面方框中添加初始化蓝牙模块、蓝牙发送函数、DMA函数:#include"blueooth.h"#include"strig.h"uint8_tBLE_ceive_uffBUF_SIZ_BE_EC];uint16_tBLEreceie_ize;uint8_tBLE_nd_bffBUF_SIE_BL_SND;uint16_tBLEsend_iz;voidBL_Iit()//初始化蓝牙模块{//包括开启空闲中断和开启DMA接收HAL_URT_EABLE_T(UART_BLE,UART_IT_DL); HAL_UAR_Recive_DA(UART_BLE,(uint8_*)BLrecevc_buff,UFF_IZ_BE_EC);} inlineoidLE_sd(int8t*messae,uit1tsize){//串口发送数据至蓝牙,蓝牙传输数据至手机HAL_UART_Transmit(&UART_BLE,message,size,TIME_OUT_BLE);}voidJudge_DMA_IDLE_BLE()//处理空闲中断相关消息,将次函数放于中断中或者回调函数中{if(__H_UAR_GET_LA(&UART_BL,ART_FLA_IDLE)!=RESET)/判断是否为空闲中断{扣心19HAL_URT_CEAR_ILELAG(&UART_BLE);//HAL_UAR_DMAtop(&AR_BLE);/BLE_recive_ize=BUF_SIZE_BLE_REC-HAL_DA_GE_COUNTER(&UART_DA_BL_HANDE);//Deal_Daa_BL();//HAL_UAR_Recive_DA(UART_BLE,(uint8_*)BLrecevc_buff,UFF_IZ_BE_EC);}}voidDel_aa_BLE){//BLE_sen((uit8t*)BL_eceive_buf,BLEreeie_size);}206 Chuankou.h/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"dma."#include"usar.h"#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*/#include"Chuakou.h"/*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*/#include"Chuakou.h"uint8_tUARTrecevc_buf[BFF_SZEUAT1_REC];21uint16_tUAR1_reciv_siz;uint8_tUARTsendbuf[BFF_IZE_AR1_END];uint16_tUAR1_sen_sze;voidUAT1Iit() //{//HAL_URT_EABLE_IT(&UART_UAT1,ART_I_ILE);//DMAHAL_UAR_Recive_DMA(&UART_UAT1,(uint8_*)UA1_reeice_buff,BUF_SZEUAT1_RC);}inlineoidART1end(uint8_t*mesage,in16tsize){//HAL_UAR_Trasmit(UAT_UART1,message,sie,IME_OUT_UART1);}voidJugeDA_IDL_UR1(){if(__H_UAR_GET_LA(&UART_UAT1,UART_FLG_IDE)!=EST)//{HAL_URT_CEAR_ILELAG(&UART_UART1);/HAL_UAR_DMAtop(&AR_UART1);//UART1_rceiv_size=UF_SIZ_UAR1REC-HAL_DA_GE_COUNTER(&UART_DA_UAT1_HADL);//Deal_Daa_UAT1();/HAL_UAR_Recive_DA(UART_UART1,(uint8_*)UA1_reeice_buff,BUF_SZEUAT1_REC);// }22}voidDel_aa_UAR1()//{UART1_snd(URT1_rcevce_buff,UART1_reciv_size); // }77WiFiuart.hstring.h#ifndefINC_P12SH_#defineINC_P12SH_#include"uarth"#include"stdi.h"#include"strig.h"voidCratcServer(constchar*Nae,costchar*Pass,constchar*ort);#endifstring.hU2#ifndefINC_RT_H_#defineINC_RT_H_23#include"usar.h"#include"strig.h"externMA_HdleTpeefhdma_usrt1_x;externMA_HdleTpeefhdma_usrt2_x;#defineUART_U1 huart1#defineUART_U2 huart2#defineUART_DMA_U1_HANDLEhdma_usart1_rx#defineUART_DMA_U2_HANDLEhdma_usart2_rx#defineTIMEUT_U1 100#defineTIMEUT_U2 100//U2#defineBUFFIZE_U1_REC 64#defineBUFFIZE_2_EC 64#include"ESP1S.h"#include"mainh"externint8tU2_ecivce_buf[UF_SIZ_UREC];voidCratcServer(constchar*Nae,costchar*Pass,constchar*ort){uint8_tbuf[64];U2_send(uint8t*"A\r\n",4;//AT24while(!trst((consthar*)U2eceivce_bff(constchar*)"OK")); //ESP12HAL_Dely(50);U2_send(uint8t*"A+CMODE2\r\",13);while(!trst((consthar*)U2eceivce_bff(constchar*)"OK"));HAL_Dely(50);U2_send(uint8t*"A+RT\r\",8);//HAL_Dely(200);strcpy(char*)bu,"AT+CSAP=\"");strcat(char*)bu,(onstchr*)Nam);strcat(char*)bu,(onstchr*)"\",\"";strcat(char*)bu,(onstchr*)Pas);strcat(char*)bu,(onstchr*)"\",1,3r\");HAL_Dely(50);U2_send(uint8t*bu,strle((costchr*)buf);//WIFImemset(buf,,sizeo(bf);while(!trst((consthar*)U2eceivce_bff(constchar*)"OK"));HAL_Dely(50);U2_send(uint8t*)"AT+PAP="19268.1.1\",\192.8.1.1\",\"255255.255.0\"\\n",strlen(AT+CAP=\"192.18.1.1\",\192.8..1\",\"255.255.2550\"\\n"));//WiFiIPwhile(!trst((consthar*)U2eceivce_bff,(constchar*)"OK"));U1 voidUSRTIit() //25{HAL_URT_EABLE_T(UART_U1,UART_IT_ILE;// //UARTMA_U_HANDE.ferCpltalbck=DMA_Recive_chieved;HAL_URT_EABLE_T(UART_U2,UART_IT_ILE;// //UART_MA_U_HANDLE.XferCpltallbck=DMA_Recive_chevd;}/***/inlineoid1_sed(uint8t*essae,uint1tsize){HAL_UAR_Trasmit(UAT_U1,message,size,IM_OUT_U1);}inlineoid2_sed(uint8t*essae,uint1tsize){HAL_UAR_Trasmit(UAT_U2,message,size,IM_OU_U2);}intmai(voi){/*USRCODEBEGIN1*/HAL_UAR_ReHAL_UAR_Recive_DA(UART_U1,(uint8_*)U1eceicebuff,BFF_SZEU1RE);// DMAHAL_UAR_Recive_DA(UART_U2,(uint8_*)U2eceicebuff,BFF_SZEU2RE);// DMA/*USERCODEEND1*//*MCUConfiguatio*//*Reetofallprpherals,niializstheFlashinterfaeandtheSystick.*/HAL_Iit(;/*USRCODEBEGINnit*//*USERCODEENDInit*//*Cofiguretheytemclock*/SysteClok_Cofi();/*USRCODEBEGINysInit*//*USRCODEENDyInit*//*Initializeallconfiguredperipherals*/MX_GPO_Iit();MX_DM_Int();MX_USRT1UARTInt();MX_USRT2UARTInt();/*USRCODEBEGIN2*//*USERCODEEND2*//*Infiniteloop*//*USRCODEBEGINHILE*/USARTIni();HAL_Dlay1000;CreatcpSrver("cheyoushen","111111","8080";while(1)27{*USRCODEENDHLE*/*USRCODEBEGN3*/}/*USERCODEEND3*/}88/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"adc."#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*//*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*/28/*USERCODEENDPTD*//*Privtedfine*//*USERCODEBEGINPD*///BEEP_ON#defineBEEP_ONHAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET)//BEEP_OFF#defineBEEP_OFFHAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET)//IR333_LD_ON#defineIR33LD_ONHAL_GPI_WriePin(PIA,GPIO_PIN_8,GPIO_INSET)//IR333_LD_OFF#defineIR33LD_OFFHAL_GPI_WriePin(PIA,GPIO_PIN_8,GPIO_INRESET)/*USERCODEENDPD*/3000/*USERCODEEND2*//*Infiniteloop*//*USRCODEBEGINHILE*/while(1){HAL_AC_Sart(&hac);HAL_Dlay10);adc_vlue=HAL_ACGetValue(hac1); //ADC//29if(adc_value<=3000){BEE_N;}{BEEP_OFF;}*USRCODEENDHLE*/*USRCODEBEGN3*/9#ifndefINC_614__#defineINC_614__#include"dela.h"#include"mainh"#include"gpioh"#defineu8uint8_t#defineu32uint32_t//#defineSDA_R HAL_GP_ReaPin(GPOB,GPIO_PN11)#defineSDA_H30罔—IWitein(I,II11,I_I:)#define—L阻—IWitein(I,II11,I_I:S)#definesa.,—H罔守IWitein(I,II10,I_FI:)#definesa.,—L阻—IWitein(I,I_I:10,II)I*岛0614的地址表-----------------------*/#define _TA#define TEMTO
Ox07Ox06/*----------------------------------------------------------*/voidSM3start();//S邓发送开始标志voidSM3stop();//SM泼送停止标志voidSM缸nd(uint8—tbuf);IISM泼送一个字节uint8tSM3read();//SJ\IB接收一个字节打开90614.c,补充从地址空间中读取绝对温度的函数代码:shortTerrp_Gt—Address(uint8_taddress)//读取温度函数 {u8SM3datau8SM3dataH=O; shortSM3data=O; II根据摄氏温度计算公式(02) -273.15获得真实的温度值 知art();//开始起始标志(写) SM氐nd(OxOO);//从机地址SM知nd(address);//发送读取地址命令SM知art();//重复起始标志(读)SM沁nd(OxOl);SM兄ataL=SM3read();//桵收高位SM兄ataH=SM3read();II桵收低位SM女eadi};令31心SMBstop); SMBdata(SMBataH*56+SMBdataL; returnSMBdat;}/inlinefloatTempc_To_Tempf(floattemp){return(9*temp/5+320);}/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*/#include"9061.h"#include"tm160.h"/*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*/SMBdataSMBdataSMBdta*2;SMBdataSMBdta-2715;//SMBdata=10;/*Privtedfine*//*USERCODEEGINPD*//*USERCODEENDPD*//*Infiniteloop*//*USRCODEBEGINHILE*/shorttem_now; //while(1){temp_ow=Temp_GtAddress(TMPTA); ////Disply_Tmp(tempnw,0); HAL_Dlay100); //100ms*USRCODEENDHLE*/*USRCODEBEGN3*/}/*USERCODEEND3*/}1010#ifndefINC_TER_ONROLH_33#defineINC_TER_ONROLH_#include"gpo.h"#defineWAERCNTRO_GPI_X GPIOB#defineWAERCNTRO_GPI_n GPIO_PI_12//voidWaer_St(GPIO_nStatePinStae); //voidWaerSt_Togle); #endif*INWATE_CNTRL_H_*/#include"wate_contrl.h"/***pinstate10***/inlineoidateretGPIO_PiStatePinSat){HAL_GPI_WriePin(ATR_CONTROL_GPIO_X,WATER_CNTRO_GPIO_n,PinStat);}/******/inlineoidateretToggle()//{HAL_GPI_ToglePinWAER_CONTROL_GPIO_X,WATER_CNTRO_GPIO_n);}34/*USERCODEENDHeader*//*Includes*/#include"mainh"#include"adc."#include"dma."#include"i2c."#include"usar.h"#include"gpioh"/*Privteicludes*//*USERCODEBEGINIncludes*/#include"olediic.h"#include"oledont.h"#include"blueooth.h"#include"stdi.h"#include"strig.h"/*USERCODEENDIncludes*//*Privtetpedef*//*USERCODEBEGINPTD*//*USERCODEENDPTD*/#include"blueooth.h"35#include"strig.h"uint8_tBLE_ceive_uffBUF_SIZ_BE_EC];uint16_tBLEreceie_ize;uint8_tBLE_nd_bffBUF_SIE_BL_SND;uint16_tBLEsend_iz;voidBL_Iit()//{//DMAHAL_URT_EABLE_T(UART_BLE,UART_IT_DL); HAL_UAR_Recive_DA(UART_BLE,(uint8_*)BLrecevc_buff,UFF_IZ_BE_EC);}inlineoidLE_sd(int8t*messae,uit1tsize){//HAL_UAR_Trasmit(UAT_BLE,message,sizeTIE_OUT_BLE);}{if(__H_UAR_GET_LA(&UART_BL,ART_FLA_IDLE)!=RESET)/{HAL_URT_CEAR_ILELAG(&UART_BLE);//HAL_UAR_DMAtop(&AR_BLE);/BLE_recive_ize=BUF_SIZE_BLE_REC-HAL_DA_GE_COUNTER(&UART_DA_BL_HANDE);//36Deal_Daa_BL();//HAL_UAR_Recive_DA(UAR_BL,(uint8_*)BLrecevc_buff,UFF_IZ_BE_EC);}}voidDel_aa_BLE){//BLE_sen((uit8t*)BL_eceive_buf,BLEreeie_size);}1intmai(voi){/*USRCODEBEGIN1*//*USERCODEEND1*//*MCUConfiguatio37*//*Reetofallprpherals,niializstheFlashinterfaeandtheSystick.*/HAL_Iit(;/*USRCODEBEGINnit*//*USERCODEENDInit*//*Cofiguretheytemclock*/SysteClok_Cofi();/*USRCODEBEGINsInit//*USRCODEENDyInit*//*Initializeallconfiguredperipherals*/MX_GPO_Iit();MX_I22_Iit();MX_AD1_Iit();/*USRCODEBEGIN2*/OLED_nit);OLED_LS(;OLED_howtr(0,0,(uint8_t)"SoilMoistue",2);HAL_ACExCaliraion_Start&adc1);//ADCHAL_AC_Sart(hac1);//ADC/*USERCODEEND2*//*Infiniteloop*//*USRCODEBEGINHILE*/shortbuff_adc,humi;charoled_buf[25];while(1){buff_dc=HAL_AD_etValue(&had);//ADC38//2700-1200if(buff_adc>2700){buff_adc=2700;};humi=180-uff_c*2/3;sprinf(oedbf,"SilMoisure:.1f%% ",(float)humi0);OLED_Shwtr(0,3,(uint8_t)olebuf,1);memset(oledbu,0,2);*USRCODEENDHLE*/*USRCODEBEGN3*/HAL_Dlay1200);}/*USERCODEEND3*/}/**@brefystemCockConfiuation@retvalNone*/voidSyteCock_Cnfg(void){RCC_OcInitTypeDefRCC_OscIitStruct={0;RCC_CkInitTypeDefRCC_ClkIitStruct={0;RCC_PriphCLKInityeDefPeriphCkInit=0;/**IitializesteRCCOscilatrsacodingtohespecifidpaametersinheCC_OcIiTypeefstrutur.*/if(buff_adc<1200){buff_adc=1200}if(buff_adc<1200){buff_adc=1200}RCC_OcIntStrct.OscilatorType=RCC_OSCLLATRTYPE_HSE;RCC_OcIntStrct.HSEStte=RCC_SE_O;RCC_OcIntStrct.HSEPrdivValue=RC_SEPREDIV_DV1;RCC_OcIntStrct.HSIStte=RCC_SI_O;RCC_OcIntStrct.PLL.PLLStte=RCC_PL_N;RCC_OcIntStrct.PLL.PLLSrce=RCC_LLOURCE_H;RCC_OcIntStrct.PLL.PLLMUL=RC_PLLMU2;if(HAL_RC_OsConfg&RCC_scIntStrut)!=HAL_K){Error_andlr();}/**IitializesteCPU,AHBndAPBbssclocks*/RCC_CkIntStrct.Clockype=RCC_CLOKTYP_HCLK|RCC_CLOCKTPE_SSCLK|RCC_CLCKTYE_PCLK1|RCC_CLOCTYPEPCLK2;RCC_CkIntStrct.SYSCLSource=RCC_SYSLKSORCE_PLLCLK;RCC_CkIntStrct.AHBCLDivider=RCC_YSCLK_DIV1;RCC_CkIntStrct.APB1CKDivider=RCHCK_DIV2;RCC_CkIntStrct.APB2CKDivider=RCHCK_DIV1;if(HAL_RC_ClckCofg(&RC_ClknitStuc,FLASH_LTENC_0)!=HAL_OK){Error_andlr();}PeripClknit.eriplockSeectin=RCC_PRIPHCLKAD;PeripClknit.dcClkSelecion=RCC_DCCLK2_DI;if(HAL_RCEx_eripCKConfg(&PriphCkIit)!=HAL_OK){Error_andlr();}
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024高考地理一轮复习专练16高低压系统与锋面气旋含解析新人教版
- 小学全环境立德树人工作方案
- 证券法期末考试题及答案
- 2024年海南政法职业学院高职单招语文历年参考题库含答案解析
- 2024年浙江安防职业技术学院高职单招职业适应性测试历年参考题库含答案解析
- 2024年陇西县第二人民医院高层次卫技人才招聘笔试历年参考题库频考点附带答案
- 2024年阳江市中西医结合医院高层次卫技人才招聘笔试历年参考题库频考点附带答案
- 2024年河南林业职业学院高职单招职业适应性测试历年参考题库含答案解析
- 2024年闽侯县第二医院高层次卫技人才招聘笔试历年参考题库频考点附带答案
- 2024年长治市高新技术开发区中心医院高层次卫技人才招聘笔试历年参考题库频考点附带答案
- 复旦大学留学生(本科)汉语入学考试大纲
- 送达地址确认书(完整版)
- 试讲 关注合理营养与食品安全课件
- 2022年同等学力人员申请硕士学位日语水平统一考试真题
- 长距离输气管线工艺设计方案
- 北师大版小学五年级上册数学第六单元《组合图形的面积》单元测评培优试卷
- 用特征方程求数列的通项
- 甲醇浓度密度对照表0~40
- 四年级奥数题(一)找规律
- 会计学原理课后习题与答案
- 县领导在新录用公务员培训班开班典礼上的讲话
评论
0/150
提交评论