基于CubeMX 5.0的TouchGFX移植教程
基于CubeMX 5.0的TouchGFX移植教程,带截图,有工程代码TIM2A TIM3Reset ConfigurationA TM4A TIM5User Constants● NVIC SettingsO DMA SettingsTIM6② Parameter SettingsTIM7Configure the below parameters:A TIMeTIM9QISearch (CIt/+FTIM10TIM1Counter SettingsTIM12Prescaler(PSC -16 bits value89TIM13Counter ModeTIM14UpCounter Period (AutoReload Registe. 999Internal Clock Division(CKD)No DivisionConnectivityv Trigger Output (IRGO)ParametersMaster/slave Mode(MSM bitDisable (Trigger input effect not delayed)MultimediaTrigger Event selectionReset (UG bit from TIMX EGR)6、勾选 FreeRtos,有2个注意点,需要打开 USE APPLICATION TASK TAG功能,分配给GFX的任务内存要大点,不然死机a Search (Crt/月⊙ComputingUSE MUTEXESEnabledUSE RECURSIVE MUTEXESDisabledUSE COUNTING SEMAPHORES DisabledQUEUE REGISTRY SIZEMiddlewareUSE APPLICATION TASK TAGEnabledENABLE BACKWARD COMPATIBIL EnabledFATESUSE PORT OPTIMISED TASK SE Enabled∠ FREERT0sUSE TICKLESS IDLEDisabledGRAPHICSUSE TASK NOTIFICATIONSEnabledLIBJPEGMemory management settingsdit TaskTask NameSysTaskPriortyos PriontyNormalStack Size(Words) 512Entry FunctionStart SysTaskCode Generation Option DefaultParameter儿LlocationDynamicBuffer NameControl Block NameKCancel7、使能 TouchEⅩ,修改分辨率,切换 TouchGEX选项,OptionsGRAPHICS Mode and ConfigurationCategoriesA->ZModeA TM4Graphics Framework Touch GF.A TM5TM6Display Interface Display Parallel Interface using LTDCTIM7△TM8TIM9TIM10TIM11TIM12TIM13TIM14ConfigurationReset ConfigurationConnectivity● TouchGFXe User ConstantsPlatform Settingse Parameter SettingsMultimediaConfigure the below parametersSecuritQ Search+月⑧DineI uchitAComputingv Physical Dis play SizeWidthV CRCHeight480ˇ Frame BufferLTDC Pixel Format(Set in LTDC)LTDC PIXEL FORMAT RGB888MiddlewareFrame Buffer Color FormatRGB888Color Frame Buffer DepthFATFSColor Frame Buffer Start Address(S. 0XC0000000FREERTOSBuffers countDouble BufferedGRAPHICSLIBJPEGBitmap Cache SettingsBitmap cache AddressMBFDT S西A,L选择GFX的设计器OptionsGRAPHICS Mode and ConfigurationCategories.>ZMnode△TM4Graphics Framework TouchGFX△TM5TIM6Display Interface Display Parallel Interface using LTDCTIMA TM8TIM9TIM10TIM11TIM12TIM13TIM14ConfiqurationReset ConfigurationConnectivityo TouchGFX● User Constants△ Platform Settings● Parameter SettingsMultimediaConfigure the below parametersSecurityQ⑤ea+月Executev External application infoComputingNameTouchGFX DesignerVersionV4.10.0CRCLocatioExecutable full nameG \Touch/4. 10. 0\designerTouch GFXDesiMiddlewareInputsPhysical Display X Size800Physical Display Y size480FATFSFREERTOSGRAPHICSLIBJPEGLWIPMREDT S8、工程配置,勾选生成的外设生成c和h文件,这样方便管理工程Pinout ConfigurationClock ConfigurationProject ManagerSTM32Cube Firmware Library PackageO Copy all used libranes into the project folderProjectO Copy only the necessary library filesO Add necessary library files as reference in the toolchain project configuration fileM Generate peripheral initialization as a pair of c/ h files per peripherala Backup previously generated files when re-generatingCode Generator U Keep User Code when re-generatingv Delete previously generated files when not re-generatedHAL Settingsa Set all free pins as analog(to optimize the power consumption口 Enable Full AssertAdvanced SettingsSelect a template to generate customized codeSetting:9、生成工程代码,点YESMX Warning: Code Generation△WARNINGSThe HAL timebase source can be changed from the Pinout tab under sr ase source other than the SystieWhen FreeRTOS is used, it is strongly recommended to use a HaL timbaThese IPs still have some not configured or wrong parameter values[FATFS, GRAPHICSDo you still want to generate codeYes N这时候编译工程会发现很多错误compiling oSWrappers cpp./Middlewares/ST/TouchGEXtouchgfx/os/osWrapperscpp(1): error: #5: cannot open source input file"touchgfx/hal⊥nc⊥ude< touchgfx/na1/ WRAppers,rpp/Middlewares/sT/TouchGEX/touchgfx/os/0SWrappers cpp: o warnings, 1 errorcompiling port. C.compiling cmsis 0s.c" TouchGFX DEMO\TouchGEX DEMO, axfn-7 Error(3), 1 Warning(s)Target not created.Build Time Elapsed: 00: 00: 27切换回 CUBEMX,在 CUBEMX下启动GFX的设计器ComputingConfigurationMiddlewareReset configurationV FATES9 TouchGFXUser Constants▲ Platform SettingsFREERTOS9 Parameter Setting∠ GRAPHICSConfigure the below parametersLIBJPEGLWiPMBEDTLSQ[ Search(CrtH月⑧⊙ExecutePDM2PCMV External application infoUSB DEVICENameTouch GFX DesignerUSe HOSTVersionV4.10.0LocationApplicationExecutable full nameG: \ TouchGFX14 10.0ldesignenTouchGFXDes.Input使用设计器设计一个界面,再点击生成代码TouchGFX DesIGNERHello TouchGFX查看生成日志,如下表示完成E TouchGFX Designer Notifications000504/12-2018 make -f simulator/gcc/Makefile -11000:0504/12-2018 Wrote G: \STM32\STM32 Project\TouchGFX DEMO\TouchGEX/generated/gui generated/include/gui generated/sAlpha00:0504/12-2018 Wrote G: \STM32\STM32_Project\TouchGFX DEMO\ TouchGEX/ generated/gui generated/gre/screenl_screen/Scre00: 04/12-2018 make -f simulator/gcc/Makefile assets-3l000.05 04/12-2018 tcuchgEx update project --pzoject-file=.WNDK-ARM TouchGIX DEMD uvpzojx--gui-gzoup-name=ApplicaticMIXINS00-05 04/12-2018 make -f simulator/gcc/Makefile-j1000: 04/12-2018 Wrote G: \STM32\ STM32 Project\TouchCFX DEMO\TouchGEX/ generated/gui generated/include/gui_ generated/s005042.208owrte:\sms2smspreetirourhrxporouchsrx/ganerate/gu9enarated/sre/sereenlserenscre0005 04/12-2016 make-f simulator/gcc/Makefile assets-11000: 04/12-2018P tauchgEx update project --project-files.. \MDK-ARMA TouchGEX DEMO uvpzojx --gui-gzoup-name=Applicatio00:0504/12-2018 make -f simulator/gcc/Makefile-1100005 04/12-2018 P make -f simulator/gee/Makefile assets-j100005 04/12-2018 touchgfx update_project--project-file=--AMDK-AR TouchGEX_DEMO. uvpzojx--gui-gzoup-name=Applicatio0005 04/12-2018 P make -f simulator/gcc/Makefile-j10000504/12-2018Gererating code00:0504/12-2018 P make -f simulator/gcc/Makefile assets-j10000s 04/12-20180 touchgEx update_projeat--pzoject-file-.MDX-ARMA TouchGEX_DEMD.uvprojx-gui-gzoup-name-Applicatic0005 04/12-2018 Code generation complete00:0604/12-2018P make -f simulator/gee/Makefile assets -j1048000604/12-2018 tcuchgEx update project--project-files..\MDK-ARMATouchGEXDEMO uvprojx--gui-group-AppLIcatIo00.0604/12-2018 make-f simulator/gcc/Makefile-j10a、再切换回MDK,发现要重新载入工程,点YES,再编译,发现上百个错误,这是因为没有添加G「X的ib文件,其实这时候MX已经把需要的GFX文件都拷贝到工程下b、添加i文件后重新编译,还有错误TouchGEX DEMO\ TouchGEX DEMO axfL6218E: Undefined symbol MX FREERTOS Inito (referred from main. o)TouchGEX DEMO\TouchGEX DEMO axfExxOXL6218E: Undefined symbol GRAPHICS MainTask (referred from freertos. o)TouchGEX DEMO\ TouchGEX DEMO axf: Error: L6218E: Undefined symbol IOE Init (referred from exc7200.o)TouchGEX DEMO\ TouchGEX DEMO axf: Error: L6218E: Undefined symbol IOE ReadMultiple (referred from exc7200. o)TouchGEX DEMO\ TouchGEX DEMO axf: Error: L6218E: Undefined symbol IoE Delay (referred from stmpe811. o)TouchGEX DEMO\ TouchGEX DEMO axf: Error: L6218E: Undefined symbol IOE ITConfig (referred from stmpe811. o)TouchGEX DEMO\ TouchGEX DEMO axf: Error: L6218E: Undefined symbol IOE Read (referred from stmpe 811 o)TouchGEX DEMO\TouchGEX DEMO axf: Error: L6218E: Undefined symbol IOE Write (referred from stmpe811. o)TouchGEX DEMOVTouchGEX DEMO axf: Error: L6218E: Undefined symbol IOE WriteMultiple (referred from ta3510.0).Not enough information to list image symbolsNot enough information to 11st load addresses in the image mapFinished: 2 information, 0 warning and 9 error messages"TouchGEX DEMO\ TouchGFX DEMO. axf-9 Error(s),1 Warning (s)C、这是因为MX乱添加了几个BSP文件日添 Touch GFX DEMO□ Application/ MDK-ARM由□ Application/ TUserB-D Drivers/BSP/Componentsexc7200. c田tmpe81由口ts3510.cDrivers/STM32F4x HAL Driver2 Drivers/CMSISd、都去掉,然后再编译,发现只有2个错误了Bula cargetOuCn9EX DENOlinking..TouchGEX DEMO\TouchGEX DEMO axf: Error: L6218E: Undefined symbol MX FREERTOS Inito(referred from main. o)TouchGEX DEMO\ TouchGEX DEMO axf: Error: L6218E: Undefined symbol GRAPHICS MainTask (referred from freertos. o)Not enough information to list image symbolsNot enough information to list Icad addresses in the image mapFn1Bhed:2inf。 eatlon,0 warning anc2exx。 r message吕"TouchGEX DEMO\ TouchGEX DEMO axf"- 2 Error(s), 0 Warning(s)e、这是因为C文件调用CPP文件中的函数,或是CPP文件调用C文件中的函数导致,GFX官方有说明,如C文件调用CPP文件中的函数,那么CPP文件中的原函数要加 extern"C"前辍,如extern C void GRAPHICs MainTask(void)touchgfx:: HAL:: getInstance ()->taskEntry (i如CPP文件调用C文件中的函数,那么CPP文件中要加 extern"C"前辍声明这是C函数,如下。90/* Private function prototypes1 extern c void systemClock Config(void);2 extern c void MX FREERTOS Init(void);3 extern void GRAPHICs HW Init(void);再次编译工程,发现没有错误了,下载程序,显示正常OKooeosee0e0最后触摸移植,触摸相关其实已经在工程文件上了,修改内容也简单GPIO. cppSTMB2F4DMA. cppSTMB2F4Touch Controller cppfreertos. cBoardConfiguration.cpp B maincpp/L STM32F4Touch Controllercpp B i2c.c3/* USER CODE BEGIN BSP user includes f4 extern "c" void GT811 Init(void);5 extern "C" bool GT811_ReadOnePiont (uint16_t *px, uint16_t *py):67USER CODE END BSP user includes +9 extern hch10曰1112 uint 32 t LCD Getxsize ();13uint32 t LCD GetYsize();1516 using name space touchgfx;1718 void sTM32F4Touch controller:: init o19日20A USER CODE BEGIN F4TouchController init *22/ Add code for touch controller Initialization*/23CD GetXsize(), LCD GetYsize():24GT811 Init()25USER CODE END F4TouchController init *26128 bool STM32F4TouchController: sampleTouch (int32 t& x, int32 t& y)29日30/USER CODE BEGIN F4Touchcontroller_sampleTouch *3132/*Is StateTypeDef state:33BSE TS Getstate(&state):34if(state. TouchDetected)3536state. x:37y= state y.38return truer3940uint16 t sx, sy;41bool ok GT811 ReadonePiont (&sx, &3y)i42sXH43y= sy44return。k4546/. USER CODE END F4Touchcontroller_sampleTouch再编译工程并下载程序,触摸也正常了,总结了下,只要注意上面红色的地方,应该都能移植成功,希望对各位有帮助。Ie:https:/pan,baiducom/s/100sjphsy15ab2-zttskgq
用户评论
谢谢分享,参考一下。
还不错,希望能出个更详细的教程