|
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)" % _" N% R! g. x9 N9 ^5 f5 s; Y
- (declared at line 197 of "D:\IAR Systems\ E:\MCU\STM32\百为stm32开发板光盘\stm32_gui_lib\Libraries\CMSIS\CM3\CoreSupport\core_cm3.h 1124
复制代码 / L* q2 ]* a% d2 M
4. 解决办法如下,勾选Use CMSIS
8 n9 g) u4 p ?, _. K# `" L# L
' B& S i X* J2 ^
5. 去掉 $PROJ_DIR$\..\..\..\Libraries\CMSIS\CM3\CoreSupport,编译通过。 ; L" Q7 H3 D$ x2 T
( r$ H7 E6 r+ G0 ~; ?4 o
6. 打开工程,分为GUI_HAL和底层有关的,GUI_Library是上层的鼠标,文字,图像等处理,其实看起来蛮简单的。 JoyHal.c是处理板子上面的一个方向按键,
+ ]8 ^! W0 j0 p* \
3 C5 N6 [- a" c+ w% i" \
7. 看下主函数 - int main(void)* P- o5 O. M" o7 z/ O
- {
- I6 K) P- Z3 r - RCC_ClocksTypeDef RCC_Clocks;( D2 v3 r( E7 g7 f- f9 P& Y
- - A/ o4 f7 p" F2 L, l& i
- /* Set the Vector Table base location at 0x08000000 */
1 X' @4 L6 c# R: u" m9 X9 s% N9 _ - NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0000);- n5 _6 j8 W5 d* N2 ~. E4 k
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
0 t' Q: ]; ]# t/ D8 F9 c - - X |5 t G0 ?% {8 }) F& [
- /* Setup SysTick Timer for 10 msec interrupts */
# ?. ~% X5 L8 M2 J- J' ~( H9 Z - RCC_GetClocksFreq(&RCC_Clocks);
8 j# D" q# m8 G% Z - if (SysTick_Config(RCC_Clocks.SYSCLK_Frequency / 100))
5 M7 G2 [1 Q5 f3 b4 U9 M0 c2 e - {! Q2 d G* ^& [1 d
- /* Capture error *// ]6 [$ H: _, P" d5 I' C# g
- while (1);6 q+ j( \* i1 x! ~ ~
- }
: \* `+ o: j* S2 x; n K) n8 E - /* configure Systick priority */: r8 y' B% \# A+ z0 l
- NVIC_SetPriority(SysTick_IRQn, 0x0B);
& h& Y- i6 y _3 g( a" l - , W6 Y1 L) V- X
- /* Set HW structure parameters */
U N, |- I6 X8 L5 I; `( F - HWConfig_SetHardwareParams();. L& h' r3 G6 O
0 z8 I- D) J5 V; F& {# b- , ]$ e' I+ l& d# y9 G$ g9 c [9 |
- /* If the LCD Panel has a resolution of 320x240 this command is not needed, it's set by default */
& I/ E. K {) o3 l+ J2 _8 e8 W - /* Set_LCD_Resolution( 320, 240 ); */, o4 E( c( Q" c4 J0 |6 X6 g
- 7 ]3 D9 D0 `5 H! b
- /* Initialize the LCD */
8 Y( {' i6 o f% n* n; p - GL_LCD_Init();
0 Z" G5 U' a# u
$ w8 Q3 E9 J9 _1 n- GL_Clear(GL_White);
* _- x- H8 s' s8 f
. Z/ y }9 n" D" k# i3 q, M# k- InputInterface_Init();+ ^: e# J9 v2 P
K0 `1 l3 X& w& u7 N5 {' ?- ShowLoadingLogo();9 m4 J }, a5 o9 V7 t6 O$ A; x2 j$ k: s
- ( `' q! |2 L, f/ y- p7 F0 H) s
- #if TOUCH_SCREEN_CAPABILITY% d7 @' h+ P+ d8 @
- /* Check if Calibration has been done*/. I* @' `! h4 n( T9 z* @
- TS_CheckCalibration();+ r- B5 i2 u* l, I3 a) p6 I0 ?% f
- #endif: T: q7 ~( P6 a: Z
- % j1 ]) ~9 X6 N& X1 W
- /*Initialize cursor*/- ?# C5 b# \- z( h
- GL_Clear(White);" r& ~* t" ~) i) S9 p
- CursorInit(GL_NULL);0 D! {6 j/ h6 U2 b: _
/ B" L$ d- }4 |& T; e- /* Menu Initialisation*/
' w' a0 }) k& \ f6 ? - Show_HomeScreen();0 G8 }/ V4 ]! Z; z+ T& w
- CursorShow(195, 80);* ^ l2 E% f) g9 i$ z4 e; F1 @9 r
/ @7 {& I* ^9 [- /* Infinite main loop ------------------------------------------------------*// M# I |* ]: s% P8 q/ z
- while (1)5 _2 q ~6 i. Y9 X" L' Z
- {% c9 ?5 w7 G. ~% ]( {
% } F% {8 Q) ?& {- #if defined(USE_STM3210C_EVAL) || defined(USE_STM32100E_EVAL)
& r; I) }- `) M: `6 f - /* Catching touch events */
5 ~, s4 }$ Y4 l) \6 G - if ( TS_IsCalibrationDone() == SET )/ h" v7 }6 z1 h* X3 D
- #endif0 _$ _7 b5 f# J
- {9 K, ~: A, w: t4 Y8 O
- ProcessInputData();
2 u. }( q( W$ m8 G! F; ]& Y- O7 r - }8 L! e# U1 _ o2 |" F# H
6 i, q+ x/ Q: s* C" h; z- /* Time out calculate for power saving mode */* y2 B" {2 M2 i! M
- TimeOutCalculate();8 e2 B$ j4 Z# ^* T. [5 |7 B
* D* z1 }/ X. f& ^! i( H- U) z. ^0 ?- CatchInputEvents();' O. w5 H% Y8 Y% f
- }
( n' T8 \) Y, U+ U4 v# ~ - }
复制代码
3 ^7 m5 p; G; V. e8. 方向按键的原理图,程序对应的就是JoyHal.c,joystick翻译成中文就是操纵杆。 2 ]2 l1 U7 O* p4 R! o
2 s7 \. I0 z( w e( {' g
9. 看下实际效果,主要用操纵杆移动鼠标,不知道为啥触摸屏没用。可能是板子跳线帽不对。看了一下cursor.c这个文件,里面只有读操纵杆的函数,估计触摸屏本来就没用。 5 ]/ {. w! S: ?5 ^& I% a& F
4 x9 u* b0 Q9 a/ ^
10. LCD接口是FSMC接口,FSMC本来是存储器的接口,也可以用来驱动LCD。
) Z0 I3 m1 y+ _
- X; N/ g' K) f9 R% s, b
11. LCD引脚配置 - void LCD_CtrlLinesConfig(void) x' A. _, D1 H* r' E7 b
- {
" R: j# R, ~: ?) \' c& S - GPIO_InitTypeDef GPIO_InitStructure;
5 B; ?& q4 D* l! P$ ~" d* x ~ - /* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */) c/ V5 {. ]+ Y) O7 N6 T$ Y
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
$ ]0 a8 Z7 \% e - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
5 {5 _9 c$ ^3 a2 W1 V - RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
& u4 W6 v' `* w# F% T - RCC_APB2Periph_AFIO, ENABLE);
7 w f+ N, Y1 l3 j9 J, T - /* Set PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14),( F2 @3 v' b3 j
- PD.10(D15), PD.14(D0), PD.15(D1) as alternate function push pull */
6 @2 C) L" `. Y5 M* H! B/ A - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 |4 s1 _9 u D8 i* H* B
- GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 |
* d# A6 u" M& m - GPIO_Pin_15;
- b' O T! P+ K& ` - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;# k. ]/ u0 u# b$ G1 y
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;$ a! I& a0 i8 q4 M5 o) t
- GPIO_Init(GPIOD, &GPIO_InitStructure);, D; A' A4 n( b
- /* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
& f7 M3 N& U- \9 m2 o - PE.14(D11), PE.15(D12) as alternate function push pull */
+ w3 t6 g4 \" J - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |3 [( H8 S2 ^3 l: k8 q" b/ m3 o
- GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |# A g/ J1 g( B6 H+ \' G$ u
- GPIO_Pin_15;5 t/ h5 S1 D# a
- GPIO_Init(GPIOE, &GPIO_InitStructure);
: i3 P1 \* q$ ^ - /* Set PF.00(A0 (RS)) as alternate function push pull */$ p r. d3 P6 d6 a: _. ?
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
# ^; I* @6 l) Y% Z' K - GPIO_Init(GPIOF, &GPIO_InitStructure);7 k( f m# ?: }+ D
- /* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
" A8 R- Q7 d! ~1 n - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
R) Q+ V4 z1 m& h% _4 [3 z - GPIO_Init(GPIOG, &GPIO_InitStructure);$ ]% E3 w- o0 \+ T2 [3 @' z `
- }
复制代码 " h6 r, w& p* @
12. FSMC配置 - void LCD_FSMCConfig(void)% e. S$ {' ^2 p/ F& b
- {
; h7 e; X+ M2 S! a' j - FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
, R4 f( g# G& N - FSMC_NORSRAMTimingInitTypeDef p;
5 x+ q) S1 ~1 j- i- k4 @ M1 |9 q5 [ - /*-- FSMC Configuration ------------------------------------------------------*/
6 p/ a# ?; c" D" ^1 w - /*----------------------- SRAM Bank 4 ----------------------------------------*/* |3 J x) j7 r1 h$ u; ?! u
- /* FSMC_Bank1_NORSRAM4 configuration */
7 u* Z. r& w' Z2 ]( ]+ c. F0 s - p.FSMC_AddressSetupTime = 1;& ?) E; ^$ e7 u4 E# K" Q1 M
- p.FSMC_AddressHoldTime = 0;" S4 D% J0 Z9 e2 c# s3 |, g/ q
- p.FSMC_DataSetupTime = 2;
+ i. v5 n% y" X( w# s - p.FSMC_BusTurnAroundDuration = 0;+ ~: J4 X) N8 |6 B+ t
- p.FSMC_CLKDivision = 0;
9 u F/ B% d# F3 x' ?: a) \3 r - p.FSMC_DataLatency = 0;
% \. M5 Y& T3 r4 A/ U* ^9 j% T - p.FSMC_AccessMode = FSMC_AccessMode_A;$ m, C" a+ e2 W5 o5 J3 [
- /* Color LCD configuration ------------------------------------
4 M# U/ x# a7 ]3 W6 @3 l3 ?) C - LCD configured as follow:
: l+ ~; A* q- B. S6 K/ z# j - - Data/Address MUX = Disable+ D! o. v7 D5 G% ?
- - Memory Type = SRAM9 U6 i/ h. }7 l; a
- - Data Width = 16bit( l. L ^8 e/ i
- - Write Operation = Enable
) n, C+ @" m- T# Z - - Extended Mode = Enable
$ N2 M! ~! W; i) d6 ` - - Asynchronous Wait = Disable */
$ { o4 ^6 h, k# f, t+ M - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;9 h( ]1 G/ p4 o
- FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;8 n% R1 T/ s8 ~, h
- FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
# k2 g! U9 [- Y0 o - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;. u! C% z' l# q6 k8 v5 _% v' d" l
- FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
/ z+ c) y0 m6 L - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; y. F1 L- M' F0 Q* d5 L% b. e
- FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
+ y: B# V8 q% ? - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
8 K" C) N9 ^6 Y* v - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
# Z6 _! h" v D. f( P9 W - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
/ J( C) b P' `# r9 @& F/ z2 Y - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
$ X s% x. {- p9 c) z5 T - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;, |' E/ l: C5 n$ J
- FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;* D& U% C9 d. l b+ n
- FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
$ h% x. m* C' ?" j/ m - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
9 ~. P/ W/ S+ Z& ]8 ~+ x - FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
0 e1 f( q8 i7 w - /* BANK 4 (of NOR/SRAM Bank 1~4) is enabled */
5 @2 _! w! b i8 N) P6 f9 } - FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
4 z$ v; Z3 X8 a/ b' V) U/ E - }
复制代码
8 U0 F$ I, |/ Q9 @2 `; ]: S13. 画按钮的函数 - void GL_DrawButtonBMP(uint16_t maxX, uint16_t minX, uint16_t maxY, uint16_t minY, uint8_t* ptrBitmap)8 ^ k0 J" G+ b: d5 l+ S/ D
- {
5 q" z" K$ w7 X7 S! n. _7 m# p - GL_SetDisplayWindow(maxY, maxX, maxY - minY, maxX - minX);( K2 R" z! M- r8 u7 g
- GL_DrawBMP(ptrBitmap);$ D# b- Q+ R3 u2 O& p9 L
- GL_SetDisplayWindow(LCD_Height - 1, LCD_Width - 1, LCD_Height, LCD_Width);
* C7 R0 K+ |3 A9 ~/ E* e* A* R' Y8 b - }
复制代码
7 g8 Q3 r4 O! H# B8 |6 j5 w7 {- e- ~14. 总结起来,这个库其实功能简单,用起来也不复杂的。 7 v6 C( ~3 B) R z! o
|