void MYDMA_Config(DMA_Channel_TypeDef* DMA_CHx,u32 cpar,u32 cmar,u16 cndtr)
{
NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //使能DMA传输
DMA_DeInit(DMA_CHx); //将DMA的通道1寄存器重设为缺省值
DMA1_MEM_LEN=cndtr;
DMA_InitStructure.DMA_PeripheralBaseAddr = cpar; //DMA外设ADC基地址
DMA_InitStructure.DMA_MemoryBaseAddr = cmar; //DMA内存基地址
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; //数据传输方向,从内存读取发送到外设
DMA_InitStructure.DMA_BufferSize = cndtr; //DMA通道的DMA缓存的大小
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址寄存器不变
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //内存地址寄存器递增
DMA_InitStructure.DMA_PeripheralDataSize =DMA_PeripheralDataSize_Byte ; //数据宽度为8位
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte ; //数据宽度为8位
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //工作在正常缓存模式
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; //DMA通道 x拥有中优先级
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //DMA通道x没有设置为内存到内存传输
DMA_Init(DMA_CHx, &DMA_InitStructure); //根据DMA_InitStruct中指定的参数初始化DMA的通道USART1_Tx_DMA_Channel所标识的寄存器
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(DMA1_Channel3, DMA_IT_TC, ENABLE); //使能DMA传输完成中断
}
/*************************************************************************************************************/
// int32_t x;
// int32_t y;
// for(y = area->y1; y <= area->y2; y++) {
// for(x = area->x1; x <= area->x2; x++) {
// /*Put a pixel to the display. For example:*/
// /*put_px(x, y, *color_p)*/
// LCD_DrawPoint(x, y, color_p->full);
// color_p++;
// }
// }
// u16 height, width;
// uint32_t y=0;
// width = area->x2 -area->x1 + 1;
// height = area->y2 -area->y1 + 1;
// LCD_Address_Set(area->x1,area->y1,area->x2,area->y2);
// for(y = 0; y
// {
// LCD_WR_DATA(color_p->full);
// color_p++;
// }
void DMA1_Channel3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void DMA1_Channel3_IRQHandler(void);
{
if(DMA_GetITStatus(DMA1_IT_TC3))
{
printf("进入DMA中断\r\n"); //无法打印
lv_disp_flush_ready(disp_drv);
DMA_ClearITPendingBit(DMA1_IT_TC3); //清除全部中断标志
}
}
LCD_Fill(area->x1,area->y1,area->x2,area->y2,color_p->full);
/*************************************************************************************************************/
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color) //LCD打印函数
{
u16 color1[1];
u16 num;
color1[0]=color;
num=(xend-xsta+1)*(yend-ysta+1)*2;
LCD_Address_Set(xsta,ysta,xend,yend);//设置显示范围
LCD_CS_Clr();
MYDMA_Config(DMA1_Channel3,(u32)&SPI1->DATAR,(u32)color1,num);
SPI_I2S_DMACmd(SPI1,SPI_I2S_DMAReq_Tx,ENABLE);
MYDMA_Enable(DMA1_Channel3);
LCD_CS_Set();
}
/*************************************************************************************************************/
如果不用DMA,使用以下函数之一是可以打印的
// int32_t x;
// int32_t y;
// for(y = area->y1; y <= area->y2; y++) {
// for(x = area->x1; x <= area->x2; x++) {
// /*Put a pixel to the display. For example:*/
// /*put_px(x, y, *color_p)*/
// LCD_DrawPoint(x, y, color_p->full);
// color_p++;
// }
// }
// u16 height, width;
// uint32_t y=0;
// width = area->x2 -area->x1 + 1;
// height = area->y2 -area->y1 + 1;
// LCD_Address_Set(area->x1,area->y1,area->x2,area->y2);
// for(y = 0; y
// {
// LCD_WR_DATA(color_p->full);
// color_p++;
// }