2022-10-19 22:44:15 +08:00

155 lines
5.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************************************************************************
* <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: SWM320_lcd.c
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: SWM320<32><30>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>LCD<43><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>: http://www.synwit.com.cn/e/tool/gbook/?bid=1
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
* <20><EFBFBD><E6B1BE><EFBFBD><EFBFBD>: V1.1.0 2017<31><37>10<31><30>25<32><35>
* <20><><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>
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_Init()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: LCD<43><44>ʼ<EFBFBD><CABC>
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* LCD_InitStructure * initStruct <20><><EFBFBD><EFBFBD>LCD<43><44><EFBFBD><EFBFBD><EFBFBD>趨ֵ<E8B6A8>Ľṹ<C4BD><E1B9B9>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
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;
}
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_Start()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void LCD_Start(LCD_TypeDef * LCDx)
{
LCDx->START |= (1 << LCD_START_GO_Pos) | (1 << LCD_START_BURST_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_IsBusy()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* <20><> <20><>: uint32_t 1 <20><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t LCD_IsBusy(LCD_TypeDef * LCDx)
{
return (LCDx->START & LCD_START_GO_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: LCD<43>ж<EFBFBD>ʹ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void LCD_INTEn(LCD_TypeDef * LCDx)
{
LCDx->IM = 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: LCD<43>жϽ<D0B6>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void LCD_INTDis(LCD_TypeDef * LCDx)
{
LCDx->IM = 1;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTClr()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: LCD<43>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void LCD_INTClr(LCD_TypeDef * LCDx)
{
LCDx->IF = 1;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LCD_INTStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: LCD<43>ж<EFBFBD>״̬<D7B4><CCAC>ѯ
* <20><> <20><>: LCD_TypeDef * LCDx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>LCD<43><44><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>LCD
* <20><> <20><>: uint32_t 1 <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD> 0 δ<><CEB4><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t LCD_INTStat(LCD_TypeDef * LCDx)
{
return (LCDx->IF & 0x01) ? 1 : 0;
}