rt-thread-official/bsp/swm320/libraries/SWM320_StdPeriph_Driver/SWM320_lcd.c

155 lines
5.9 KiB
C
Raw Normal View History

2021-02-18 13:29:12 +08:00
/******************************************************************************************************************************************
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: SWM320_lcd.c
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: SWM320<EFBFBD><EFBFBD>Ƭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>: http://www.synwit.com.cn/e/tool/gbook/?bid=1
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: V1.1.0 2017<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD>25<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:
*
*
*******************************************************************************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
* REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
* FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
* -ECTION WITH THEIR PRODUCTS.
*
* COPYRIGHT 2012 Synwit Technology
*******************************************************************************************************************************************/
#include "SWM320.h"
#include "SWM320_lcd.h"
#include <string.h>
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_Init()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: LCD<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* LCD_InitStructure * initStruct <EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ľ<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
void LCD_Init(LCD_TypeDef * LCDx, LCD_InitStructure * initStruct)
{
switch((uint32_t)LCDx)
{
case ((uint32_t)LCD):
SYS->CLKEN |= (0x01 << SYS_CLKEN_LCD_Pos);
break;
}
if(initStruct->Interface == LCD_INTERFACE_RGB)
{
LCDx->START = (0 << LCD_START_MPUEN_Pos);
LCDx->CR0 = ((initStruct->HnPixel - 1) << LCD_CR0_HPIX_Pos) |
((initStruct->VnPixel - 1) << LCD_CR0_VPIX_Pos) |
(initStruct->ClkAlways << LCD_CR0_DCLK_Pos) |
(initStruct->HsyncWidth << LCD_CR0_HLOW_Pos);
LCDx->CR1 = ((initStruct->Hfp - 1) << LCD_CR1_HFP_Pos) |
((initStruct->Hbp - 1) << LCD_CR1_HBP_Pos) |
((initStruct->Vfp - 1) << LCD_CR1_VFP_Pos) |
((initStruct->Vbp - 1) << LCD_CR1_VBP_Pos) |
(initStruct->ClkDiv << LCD_CR1_DCLKDIV_Pos) |
(initStruct->SamplEdge << LCD_CR1_DCLKINV_Pos);
}
else if(initStruct->Interface == LCD_INTERFACE_I80)
{
//
}
LCDx->IE = 1;
LCDx->IF = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
if(initStruct->IntEOTEn) LCD_INTEn(LCDx);
else LCD_INTDis(LCDx);
switch((uint32_t)LCDx)
{
case ((uint32_t)LCD):
if(initStruct->IntEOTEn)
{
NVIC_EnableIRQ(LCD_IRQn);
}
else
{
NVIC_DisableIRQ(LCD_IRQn);
}
break;
}
}
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_Start()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
void LCD_Start(LCD_TypeDef * LCDx)
{
LCDx->START |= (1 << LCD_START_GO_Pos) | (1 << LCD_START_BURST_Pos);
}
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_IsBusy()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
uint32_t LCD_IsBusy(LCD_TypeDef * LCDx)
{
return (LCDx->START & LCD_START_GO_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTEn()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: LCD<EFBFBD>ж<EFBFBD>ʹ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
void LCD_INTEn(LCD_TypeDef * LCDx)
{
LCDx->IM = 0;
}
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTDis()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: LCD<EFBFBD>жϽ<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
void LCD_INTDis(LCD_TypeDef * LCDx)
{
LCDx->IM = 1;
}
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTClr()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: LCD<EFBFBD>жϱ<EFBFBD>־<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
void LCD_INTClr(LCD_TypeDef * LCDx)
{
LCDx->IF = 1;
}
/******************************************************************************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTStat()
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: LCD<EFBFBD>ж<EFBFBD>״̬<EFBFBD><EFBFBD>ѯ
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: LCD_TypeDef * LCDx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
******************************************************************************************************************************************/
uint32_t LCD_INTStat(LCD_TypeDef * LCDx)
{
return (LCDx->IF & 0x01) ? 1 : 0;
}