Browse Source

First Cube Test

Thomas Buck 12 years ago
parent
commit
a7b01721d2
2 changed files with 16 additions and 13 deletions
  1. 0
    4
      CubeFirmware/cube.c
  2. 16
    9
      CubeFirmware/main.c

+ 0
- 4
CubeFirmware/cube.c View File

57
 
57
 
58
 void init(void) {
58
 void init(void) {
59
 	uint8_t ctr = 0;
59
 	uint8_t ctr = 0;
60
-	DDRD = 0xFF; // Mosfets as Output
61
-	DDRB = 0xFF;
62
-	DDRC = 0xFF; // Latch Enable
63
-	DDRA = 0xFF; // Latch Data
64
 
60
 
65
 	TCCR1A |= (1 << WGM12); // CTC Mode
61
 	TCCR1A |= (1 << WGM12); // CTC Mode
66
 	TCCR1B |= (1 << CS10); // No prescaler
62
 	TCCR1B |= (1 << CS10); // No prescaler

+ 16
- 9
CubeFirmware/main.c View File

32
 #endif
32
 #endif
33
 
33
 
34
 int main(void) {
34
 int main(void) {
35
-	uint8_t i;
35
+	uint8_t i, j = 1;
36
+
37
+	DDRD = 0xFF; // Mosfets as Output
38
+	DDRB = 0xFF;
39
+	DDRC = 0xFF; // Latch Enable
40
+	DDRA = 0xFF; // Latch Data
36
 
41
 
37
 	// init(); // Initialize Cube Low-Level Code
42
 	// init(); // Initialize Cube Low-Level Code
38
 	uart_init(UART_BAUD_SELECT(19200, 16000000L)); // Initialize Serial
43
 	uart_init(UART_BAUD_SELECT(19200, 16000000L)); // Initialize Serial
39
 
44
 
40
 
45
 
41
-	setFet(0xFF);
46
+	setFet(0x01);
42
 	// Blink led :)
47
 	// Blink led :)
43
 	while (1) {
48
 	while (1) {
44
-		 PORTB |= (1 << PB0);
45
-		_delay_ms(1000);
46
-		PORTB &= ~(1 << PB0);
47
-		_delay_ms(1000);
48
-		
49
-		//setFet(0);
50
-		//_delay_ms(10000);
49
+		for (i = 0; i < 8; i++) {
50
+			setLatch(i, j);
51
+			_delay_ms(100);
52
+		}
53
+		if (j < 128) {
54
+			j *= 2;
55
+		} else {
56
+			j = 1;
57
+		}
51
 	}
58
 	}
52
 
59
 
53
 	close();
60
 	close();

Loading…
Cancel
Save