shumaguan.h

来自「ICCAVR下」· C头文件 代码 · 共 49 行

H
49
字号
/* 
   this file is the head file 
*/


#include<iom16v.h>
#include<macros.h>
#include"delay.h"
//macros.h 中有BIT(x)	(1 << (x))定义,  比如  BIT(5)相当于将第5位置1

const unsigned char discode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
                               0x82,0xf8,0x80,0x90,0x88,0x83,
							   0xc6,0xa1,0x86,0x8e,0xbf}; //共阳数码管

/*------------------------------------------------------------------
fuction: display in hex formart
para   : hi--the high two bits to be displayed
         low--the low two bits to be displayed
-------------------------------------------------------------------*/
void display(unsigned char num)
{
     PORTB &=~BIT(PORTB0);           //light the first bit of the shumaguan
	                                 //PORTB0 was defined in iom16v.h
 	 PORTA=discode[num>>4];               //display the thousand bit    
	 delay_nms(5);                           
	 PORTB |=BIT(PORTB0);             //turn off the first bit of the shumaguan
 	 
	 PORTB &=~BIT(PORTB1);
 	 PORTA=discode[num%16];
	 delay_nms(5);
	 PORTB |=BIT(PORTB1);
	
}
/*---------------------------------------------------------------------
fuction: display error,this will display "- - - -" on the four bits leds
----------------------------------------------------------------------*/
void displayerror(void)
{
	 PORTB &=~1;           //light the first bit of the shumaguan
	                                 //PORTB0 was defined in iom16v.h
 	 PORTA=discode[16];               //display the thousand bit    
	 delay_nms(5);                          
	 PORTB |=1;             //turn off the first bit of the shumaguan
 	 
	 PORTB &=~2;
 	 PORTA=discode[16];
	 delay_nms(5);   
	 PORTB |=2;
}

⌨️ 快捷键说明

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