⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lh7a400_sevenseg.c

📁 sharp触摸屏测试代码
💻 C
字号:
/**********************************************************************
 * $Workfile:   LH7A400_sevenseg.c  $
 * $Revision:   1.4  $
 * $Author:   BarnettH  $
 * $Date:   Jun 12 2002 18:38:20  $
 *
 * Project: LH7A400 EVB -- Aruba Platform
 *
 * Description:
 * 	  Seven-segment LED routines for LH7A400 EVB Platform
 * 	  
 * Usage:
 * 		These routines display hexadecimal numbers, and
 * 		can enable a "decimal" point in the lower right 
 * 		corner of both LEDS. The "MSB" LED is on the left,
 * 		and the "MSB" LED is on the right.
 * 		
 * 		set_hexleds (x, DP_ON) will set both leds to the
 * 		hexadecimal value (0-255) of the argument 'x'
 * 		and enable the decimal point on the right led.
 * 		To deactivate the decimal point, use the argument 
 * 		DP_OFF
 *
 * 		set_hexledsleft (x, DP_OFF) will set the left LED
 * 		to the hexadecimal value (0x0-0xF) of the argument 'x',
 * 		and disable the decimal point on the left led.
 *
 * 		set_hexledsright () works similarly on the right LED
 *
 * Local Includes:
 * 		lh7A400_evb.h
 * 		lh7A400_sevenseg.h
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/CHIPS/archives/LH7A400/Startup/LH7A400_sevenseg.c-arc  $
 * 
 *    Rev 1.4   Jun 12 2002 18:38:20   BarnettH
 * Eliminated superfluous static function.
 * 
 *    Rev 1.3   Jun 12 2002 18:23:08   BarnettH
 * Changed code to eliminate 'implicit narrowing' warnings during build.
 * 
 *    Rev 1.2   Apr 11 2002 14:57:42   BarnettH
 * Changed to universal SMA_sevenseg_driver.h
 * Changed name of functions to agree with universal header
 * 
 *    Rev 1.1   Nov 13 2001 08:37:02   BarnettH
 * Transparent changes for LH7A400
 * 
 *    Rev 1.0   Sep 18 2001 18:06:24   BarnettH
 * Initial revision.
 * 
 * COPYRIGHT (C) 2000 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 * 		       CAMAS, WA
 *********************************************************************/

#include "lh7A400_evb.h"
#include "SMA_sevenseg_driver.h"

static UNS_8 set_hexled (UNS_8 val, UNS_8 dp);

static const UNS_8 lednum[] =
	{ 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,  /* 0-7 */ 
		0x80, 0x98, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E, /* 8-F */ 
		/* 0xBF, */ 	/* hyphen */ 
		/* 0xFF, */ 	/* (blank) */ 
	};

void util_set_sevenseg_blank (void)
{
	CPLD->seven_seg = 0xFFFF;
}

void util_set_sevenseg_hexval (INT_32 val, UNS_8 dp)
{
	val &= 0xFF;
	CPLD->seven_seg = (UNS_16)
        (
         ((set_hexled ((UNS_8)(val >> 4), DP_OFF)) << 8)
         |
		 (set_hexled ((UNS_8)(val & 0x0F), dp))
        );
}

static UNS_8 set_hexled (UNS_8 val, UNS_8 dp)
{
	return((UNS_8)((dp == DP_OFF) ? 
                lednum[val & 0x0F] : lednum[val & 0x0F] & 0x7F));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -