environment:
Host: WIN8
Development environment: MDK5.13
emwin version: STemWinLibrary522
mcu: stm32f407VGT6
Development board: Anfulai STM32-X3
TFT model: Ailan 2.8-inch TFT, main control chip: ILI9325
illustrate:
Porting emwin on STM32F407, driving the screen interface to FSMC
Transplantation steps:
1. MDK new file structure:
2. GUIConf.c file modification
a) Add macro definition:
#define GUI_NUMBYTES (1024 * 80)
#define GUI_BLOCKSIZE 0x80
b) Add the following statement to the GUI_X_Config(void) function:
GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
After modification:
/*********************************************************************
*
* GUI_X_Config
*
* Purpose:
* Called during the initialization process in order to set up the
* available memory for the GUI.
*/
void GUI_X_Config(void) {
//
// 32 bit aligned memory area
//
static U32 aMemory[GUI_NUMBYTES / 4];
//
// Assign memory to emWin
//
GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
//
// Set default font
//
GUI_SetDefaultFont(GUI_FONT_6X8);
}
3. LCDConf_FlexColor_Template.c file modification
a) Add macro definition:
#define LCD_REG_ADDRESS BANK1_LCD_REG
#define LCD_DATA_ADDRESS BANK1_LCD_RAM
These two BANK macro definitions are defined in the tft driver file:
#define BANK1_BASE ((uint32_t)(0x60000000 | 0x00000000))
#define BANK1_LCD_RAM *(__IO uint16_t *)(BANK1_BASE + (1 << (18 + 1))) /* In FSMC 16-bit bus mode, FSMC_A18 port line corresponds to physical address A19 */
#define BANK1_LCD_REG *(__IO uint16_t *)(BANK1_BASE)
Specific values are related to wiring
b) Specific function modification
/*********************************************************************
*
* Local functions
*
**********************************************************************
*/
/********************************************************************
*
* LcdWriteReg
*
* Function description:
* Sets display register
*/
static void LcdWriteReg(U16 Data) {
// ... TBD by user
LCD_REG_ADDRESS = Data;
}
/********************************************************************
*
* LcdWriteData
*
* Function description:
* Writes a value to a display register
*/
static void LcdWriteData(U16 Data) {
// ... TBD by user
LCD_DATA_ADDRESS=Data;
}
/********************************************************************
*
* LcdWriteDataMultiple
*
* Function description:
* Writes multiple values to a display register.
*/
static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
while (NumItems--) {
// ... TBD by user
LCD_DATA_ADDRESS=*pData++;
}
}
/********************************************************************
*
* LcdReadDataMultiple
*
* Function description:
* Reads multiple values from a display register.
*/
static void LcdReadDataMultiple(U16 * pData, int NumItems) {
while (NumItems--) {
// ... TBD by user
*pData++=LCD_DATA_ADDRESS;
}
}
/*********************************************************************
*
* Public functions
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_X_Config
*
* Function description:
* Called during the initialization process in order to set up the
* display driver configuration.
*
*/
void LCD_X_Config(void) {
GUI_DEVICE * pDevice;
CONFIG_FLEXCOLOR Config = {0};
GUI_PORT_API PortAPI = {0};
//
// Set display driver and color conversion
//
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
//
// Display driver configuration, required for Lin-driver
//
LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
//
// Orientation
//
//Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
Config.FirstCOM = 0;
Config.FirstSEG = 0;
//Config.Orientation = GUI_MIRROR_X | GUI_MIRROR_Y;
Config.NumDummyReads = 2;
GUIDRV_FlexColor_Config(pDevice, &Config);
//
// Set controller and operation mode
//
PortAPI.pfWrite16_A0 = LcdWriteReg;
PortAPI.pfWrite16_A1 = LcdWriteData;
PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);
//GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);
}
Among them: GUIDRV_FlexColor_SetFunc function description:
Because the main control chip is ILI9325, the parameter is selected as GUIDRV_FLEXCOLOR_F66708
4. GUI_X.c file modification
This file controls the delay in the GUI, which can be implemented with a timer. The modifications are as follows:
/*********************************************************************
*
* Global data
*/
volatile GUI_TIMER_TIME OS_TimeMS;
/*********************************************************************
*
* Timing:
* GUI_X_GetTime()
* GUI_X_Delay(int)
Some timing dependent routines require a GetTime
and delay function. Default time unit (tick), normally is
1 ms.
*/
extern __IO int32_t g_iRunTime;
GUI_TIMER_TIME GUI_X_GetTime(void) {
//return OS_TimeMS;
return g_iRunTime;
}
void GUI_X_Delay(int ms) {
// int tEnd = OS_TimeMS + ms;
// while ((tEnd - OS_TimeMS) > 0);
int tEnd = g_iRunTime + ms;
while ((tEnd - g_iRunTime) > 0);
}
5. Main function implementation:
int main(void)
{
/*
The startup file in the ST firmware library has already executed the SystemInit() function, which is in the system_stm32f4xx.c file. Its main function is
Configure the CPU system clock, internal Flash access timing, and configure FSMC for external SRAM
*/
bsp_Init(); /* Hardware initialization */
PrintfLogo(); /* Print routine information to serial port 1 */
vLCDInit();
// vClearScreen(Green);
// vSetTextColor(Red);
// vPutString(20,0, "NanJing RF Tracking!!!!!");
// ShowImage();
//DemoFatFS(); /* SD card file system demonstration program */
//RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
GUI_Init();
GUI_DispString("I am jdh!");
while (1)
{
GUI_Delay(1000);
}
}
Notice:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
The function is necessary, otherwise the GUI will not work. This is a measure taken by ST to prevent other chips from using this GUI.
Effect:
References:
1. STemWin5.22 transplantation notes
2. "Wildfire emwin practical guide V1.0.0"
3. Anfulai source code: x3 development board_bare metal STemWin5.20
Previous article:Driver font chip GT23L24M0140
Next article:ucos-ii example 7: memory management test
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- "Playing with the Board" + Replaying MicroPython on the STM32F7DISC (1)
- Which sensor is suitable for an automatic disinfectant machine to provide a liquid shortage reminder?
- How to enable wireless triggering of devices via bootloading using a Bluetooth serial adapter
- USB TypeC training PPT materials from Tektronix Labs Open Day are here. Download for a limited time to get a gift (including training videos)
- LIS25BA can record, but there is "interference"
- TI chip strange labeling
- Millions of 103 series MCU stocks are about to be released!!!
- 30 EMC standard circuits shared, it will be too late if you don’t save them now!
- How to expand NorFLASH using IAR?
- Analysis of the voltage following circuit of the operational amplifier