Bläddra i källkod

Fixed latch selection

Code never was rewritten for new Hardware.
Thomas Buck 12 år sedan
förälder
incheckning
ce1c3b2e43
2 ändrade filer med 13 tillägg och 7 borttagningar
  1. 9
    3
      CubeFirmware/cube.c
  2. 4
    4
      CubeFirmware/main.c

+ 9
- 3
CubeFirmware/cube.c Visa fil

@@ -126,9 +126,15 @@ inline void setFet(uint8_t data) {
126 126
 
127 127
 // Give id of latch, 0 - 7
128 128
 inline void selectLatch(uint8_t latchNr) {
129
-	PORTC = 0;
130
-	if (latchNr < 8) {
131
-		PORTC = 1 << latchNr;
129
+	// Disable all latches
130
+	PORTC &= ~(0xFC); // 2 - 7
131
+	PORTB &= ~(6); // 0 & 1
132
+
133
+	// Enable desired latch
134
+	if (latchNr > 1) {
135
+		PORTC |= (1 << latchNr);
136
+	} else {
137
+		PORTB |= (1 << (latchNr + 1));
132 138
 	}
133 139
 }
134 140
 

+ 4
- 4
CubeFirmware/main.c Visa fil

@@ -112,10 +112,10 @@ int main(void) {
112 112
 
113 113
 	wdt_enable(WDTO_500MS); // Enable watchdog reset after 500ms
114 114
 
115
-	DDRD = 0xFC; // Mosfets as Output
116
-	DDRB = 0xFE;
117
-	DDRC = 0xFF; // Latch Enable
118
-	DDRA = 0xFF; // Latch Data
115
+	DDRA = 0xFF; // Latch Data Bus as Output
116
+	DDRD = 0xFC; DDRB = 24; // Mosfets as Output
117
+	DDRC = 0xFC; DDRB |= 6; // Latch Enable as Output
118
+	DDRB &= ~(1 << PB0); // Pushbutton as Input
119 119
 
120 120
 	setImage(defaultImage); // Display something
121 121
 

Laddar…
Avbryt
Spara