移植步骤:
1、将裸板的LCD程序复制到新建的文件中,与main工程一起,并lcd.c、lcd.h,然后编译通过。

2、然后cubemx生成的文件。
CUBEMX设置如下:

将cubemx生成的文件中的main.c中的MX_FSMC_Init添加到rtt生成的applications的main.c中

将cubemx生成的文件中的stm32f1xx_hal_msp.c中的HAL_FSMC_MspInit复制到rtt生成的board.c中。

将cubemx生成的文件中的Drivers\STM32F1xx_HAL_Driver\Src文件中的stm32f1xx_ll_fsmc.c文件和stm32f1xx_hal_sram.c复制文件到rtt生成的libraries\STM32F1xx_HAL_Driver\Src文件夹中,并加入编译。

3、在mian.c下面添加代码
static int lcd_display(void)
{
rt_uint8_t x=0;
rt_uint8_t lcd_id[12]; //存放LCD ID字符串
LCD_Init(); //初始化LCD FSMC接口
POINT_COLOR=RED; //画笔颜色:红色
sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//将LCD ID打印到lcd_id数组。
while(1)
{
switch(x)
{
case 0:LCD_Clear(WHITE);break;
case 1:LCD_Clear(BLACK);break;
case 2:LCD_Clear(BLUE);break;
case 3:LCD_Clear(RED);break;
case 4:LCD_Clear(MAGENTA);break;
case 5:LCD_Clear(GREEN);break;
case 6:LCD_Clear(CYAN);break;
case 7:LCD_Clear(YELLOW);break;
case 8:LCD_Clear(BRRED);break;
case 9:LCD_Clear(GRAY);break;
case 10:LCD_Clear(LGRAY);break;
case 11:LCD_Clear(BROWN);break;
}
POINT_COLOR=RED;
LCD_ShowString(30,40,210,24,24,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"TFTLCD TEST");
LCD_ShowString(30,90,200,16,16,"RT-thread");
LCD_ShowString(30,110,200,16,16,lcd_id); //显示LCD ID
LCD_ShowString(30,130,200,12,12,"2014/5/4");
x++;
if(x==12)x=0;
rt_pin_write(LED0_PIN, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(LED0_PIN, PIN_LOW);
rt_thread_mdelay(500);
}
}
MSH_CMD_EXPORT(lcd_display, lcd_display samole);
以上是我的移植过程,最后编译报错:
../applications/main.c: In function 'MX_FSMC_Init':
../applications/main.c:27:3: error: unknown type name 'FSMC_NORSRAM_TimingTypeDef'
FSMC_NORSRAM_TimingTypeDef Timing = {0};
^
../applications/main.c:35:3: error: 'hsram4' undeclared (first use in this function)
hsram4.Instance = FSMC_NORSRAM_DEVICE;
^
../applications/main.c:35:3: note: each undeclared identifier is reported only once for each function it appears in
../applications/main.c:35:21: error: 'FSMC_NORSRAM_DEVICE' undeclared (first use in this function)
hsram4.Instance = FSMC_NORSRAM_DEVICE;
^
../applications/main.c:36:21: error: 'FSMC_NORSRAM_EXTENDED_DEVICE' undeclared (first use in this function)
hsram4.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
^
../applications/main.c:38:24: error: 'FSMC_NORSRAM_BANK4' undeclared (first use in this function)
hsram4.Init.NSBank = FSMC_NORSRAM_BANK4;
^
../applications/main.c:39:32: error: 'FSMC_DATA_ADDRESS_MUX_DISABLE' undeclared (first use in this function)
hsram4.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
^
../applications/main.c:40:28: error: 'FSMC_MEMORY_TYPE_SRAM' undeclared (first use in this function)
hsram4.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
^
../applications/main.c:41:33: error: 'FSMC_NORSRAM_MEM_BUS_WIDTH_16' undeclared (first use in this function)
hsram4.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
^
../applications/main.c:42:33: error: 'FSMC_BURST_ACCESS_MODE_DISABLE' undeclared (first use in this function)
hsram4.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
^
../applications/main.c:43:36: error: 'FSMC_WAIT_SIGNAL_POLARITY_LOW' undeclared (first use in this function)
hsram4.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
^
../applications/main.c:44:26: error: 'FSMC_WRAP_MODE_DISABLE' undeclared (first use in this function)
hsram4.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
^
../applications/main.c:45:34: error: 'FSMC_WAIT_TIMING_BEFORE_WS' undeclared (first use in this function)
hsram4.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
^
../applications/main.c:46:32: error: 'FSMC_WRITE_OPERATION_ENABLE' undeclared (first use in this function)
hsram4.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
^
../applications/main.c:47:28: error: 'FSMC_WAIT_SIGNAL_DISABLE' undeclared (first use in this function)
hsram4.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
^
../applications/main.c:48:30: error: 'FSMC_EXTENDED_MODE_DISABLE' undeclared (first use in this function)
hsram4.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
^
../applications/main.c:49:34: error: 'FSMC_ASYNCHRONOUS_WAIT_DISABLE' undeclared (first use in this function)
hsram4.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
^
../applications/main.c:50:28: error: 'FSMC_WRITE_BURST_DISABLE' undeclared (first use in this function)
hsram4.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
^
../applications/main.c:52:9: error: request for member 'AddressSetupTime' in something not a structure or union
Timing.AddressSetupTime = 15;
^
../applications/main.c:53:9: error: request for member 'AddressHoldTime' in something not a structure or union
Timing.AddressHoldTime = 15;
^
../applications/main.c:54:9: error: request for member 'DataSetupTime' in something not a structure or union
Timing.DataSetupTime = 255;
^
../applications/main.c:55:9: error: request for member 'BusTurnAroundDuration' in something not a structure or union
Timing.BusTurnAroundDuration = 15;
^
../applications/main.c:56:9: error: request for member 'CLKDivision' in something not a structure or union
Timing.CLKDivision = 16;
^
../applications/main.c:57:9: error: request for member 'DataLatency' in something not a structure or union
Timing.DataLatency = 17;
^
../applications/main.c:58:9: error: request for member 'AccessMode' in something not a structure or union
Timing.AccessMode = FSMC_ACCESS_MODE_A;
^
../applications/main.c:58:23: error: 'FSMC_ACCESS_MODE_A' undeclared (first use in this function)
Timing.AccessMode = FSMC_ACCESS_MODE_A;
^
../applications/main.c:61:7: warning: implicit declaration of function 'HAL_SRAM_Init' [-Wimplicit-function-declaration]
if (HAL_SRAM_Init(&hsram4, &Timing, NULL) != HAL_OK)
^
../applications/main.c:61:48: error: 'HAL_OK' undeclared (first use in this function)
if (HAL_SRAM_Init(&hsram4, &Timing, NULL) != HAL_OK)
^
../applications/main.c:63:5: warning: implicit declaration of function 'Error_Handler' [-Wimplicit-function-declaration]
Error_Handler( );
^
../applications/main.c: In function 'lcd_display':
../applications/main.c:80:5: warning: implicit declaration of function 'LCD_Init' [-Wimplicit-function-declaration]
LCD_Init(); //鍒濆鍖朙CD FSMC鎺ュ彛
^
../applications/main.c:81:5: error: 'POINT_COLOR' undeclared (first use in this function)
POINT_COLOR=RED; //鐢荤瑪棰滆壊锛氱孩鑹?
^
../applications/main.c:81:17: error: 'RED' undeclared (first use in this function)
POINT_COLOR=RED; //鐢荤瑪棰滆壊锛氱孩鑹?
^
../applications/main.c:82:5: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//灏哃CD ID鎵撳嵃鍒發cd_id鏁扮粍銆?
^
../applications/main.c:82:5: warning: incompatible implicit declaration of built-in function 'sprintf'
../applications/main.c:82:5: note: include '<stdio.h>' or provide a declaration of 'sprintf'
../applications/main.c:82:41: error: 'lcddev' undeclared (first use in this function)
sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//灏哃CD ID鎵撳嵃鍒發cd_id鏁扮粍銆?
^
../applications/main.c:87:20: warning: implicit declaration of function 'LCD_Clear' [-Wimplicit-function-declaration]
case 0:LCD_Clear(WHITE);break;
^
../applications/main.c:87:30: error: 'WHITE' undeclared (first use in this function)
case 0:LCD_Clear(WHITE);break;
^
../applications/main.c:88:30: error: 'BLACK' undeclared (first use in this function)
case 1:LCD_Clear(BLACK);break;
^
../applications/main.c:89:30: error: 'BLUE' undeclared (first use in this function)
case 2:LCD_Clear(BLUE);break;
^
../applications/main.c:91:30: error: 'MAGENTA' undeclared (first use in this function)
case 4:LCD_Clear(MAGENTA);break;
^
../applications/main.c:92:30: error: 'GREEN' undeclared (first use in this function)
case 5:LCD_Clear(GREEN);break;
^
../applications/main.c:93:30: error: 'CYAN' undeclared (first use in this function)
case 6:LCD_Clear(CYAN);break;
^
../applications/main.c:94:30: error: 'YELLOW' undeclared (first use in this function)
case 7:LCD_Clear(YELLOW);break;
^
../applications/main.c:95:30: error: 'BRRED' undeclared (first use in this function)
case 8:LCD_Clear(BRRED);break;
^
../applications/main.c:96:30: error: 'GRAY' undeclared (first use in this function)
case 9:LCD_Clear(GRAY);break;
^
../applications/main.c:97:31: error: 'LGRAY' undeclared (first use in this function)
case 10:LCD_Clear(LGRAY);break;
^
../applications/main.c:98:31: error: 'BROWN' undeclared (first use in this function)
case 11:LCD_Clear(BROWN);break;
^
../applications/main.c:101:9: warning: implicit declaration of function 'LCD_ShowString' [-Wimplicit-function-declaration]
LCD_ShowString(30,40,210,24,24,"Explorer STM32F4");
^
../applications/main.c:108:9: warning: implicit declaration of function 'rt_pin_write' [-Wimplicit-function-declaration]
rt_pin_write(LED0_PIN, PIN_HIGH);
^
../applications/main.c:108:22: error: 'LED0_PIN' undeclared (first use in this function)
rt_pin_write(LED0_PIN, PIN_HIGH);
^
../applications/main.c:108:32: error: 'PIN_HIGH' undeclared (first use in this function)
rt_pin_write(LED0_PIN, PIN_HIGH);
^
../applications/main.c:110:32: error: 'PIN_LOW' undeclared (first use in this function)
rt_pin_write(LED0_PIN, PIN_LOW);
^
../applications/main.c:113:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
../applications/main.c: At top level:
../applications/main.c:20:13: warning: 'MX_FSMC_Init' defined but not used [-Wunused-function]
static void MX_FSMC_Init(void)
^
make: *** [applications/subdir.mk:21: applications/main.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j12 all" terminated with exit code 2. Build might be incomplete.
是什么地方有问题?希望大佬给看一下。
举报
举报
更多回帖