STM32 embedded graphic objects ...

STM32 embedded graphic objects touchscreen library, Elektronika

[ Pobierz całość w formacie PDF ]
AN3128
Application note
STM32 embedded graphic objects/touchscreen library
Introduction
This library is a firmware package which contains a collection of routines, data structures,
and macros covering the main features of a graphic library and supporting a HID device to
interact with the graphic objects (touchscreen, joystick, and pushbutton).
The library is general purpose and can be executed on any CPU, 8/16/32-bit, to guarantee
the maximum portability of any architecture or LCD controller, and it provides a graphical
user interface (GUI) for any application that operates with a graphical LCD.
While the firmware library functions with all currently available STM32 microcontrollers, this
document describes the firmware library through the implementation of a graphic library for
embedded systems based on the STM32F10xxx microcontroller family.
It can easily be used in the user application without an in-depth study of STM32 registers,
SPI, and I
2
C read/write operation steps. As a result, using the firmware library saves
significant time that would otherwise be spent in coding, while at the same time reducing the
application development and integration costs.
The firmware architecture is developed in separate layers and the HAL (hardware
abstraction layer) makes it independent from the microcontroller used in the final
application.
A set of fonts is included: 8x12 and 16x24.
Even though the firmware library source code is developed in 'ANSI-C', the code
architecture follows an OOP (object oriented programming) approach.
describes the document and library rules.
highlights the features of the STMPE811 and explains its hardware interface with
a device microcontroller (STM32 in this case).
and
describe the library features, its architecture and its exported APIs
(application programming interfaces) in detail.
contains an example application source code describing how to configure and use
the library.
contains information about the embedded GUI resource editor application.
March 2011
Doc ID 16918 Rev 4
1/104
Contents
AN3128
Contents
1
Document and library rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1
Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2
Touchscreen controller hardware description . . . . . . . . . . . . . . . . . . . 11
2.1
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3
STMPE811 functional overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.4
Touchscreen controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5
Interfacing touchscreen with microcontroller with the STMPE811 via I2C 13
3
Multi-input embedded GUI library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2
Graphic object introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3
Library package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4
Library architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4.1
API layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4.2
HAL layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4
Multi-input embedded GUI library firmware . . . . . . . . . . . . . . . . . . . . . 20
4.1
Graphic object API functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1.1 NewLabel API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.1.2 NewButton API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1.3 NewCheckbox API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.1.4 NewSwitch API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1.5 NewIcon API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.1.6 NewRadioButtonGrp API global function . . . . . . . . . . . . . . . . . . . . . . . . 27
4.1.7 AddRadioOption API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.1.8 NewComboBoxGrp API global function . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.9 AddComboOption API global function . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1.10 NewSlidebar API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.1.11 NewHistogram API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.1.12 NewGraphChart API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2/104
Doc ID 16918 Rev 4
AN3128
Contents
4.1.14 DestroyPageControl API global function . . . . . . . . . . . . . . . . . . . . . . . . 36
4.1.15 DestroyPage API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.1.16 Set_Label API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.1.17 Get_Label API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.1.18 GetComboOptionLabel API global function . . . . . . . . . . . . . . . . . . . . . . 39
4.1.19 SetComboOptionLabel API global function . . . . . . . . . . . . . . . . . . . . . . 40
4.1.20 ResetComboOptionActive API global function . . . . . . . . . . . . . . . . . . . . 41
4.1.21 GetComboOptionActive API global function . . . . . . . . . . . . . . . . . . . . . 42
4.1.22 SetIconImage API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.1.23 Get_SlidebarValue API global function . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.1.24 SetHistogramPoints API global function . . . . . . . . . . . . . . . . . . . . . . . . 45
4.1.25 SetGraphChartPoints API global function . . . . . . . . . . . . . . . . . . . . . . . 45
4.1.26 GetObjStatus API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.1.27 ShowPage API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.28 RefreshPage API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.29 RefreshPageControl API global function . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.30 ChangePage API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.1.31 Set_LCD_Resolution API global function . . . . . . . . . . . . . . . . . . . . . . . 50
4.1.32 Set_LastFlashMemoryAddress API global function . . . . . . . . . . . . . . . . 51
4.1.33 CursorInit API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.1.34 CursorShow API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.2
Graphic objects API types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.2.1 GL_ErrStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.2 GL_Direction type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.3 GL_ButtonStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.4 GL_ObjType type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.5 GL_Coordinate_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.6 GL_PageControls_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.7 GL_Label_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.2.8 GL_Button_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.2.9 GL_CheckboxObj_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.2.10 GL_SwitchObj_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2.11 GL_RadioButtonGrp_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2.12 GL_RadioButton_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2.13 GL_ComboBoxGrp_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2.14 GL_ComboOption_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Doc ID 16918 Rev 4
3/104
Contents
AN3128
4.2.16 GL_Slidebar_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.2.17 GL_Histogram_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.2.18 GL_GraphChart_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.2.19 GL_ObjDimensions_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.2.20 GL_Page_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.2.21 GL_BusType type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.2.22 LCD_HW_Parameters_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.2.23 TSC_HW_Parameters_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.2.24 JOY_HW_Parameters_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.2.25 JOY_ReadMode type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.2.26 BTN_HW_Parameters_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3
Graphic object API properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3.1
Graphics controls:: properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3.2
Graphic Object:: PagesList array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3.3
LCD:: pLcdParam API properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3.4
Touchscreen:: pTscParam API properties . . . . . . . . . . . . . . . . . . . . . . . 66
4.3.5
Joystick:: pJoyParam API properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.3.6
Push user button:: pBtnParam API properties . . . . . . . . . . . . . . . . . . . . 69
4.4
HAL layer firmware overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5
HAL types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5.1
GL_bool type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5.2
GL_FlagStatus/GL_ITStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5.3
GL_SignalActionType type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5.4
GL_FunctionalState type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5.5
TSC_I2C_SettingsType type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5.6
TSC_Flash_TestStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.5.7
GL_LCD_TypeDef type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6
HAL functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.1 NewLcdHwParamObj HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.2 GL_SetTextColor HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.3 GL_SetBackColor HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.6.4 GL_Clear HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.6.5 GL_LCD_DrawCharTransparent HAL function . . . . . . . . . . . . . . . . . . . 73
4.6.6 GL_LCD_DrawChar HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.6.7 GL_DisplayAdjStringLine HAL function . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.6.8 GL_LCD_DisplayChar HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.6.9 GL_SetDisplayWindow HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4/104
Doc ID 16918 Rev 4
AN3128
Contents
4.6.11 GL_DrawBMP HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.6.12 GL_SetFont HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.6.13 GL_BackLightSwitch HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.6.14 GL_BUSConfig HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.6.15 GL_LCD_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.6.16 NewTscHwParamObj HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.6.17 NewJoyHwParamObj HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.6.18 NewBtnHwParamObj HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.6.19 GL_GPIO_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.6.20 GL_SPI_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.6.21 GL_NVIC_SetVectorTable HAL function . . . . . . . . . . . . . . . . . . . . . . . . 80
4.6.22 GL_NVIC_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.6.23 GL_NVIC_PriorityGroupConfig HAL function . . . . . . . . . . . . . . . . . . . . 81
4.6.24 GL_EXTI_DeInit HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.6.25 GL_EXTI_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.6.26 GL_GPIO_EXTILineConfig HAL function . . . . . . . . . . . . . . . . . . . . . . . 82
4.6.27 GL_EXTI_TSC_IRQHandler HAL function . . . . . . . . . . . . . . . . . . . . . . 83
4.6.28 GL_TSC_Interface_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.6.29 GL_JOY_Interface_Init HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.6.30 GL_JoyStickConfig_IOExpander HAL function . . . . . . . . . . . . . . . . . . . 84
4.6.31 GL_JoyStickConfig_GPIO HAL function . . . . . . . . . . . . . . . . . . . . . . . . 84
4.6.32 GL_JoyStickStateIOEXP HAL function . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.6.33 GL_JoyStickStatePolling HAL function . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.6.34 GL_Delay HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.6.35 TSC_Read HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.6.36 TSC_FLASH_Unlock HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.6.37 TSC_FLASH_ClearFlag HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.6.38 TSC_FLASH_ErasePage HAL function . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.6.39 TSC_FLASH_ProgramWord HAL function . . . . . . . . . . . . . . . . . . . . . . 88
4.6.40 GL_GPIO_ReadInputDataBit HAL function . . . . . . . . . . . . . . . . . . . . . . 89
4.6.41 GL_LCD_CtrlLinesWrite HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.6.42 GL_LCD_ReadRAM HAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.6.43 GL_RCC_APBPeriphClockCmd HAL function . . . . . . . . . . . . . . . . . . . . 90
4.6.44 GL_RCC_AHBPeriphClockCmd HAL function . . . . . . . . . . . . . . . . . . . 91
5
Getting started with the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
5.1
Example application - main.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Doc ID 16918 Rev 4
5/104
[ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • jutuu.keep.pl