Ubuntu下sdcc写的一个基于普中V2单片机数码管头文件
2024-07-23 来源:cnblogs
/*
使用此头文件需先包含头文件:
#include <8051.h>
#include */ uchar __code smgduan[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x00}; void shumaguan(uchar duan, uchar wei) { switch (duan) { case 1: P2 &= 0xE3; //1110 0011 相当于LSC=0;LSB=0;LSA=0; break; case 2: P2 &= 0xE7; //1110 0111 相当于LSC=0;LSB=0;LSA=1; break; case 3: P2 &= 0xEB; //1110 1011 相当于LSC=0;LSB=1;LSA=0; break; case 4: P2 &= 0xEF; //1110 1111 相当于LSC=0;LSB=1;LSA=1; break; case 5: P2 &= 0xF3; //1111 0011 相当于LSC=1;LSB=0;LSA=0; break; case 6: P2 &= 0xF7; //1111 0111 相当于LSC=1;LSB=0;LSA=1; break; case 7: P2 &= 0xFB; //1111 1011 相当于LSC=1;LSB=1;LSA=0; break; case 8: P2 &= 0xFF; //1111 1111 相当于LSC=1;LSB=1;LSA=1; break; default: break; } switch (wei) { case 0: smg_wei = smgduan[0]; break; case 1: smg_wei = smgduan[1]; break; case 2: smg_wei = smgduan[2]; break; case 3: smg_wei = smgduan[3]; break; case 4: smg_wei = smgduan[4]; break; case 5: smg_wei = smgduan[5]; break; case 6: smg_wei = smgduan[6]; break; case 7: smg_wei = smgduan[7]; break; default: break; } }