archive: homework4 headers

This commit is contained in:
2025-04-14 12:59:36 +08:00
parent 14d324e29a
commit 83be5ac8da
+46
View File
@@ -0,0 +1,46 @@
// homework4.h
/*
* this header file defines defines:
* the BUS pin numbers for the LEDs, 7SEGs, and 38 transistors.
* the type for the 38 transistor array.
*/
#include <REG52.H>
// variables:
// pin addresses for the 38 transistor
sbit ADDR0 = P1 ^ 0;
sbit ADDR1 = P1 ^ 1;
sbit ADDR2 = P1 ^ 2;
sbit ADDR3 = P1 ^ 3;
sbit ENLED = P1 ^ 4;
// BUS pin addresses for the LEDs and 7SEGs:
sbit BUS1A = P2 ^ 0;
sbit BUS2B = P2 ^ 1;
sbit BUS3C = P2 ^ 2;
sbit BUS4D = P2 ^ 3;
sbit BUS5E = P2 ^ 4;
sbit BUS6F = P2 ^ 5;
sbit BUS7G = P2 ^ 6;
sbit BUS8DP = P2 ^ 7;
// functions:
// 38 transistor type setters:
void set_38_2LED()
{
// e.g. set Y3 to 1, others to 0:
ADDR0 = 0;
ADDR1 = 1;
ADDR2 = 1;
ADDR3 = 1;
ENLED = 0;
}
void set_38_2SEG()
{
// e.g. set Y4 to 1, others to 0:
ADDR0 = 1;
ADDR1 = 0;
ADDR2 = 0;
ADDR3 = 1;
ENLED = 0;
}