2021-09-09 19:47:51 索煒達電子 1020
項目編號:E958
文件大小:6M
源碼說明:帶中文注釋
開發(fā)環(huán)境:C編譯器
簡要概述:
特別提醒的是:
我原來的項目是用的GUI是:emWin,項目文件很大,不利于理解。
下面我發(fā)的 littleVgl 簡單測試項目文件,對于你們想采用SPI DMA的功能來說,足夠用的了!
1、請看LCD 接口說明:
/*----------------------------------------------------------------------------
* Simple STM32F103 using littleVgl: *
* ILI9341 display over SPI with DMA, *
* XPT2046 resistive touch panel *
* *
* ILI9341 SPI1 CONNECTIONS: *
* ------------------------------- *
* TFT_RESET PC1 *
* TFT_DC PC2 *
* TFT_CS PC0 *
* TFT_SCK PA5 *
* TFT_MISO PA6 *
* TFT_MOSI PA7 *
* *
* XPT2046 SPI2 CONNECTIONS: *
* -------------------------------- *
* TOUCH_CLK PB13 *
* TOUCH_DIN (MOSI) PB15 *
* TOUCH_DO (MISO) PB14 *
* TOUCH_CS PB12 *
* TOUCH_IRQ PA0 *
* *
* *
* *
*-------------------------------------------------------------------------*/
2、項目文件: GUI: littleVgl
//****************項目內(nèi)容說明如下**************//
3、請你們自己看 ILI9341\core.c文件的內(nèi)容,使用的就是:SPI_DMA
//重要函數(shù):
void Send_DMA_Data16(uint16_t* buff, uint16_t dataSize)
{
LL_SPI_SetDataWidth(SPI1, LL_SPI_DATAWIDTH_16BIT);
LL_SPI_Disable(SPI1);
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_3);
LL_DMA_ClearFlag_TC3(DMA1);
LL_DMA_ClearFlag_TE3(DMA1);
LL_SPI_EnableDMAReq_TX(SPI1);
LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_3);
LL_DMA_EnableIT_TE(DMA1, LL_DMA_CHANNEL_3);
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_3);
LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_3, dataSize);
LL_DMA_ConfigAddresses(DMA1, LL_DMA_CHANNEL_3, (uint32_t)buff, LL_SPI_DMA_GetRegAddr(SPI1),
LL_DMA_GetDataTransferDirection(DMA1, LL_DMA_CHANNEL_3));
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_3);
LL_SPI_Enable(SPI1);
while (!flag_DMA_CH3_bsy) {
}
flag_DMA_CH3_bsy = 0;
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_3);
LL_SPI_Disable(SPI1);
LL_DMA_ClearFlag_TC3(DMA1);
LL_DMA_ClearFlag_TE3(DMA1);
LL_SPI_DisableDMAReq_TX(SPI1);
LL_DMA_DisableIT_TC(DMA1, LL_DMA_CHANNEL_3);
LL_DMA_DisableIT_TE(DMA1, LL_DMA_CHANNEL_3);
LL_SPI_Enable(SPI1);
LL_SPI_SetDataWidth(SPI1, LL_SPI_DATAWIDTH_8BIT);
}
void ILI9341_fillRect(uint16_t x1, uint16_t y1, uint16_t w, uint16_t h, uint16_t color)
{
uint16_t tbuf[w];
TFT_CS_RESET;
ILI9341_setAddressWindow(x1, y1, (uint16_t) (x1 + w - 1), (uint16_t) (y1 + h - 1));
TFT_DC_D
for (int x = w ; x >= 0; x--)
tbuf[x] = color;
for (y1 = h; y1 > 0; y1--)
Send_DMA_Data16(tbuf,w);
TFT_CS_SET;
}
4、DMA傳輸,在傳輸大量數(shù)據(jù)的情況下,就顯示出它的巨大優(yōu)勢了!
=== 填充矩形功能,就是使用大量數(shù)據(jù)的情況,
=== 其它的一般功能,就采用傳統(tǒng)的操作就可以了。
5、在項目中,還有SPI傳輸,采用可變的8bit, 16bit,更能體現(xiàn)執(zhí)行效率
6、項目運行測試界面如下:
目錄│文件列表:
└ lvgl_STM32F103_ILI9341_SPIDMA
└ lvgl_STM32F103_ILI9341_SPIDMA
│ .gitignore
│ .gitmodules
│ lv_conf.h
│ README.md
├ benchmark
│ │ benchmark.c
│ │ benchmark.h
│ │ benchmark.mk
│ │ benchmark_bg.png
│ └ img_benchmark_bg.c
├ demo
│ │ bubble_pattern.png
│ │ demo.c
│ │ demo.h
│ │ demo.mk
│ │ img_bubble_pattern.c
│ └ lv_ex_conf.h
├ Drivers
│ ├ CMSIS
│ │ ├ Core
│ │ │ ├ Include
│ │ │ │ │ cmsis_armcc.h
│ │ │ │ │ cmsis_armclang.h
│ │ │ │ │ cmsis_compiler.h
│ │ │ │ │ cmsis_gcc.h
│ │ │ │ │ cmsis_iccarm.h
│ │ │ │ │ cmsis_version.h
│ │ │ │ │ core_armv8mbl.h
│ │ │ │ │ core_armv8mml.h
│ │ │ │ │ core_cm0.h
│ │ │ │ │ core_cm0plus.h
│ │ │ │ │ core_cm1.h
│ │ │ │ │ core_cm23.h
│ │ │ │ │ core_cm3.h
│ │ │ │ │ core_cm33.h
│ │ │ │ │ core_cm4.h
│ │ │ │ │ core_cm7.h
│ │ │ │ │ core_sc000.h
│ │ │ │ │ core_sc300.h
│ │ │ │ │ mpu_armv7.h
│ │ │ │ │ mpu_armv8.h
│ │ │ │ └ tz_context.h
│ │ │ └ Template
│ │ │ └ ARMv8-M
│ │ │ │ main_s.c
│ │ │ └ tz_context.c
│ │ ├ Core_A
│ │ │ ├ Include
│ │ │ │ │ cmsis_armcc.h
│ │ │ │ │ cmsis_armclang.h
│ │ │ │ │ cmsis_compiler.h
│ │ │ │ │ cmsis_cp15.h
│ │ │ │ │ cmsis_gcc.h
│ │ │ │ │ cmsis_iccarm.h
│ │ │ │ │ core_ca.h
│ │ │ │ └ irq_ctrl.h
│ │ │ └ Source
│ │ │ └ irq_ctrl_gic.c
│ │ ├ Device
│ │ │ └ ST
│ │ │ └ STM32F1xx
│ │ │ ├ Include
│ │ │ │ │ stm32f100xb.h
│ │ │ │ │ stm32f100xe.h
│ │ │ │ │ stm32f101x6.h
│ │ │ │ │ stm32f101xb.h
│ │ │ │ │ stm32f101xe.h
│ │ │ │ │ stm32f101xg.h
│ │ │ │ │ stm32f102x6.h
│ │ │ │ │ stm32f102xb.h
│ │ │ │ │ stm32f103x6.h
│ │ │ │ │ stm32f103xb.h
│ │ │ │ │ stm32f103xe.h
│ │ │ │ │ stm32f103xg.h
│ │ │ │ │ stm32f105xc.h
│ │ │ │ │ stm32f107xc.h
│ │ │ │ │ stm32f1xx.h
│ │ │ │ └ system_stm32f1xx.h
│ │ │ └ Source
│ │ │ └ Templates
│ │ │ │ system_stm32f1xx.c
│ │ │ ├ arm
│ │ │ │ │ startup_stm32f100xb.s
│ │ │ │ │ startup_stm32f100xe.s
│ │ │ │ │ startup_stm32f101x6.s
│ │ │ │ │ startup_stm32f101xb.s
│ │ │ │ │ startup_stm32f101xe.s
│ │ │ │ │ startup_stm32f101xg.s
│ │ │ │ │ startup_stm32f102x6.s
│ │ │ │ │ startup_stm32f102xb.s
│ │ │ │ │ startup_stm32f103x6.s
│ │ │ │ │ startup_stm32f103xb.s
│ │ │ │ │ startup_stm32f103xe.s