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

📄 number.c

📁 uC/OS-II在EP7312微处理器的移植源程序
💻 C
字号:
/*
 * $Id: number.c,v 1.2 2003/08/29 03:03:31 dyn Exp $
 *
 * number.c : keyboard driver
 *
 * Copyright (C) 2003 ynding ( haoanian@263.net )
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include "number.h"

static unsigned char numbers[17] = {
	num_0, num_1, num_2, num_3,
	num_4, num_5, num_6, num_7,
	num_8, num_9, num_a, num_b,
	num_c, num_d, num_e, num_f,
	point
};


/* show number on the ith number-tube ,num 17 as point*/
void number(int i,int num)
{
	PBDDR = 0xff; 
	PBDR = 0xff;
	sendcs(i);
	PBDR = numbers[num];
	sendcs(i);
	return;
}

/*make the ith number cs active*/
void sendcs(int i)
{
    if(i == NUMBER1)
	    LED1CS = 0x00;
	else if(i == NUMBER2)
        LED2CS = 0x00;
    else if(i == NUMBER3)
        LED3CS = 0x00;
    else if(i ==NUMBER4)
        LED4CS = 0x00;
    
}
/* turn on the ithnumber-tube */
void number_on(int i)
{
	PBDDR = 0xff; 
	PBDR = 0xff;
	sendcs(i);
	return;
}
/* close the ithnumber-tube */
void number_off(int i)
{
	PBDDR = 0xff; 
	PBDR = 0x00;
    sendcs(i);
	return;
}

/* show numbers in turn */
void num_show(void)
{
	int i,j;
    for(j=1;j<=4;j++){
        for ( i=0;i<17;++i ) {
		    number(j,i);
		    wait(1000);
	    }
    }
	return;
}

void init_num(void)
{
    int i;
    PBDDR = 0xff;       //set PB port output 
   /* for(i=1;i<=4;i++){
        number_on(i);
        wait(1000);
    }*/
    for(i=1;i<=4;i++){
        number_off(i);
        wait(1000);
    }
}

⌨️ 快捷键说明

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