📄 es449_sblcda2t.c
字号:
//************************************************************
// Copyright (C) 2004 Texas Instruments, Inc.
//
// File: es449_sblcda2t.c
//
// Comment: LCD drivers for SoftBaugh ES449 demo board
//
// Author: Randy Wu
// Company: Texas Instruments, Inc
// Date: September 2004
// IDE: Built with IAR Systems Embedded Workbench 430 V3.20A
//
// Hardware:
// - SoftBaugh SBLCDA2/T 7-Segment 4-Mux LCD
//************************************************************/
#include "app.h"
#include "es449_sblcda2t.h"
void LCD_displayAccessories(void)
{
static int m_nAccessoryState = 0;
switch( m_nAccessoryState )
{ case 0:
LCDM1 = 0x2F; // S1:S0
LCDM2 = 0x1F; // S3:S2
break;
case 1:
LCDM1 = 0x2F; // S1:S0
LCDM2 = 0x2D; // S3:S2
break;
case 2:
LCDM1 = 0x0F; // S1:S0
LCDM2 = 0x4D; // S3:S2
break;
case 3:
LCDM1 = 0x0F; // S1:S0
LCDM2 = 0x8D; // S3:S2
break;
case 4:
LCDM1 = 0x2F; // S1:S0
LCDM2 = 0x19; // S3:S2
break;
case 5:
LCDM1 = 0x3F; // S1:S0
LCDM2 = 0x29; // S3:S2
break;
case 6:
LCDM1 = 0x2F; // S1:S0
LCDM2 = 0x49; // S3:S2
break;
case 7:
LCDM1 = 0x3F; // S1:S0
LCDM2 = 0x81; // S3:S2
break;
case 8:
LCDM1 = 0xBF; // S1:S0
LCDM2 = 0x11; // S3:S2
break;
case 9:
LCDM1 = 0xFF; // S1:S0
LCDM2 = 0x20; // S3:S2
break;
case 10:
LCDM1 = 0xBF; // S1:S0
LCDM2 = 0x40; // S3:S2
break;
case 11:
LCDM1 = 0xFF; // S1:S0
LCDM2 = 0x8F; // S3:S2
break;
default:
m_nAccessoryState = 0;
}
m_nAccessoryState++;
if( m_nAccessoryState >= 12 )
m_nAccessoryState = 0;
}
void LCD_init(void)
{
P4SEL = 0xFF;
P4DIR = 0xFF;
P5SEL = 0xFF;
P5DIR = 0xFF;
// Setup Basic Timer for LCD operation
BTCTL = (BT_fLCD_DIV64 + BTDIV + BTIP1 + BTIP0);
// Setup LCD
LCDCTL = (LCDSG0_7 + LCD4MUX + LCDON);
LCD_putHex(DSPDEGREES_34, NUM_DISPLAY_3);
LCD_putHex(DSPF_34, NUM_DISPLAY_4);
}
/***********************************************************/
/* Function put_char(unsigned int val, unsigned char loc) */
/* */
/* Description: Output the specified value to the given */
/* LCD location. Locations referred to are */
/* the 7 main characters. */
/***********************************************************/
void LCD_putChar(unsigned int val, unsigned char loc)
{
switch(loc) {
case CHAR_DISPLAY_1:
LCDM19 = val;
LCDM20 = val >> 8;
break;
case CHAR_DISPLAY_2:
LCDM17 = val;
LCDM18 = val >> 8;
break;
case CHAR_DISPLAY_3:
LCDM15 = val;
LCDM16 = val >> 8;
break;
case CHAR_DISPLAY_4:
LCDM13 = val;
LCDM14 = val >> 8;
break;
case CHAR_DISPLAY_5:
LCDM11 = val;
LCDM12 = val >> 8;
break;
case CHAR_DISPLAY_6:
LCDM9 = val;
LCDM10 = val >> 8;
break;
case CHAR_DISPLAY_7:
LCDM7 = val;
LCDM8 = val >> 8;
break;
default:
// ERROR
break;
}// end switch(loc)
}
/***********************************************************/
/* Function put_hex(unsigned char val, unsigned char loc) */
/* */
/* Description: Output the specified value to the given */
/* LCD location. Locations referred to are */
/* the 4 smaller characters in the upper */
/* right of the LCD. */
/***********************************************************/
void LCD_putHex(unsigned char val, unsigned char loc)
{
switch(loc) {
case NUM_DISPLAY_1:
LCDM6 = val;
break;
case NUM_DISPLAY_2:
LCDM5 = val;
break;
case NUM_DISPLAY_3:
LCDM4 = val;
break;
case NUM_DISPLAY_4:
LCDM3 = val;
break;
default:
// ERROR
break;
} // end switch(loc)
}
void LCD_putMUTE(void)
{
LCD_putChar(CHARM, CHAR_DISPLAY_1);
LCD_putChar(CHARU, CHAR_DISPLAY_2);
LCD_putChar(CHART, CHAR_DISPLAY_3);
LCD_putChar(CHARE, CHAR_DISPLAY_4);
}
void LCD_putON(void)
{
LCD_putChar(CHARSPACE, CHAR_DISPLAY_1);
LCD_putChar(CHARO, CHAR_DISPLAY_2);
LCD_putChar(CHARN, CHAR_DISPLAY_3);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_4);
}
void LCD_putOFF(void)
{
LCD_putChar(CHARO, CHAR_DISPLAY_1);
LCD_putChar(CHARF, CHAR_DISPLAY_2);
LCD_putChar(CHARF, CHAR_DISPLAY_3);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_4);
}
void LCD_splashScreen(void)
{
unsigned int i, k;
LCD_putChar(CHARM, CHAR_DISPLAY_1);
LCD_putChar(CHARS, CHAR_DISPLAY_2);
LCD_putChar(CHARP, CHAR_DISPLAY_3);
LCD_putChar(CHAR4, CHAR_DISPLAY_4);
LCD_putChar(CHAR3, CHAR_DISPLAY_5);
LCD_putChar(CHAR0, CHAR_DISPLAY_6);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_7);
for (i = 0; i < LCD_PRIMARYDELAY; i++)
for (k = 0; k < LCD_SECONDARYDELAY; k++);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_1);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_2);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_3);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_4);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_5);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_6);
LCD_putChar(CHARSPACE, CHAR_DISPLAY_7);
}
// This function coverts a number to its equivalent bit mask to
// display on LCD locations 1 & 2. (The 2 MSB's of the 4 smaller
// characters in the upper right of the LCD)
char LCD_convertNumToCharFor12(char num)
{
switch(num) {
case 0:
return DSP0_12;
case 1:
return DSP1_12;
case 2:
return DSP2_12;
case 3:
return DSP3_12;
case 4:
return DSP4_12;
case 5:
return DSP5_12;
case 6:
return DSP6_12;
case 7:
return DSP7_12;
case 8:
return DSP8_12;
case 9:
return DSP9_12;
}
return 0;
}
void LCD_displayTemperature(int temp)
{
static unsigned long int DegC, DegF;
DegC = ((((long)temp-1615)*704)/4095); // Celsius
DegF = ((DegC * 9/5)+32); // Farhenheit
// Display 10's digit of temperature
LCD_putHex(LCD_convertNumToCharFor12(DegF / 10), NUM_DISPLAY_1);
// Display 1's digit of temperature
LCD_putHex(LCD_convertNumToCharFor12(DegF % 10), NUM_DISPLAY_2);
// then "degrees F"
//LCD_putHex(DSPDEGREES_34,NUM_DISPLAY_3);
//LCD_putHex(DSPF_34,NUM_DISPLAY_4);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -