1. 实验平台使用百为的STM32F103开发板
2. 例程目录\百为stm32开发板光盘\stm32_gui_lib\Project\Embedded_GUI_Example\EWARM
3. 直接编译遇到一个问题
Error[Pe147]: declaration is incompatible with "__nounwind __interwork __softfp unsigned int __iar_builtin_REV16(unsigned int)" (declared at line 197 of "D:\IAR Systems\ E:\MCU\STM32\百为stm32开发板光盘\stm32_gui_lib\Libraries\CMSIS\CM3\CoreSupport\core_cm3.h 1124
4. 解决办法如下,勾选Use CMSIS
5. 去掉 $PROJ_DIR$\..\..\..\Libraries\CMSIS\CM3\CoreSupport,编译通过。
6. 打开工程,分为GUI_HAL和底层有关的,GUI_Library是上层的鼠标,文字,图像等处理,其实看起来蛮简单的。 JoyHal.c是处理板子上面的一个方向按键,
7. 看下主函数
1 int main(void) 2 { 3 RCC_ClocksTypeDef RCC_Clocks; 4 5 /* Set the Vector Table base location at 0x08000000 */ 6 NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0000); 7 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); 8 9 /* Setup SysTick Timer for 10 msec interrupts */ 10 RCC_GetClocksFreq(&RCC_Clocks); 11 if (SysTick_Config(RCC_Clocks.SYSCLK_Frequency / 100)) 12 { 13 /* Capture error */ 14 while (1); 15 } 16 /* configure Systick priority */ 17 NVIC_SetPriority(SysTick_IRQn, 0x0B); 18 19 /* Set HW structure parameters */ 20 HWConfig_SetHardwareParams(); 21 22 23 /* If the LCD Panel has a resolution of 320x240 this command is not needed, it‘s set by default */ 24 /* Set_LCD_Resolution( 320, 240 ); */ 25 26 /* Initialize the LCD */ 27 GL_LCD_Init(); 28 29 GL_Clear(GL_White); 30 31 InputInterface_Init(); 32 33 ShowLoadingLogo(); 34 35 #if TOUCH_SCREEN_CAPABILITY 36 /* Check if Calibration has been done*/ 37 TS_CheckCalibration(); 38 #endif 39 40 /*Initialize cursor*/ 41 GL_Clear(White); 42 CursorInit(GL_NULL); 43 44 /* Menu Initialisation*/ 45 Show_HomeScreen(); 46 CursorShow(195, 80); 47 48 /* Infinite main loop ------------------------------------------------------*/ 49 while (1) 50 { 51 52 #if defined(USE_STM3210C_EVAL) || defined(USE_STM32100E_EVAL) 53 /* Catching touch events */ 54 if ( TS_IsCalibrationDone() == SET ) 55 #endif 56 { 57 ProcessInputData(); 58 } 59 60 /* Time out calculate for power saving mode */ 61 TimeOutCalculate(); 62 63 CatchInputEvents(); 64 } 65 }
8. 方向按键的原理图,程序对应的就是JoyHal.c,joystick翻译成中文就是操纵杆。