diff --git a/homework4/src/homework4.h b/homework4/src/homework4.h new file mode 100644 index 0000000..691c3b1 --- /dev/null +++ b/homework4/src/homework4.h @@ -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 + +// 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; +} \ No newline at end of file