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

146 lines
6.4 KiB
C
Raw Normal View History

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