?? glasslcd.c
字號(hào):
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : glasslcd.c
* Author : MCD Application Team
* Version : V1.0.0
* Date : 07/21/2008
* Description : LCD glass driver file using Timer method and Sleep Mode
********************************************************************************
* 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, STMICROELECTRONICS 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 CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "glasslcd.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#ifdef USE_LCD_REF_CT4_098
#define NumberOfUsedDigits 4 /* For CT4_098 LCD reference */
#else
#define NumberOfUsedDigits 8 /* For PD-878 LCD reference */
#endif
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Global variables definition and initialization ----------------------------*/
u16 SegmentsValues_Lower_Quarter_Digits[4]; /* LCD frame buffer for low
quarter digits (digits 1 -> 4) */
u16 SegmentsValues_Higher_Quarter_Digits[4]; /* LCD frame buffer for high
quarter digits (digits 5 -> 8) */
u16 digit[4]; /* Digit frame buffer */
#ifdef CommonLines_EightHighPortPins
const u16 CommonLine[4]={
1<<(CommonLines_Pin_Offset+8),
2<<(CommonLines_Pin_Offset+8),
4<<(CommonLines_Pin_Offset+8),
8<<(CommonLines_Pin_Offset+8)
};
#else
const u16 CommonLine[4]={
1<<CommonLines_Pin_Offset,
2<<CommonLines_Pin_Offset,
4<<CommonLines_Pin_Offset,
8<<CommonLines_Pin_Offset
};
#endif
/* GPIOs to be configured to VDD/2 */
u32 CommonLine_VDD_2[4]={
0xFFFF000F,
0xFFFF00F0,
0xFFFF0F00,
0xFFFFF000
};
/* GPIOs to be configured to Output PP */
u32 CommonLine_OUT_PP[4]={
0x00000003,
0x00000030,
0x00000300,
0x00003000
};
/* =========================================================================
LCD MAPPING
=========================================================================
A
-- ----------
X \/ |\ |I /|
F| H | J |B
| \ | / |
--G-- --K--
| /| \ |
E | L | N |C
| / |M \| _
----------- | |DP
D -
A LCD character coding is based on the following matrix:
===========================
The PD-878 LCD matrix map:
===========================
{ X , F , E , D }
{ I , J , K , N }
{ A , B , C , DP }
{ H , G , L , M }
The characher A for example is:
-------------------------------
{ 0 , 1 , 1 , 0 }
{ 0 , 0 , 1 , 0 }
{ 1 , 1 , 1 , 0 }
{ 0 , 1 , 0 , 0 }
-------------------
= 4 D 7 0 hex
=> 'A' = 0x4D70
============================
The CT4-098 LCD matrix map:
============================
{ X , I , A , DP }
{ F , J , K , B }
{ E , G , H , C }
{ M , L , N , D }
The characher A for example is:
-------------------------------
{ 0 , 1 , 1 , 0 }
{ 0 , 0 , 1 , 0 }
{ 1 , 0 , 1 , 0 }
{ 0 , 1 , 1 , 0 }
-------------------
= 4 9 F 0 hex
=> 'A' = 0x49F0
*/
/* =========================================================================
LETTERS AND NUMBERS MAPPING DEFINITION
========================================================================= */
#ifdef USE_LCD_REF_PD_878 /* Letters and number map of PD_878 LCD */
const u16 LetterMap[26]=
{
/* A B C D E F G H I */
0x4D70,0x6469,0x4111,0x6449,0x4911,0x4910,0x4171,0x0D70,0x6009,
/* J K L M N O P Q R */
0x0451,0x0B12,0x0111,0x8750,0x8552,0x4551,0x4D30,0x4553,0x4D32,
/* S T U V W X Y Z */
0x4961,0x6008,0x0551,0x0390,0x05D2,0x8282,0x8208,0x4281
};
const u16 NumberMap[10]=
{
/* 0 1 2 3 4 5 6 7 8 9 */
0x47D1,0x0640,0x4C31,0x4C61,0x0D60,0x4961,0x4971,0x4440,0x4D71,0x4D61
};
#endif
#ifdef USE_LCD_REF_CT4_098 /* Letters and number map of CT4_098 LCD */
const u16 LetterMap[26]=
{
/* A B C D E F G H I */
0x49F0,0x01F8,0x4118,0x08F8,0x4178,0x4170,0x41D8,0x09F0,0x600A,
/* J K L M N O P Q R */
0x0888,0x0534,0x0118,0x0F90,0x0B94,0x4998,0x4970,0x499C,0x4974,
/* S T U V W X Y Z */
0x41E8,0x6002,0x0998,0x0511,0x299A,0x0605,0x0601,0x4409
};
const u16 NumberMap[10]=
{ /* 0 1 2 3 4 5 6 7 8 9 */
0x4998,0x0880,0x4878,0x48E8,0x09E0,0x41E8,0x41F8,0x4880,0x49F8,0x49E8
};
#endif
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : OffsetValue
* Description : computes the offset to add to the GPIO masks
* Input : - Pin_offset: pin offset.
* Output : None.
* Return : None.
*******************************************************************************/
u32 OffsetValue(u8 Pin_offset)
{
u8 i;
u32 offset_Value = 1;
for (i=0; i<Pin_offset; i++)
{
offset_Value = offset_Value * 16;
}
return (offset_Value - 1);
}
/*******************************************************************************
* Function Name : LCD_GPIO_Masks_Init
* Description : initilizes the LCD GPIOs masks.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void LCD_GPIO_Coms_Masks_Init(void)
{
u8 i;
for (i=0; i<4; i++)
{
CommonLine_VDD_2[i] = (CommonLine_VDD_2[i] << ((CommonLines_Pin_Offset) * 4))\
+ OffsetValue(CommonLines_Pin_Offset);
CommonLine_OUT_PP[i] = CommonLine_OUT_PP[i] << ((CommonLines_Pin_Offset) * 4);
}
}
/*******************************************************************************
* Function Name : Convert
* Description : converts an ascii char to the a LCD digit (previous coding)
* Input : - c: a char to display.
* - point: flag indicating if a point has to be add in front of
* displayed character (0: no, 1: yes)
* Output : None.
* Return : None.
*******************************************************************************/
void Convert(char* c,u8 point)
{
u16 car=0,tmp;
u8 i;
const u16 mask[4]={0xF000,0x0F00,0x00F0,0x000F};
const u8 shift[3]={12,8,4};
if ((*c<0x5B)&(*c>0x40))
{
car = LetterMap[*c-0x41];
}
if ((*c<0x3A)&(*c>0x2F))
{
car = NumberMap[*c-0x30];
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -