rt-thread-official/bsp/swm320-lq100/Libraries/SWM320_StdPeriph_Driver/SWM320_lcd.c

148 lines
6.3 KiB
C
Raw Normal View History

2018-12-24 17:17:27 +08:00
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : SWM320_lcd.c
* : SWM320单片机的LCD功能驱动库
* : http://www.synwit.com.cn/e/tool/gbook/?bid=1
* :
* : V1.1.0 20171025
* :
2018-12-24 17:17:27 +08:00
*
*
*******************************************************************************************************************************************
* @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>
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_Init()
* : LCD初始化
* : LCD_TypeDef * LCDx LCDLCD
* LCD_InitStructure * initStruct LCD相关设定值的结构体
* :
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
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;
}
2021-09-30 17:55:16 +08:00
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);
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
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);
2018-12-24 17:17:27 +08:00
LCDx->IE = 1;
2021-09-30 17:55:16 +08:00
LCDx->IF = 1; //清除标志
if (initStruct->IntEOTEn)
LCD_INTEn(LCDx);
else
LCD_INTDis(LCDx);
2018-12-24 17:17:27 +08:00
switch ((uint32_t)LCDx)
{
case ((uint32_t)LCD):
if (initStruct->IntEOTEn)
{
NVIC_EnableIRQ(LCD_IRQn);
}
else
{
NVIC_DisableIRQ(LCD_IRQn);
}
break;
}
}
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_Start()
* :
* : LCD_TypeDef * LCDx LCDLCD
* :
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
void LCD_Start(LCD_TypeDef *LCDx)
{
2021-09-30 17:55:16 +08:00
LCDx->START |= (1 << LCD_START_GO_Pos) | (1 << LCD_START_BURST_Pos);
2018-12-24 17:17:27 +08:00
}
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_IsBusy()
* :
* : LCD_TypeDef * LCDx LCDLCD
* : uint32_t 1 0
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
uint32_t LCD_IsBusy(LCD_TypeDef *LCDx)
{
return (LCDx->START & LCD_START_GO_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_INTEn()
* : LCD中断使能
* : LCD_TypeDef * LCDx LCDLCD
* :
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
void LCD_INTEn(LCD_TypeDef *LCDx)
{
LCDx->IM = 0;
}
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_INTDis()
* : LCD中断禁止
* : LCD_TypeDef * LCDx LCDLCD
* :
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
void LCD_INTDis(LCD_TypeDef *LCDx)
{
LCDx->IM = 1;
}
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_INTClr()
* : LCD中断标志清除
* : LCD_TypeDef * LCDx LCDLCD
* :
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
void LCD_INTClr(LCD_TypeDef *LCDx)
{
LCDx->IF = 1;
}
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : LCD_INTStat()
* : LCD中断状态查询
* : LCD_TypeDef * LCDx LCDLCD
* : uint32_t 1 0
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
uint32_t LCD_INTStat(LCD_TypeDef *LCDx)
{
return (LCDx->IF & 0x01) ? 1 : 0;
}