Browse Source

Memory now working.

Also changed nitrate to highest one possible with our clock speed,
38400bps.
Thomas Buck 12 years ago
parent
commit
006665ba0b
4 changed files with 21 additions and 12 deletions
  1. 1
    1
      CubeControl/libSerial/unixSerial.c
  2. 1
    1
      CubeControl/libSerial/winSerial.c
  3. 11
    2
      CubeFirmware/main.c
  4. 8
    8
      CubeFirmware/mem.c

+ 1
- 1
CubeControl/libSerial/unixSerial.c View File

@@ -33,7 +33,7 @@
33 33
 #include <dirent.h>
34 34
 #include <errno.h>
35 35
 
36
-#define BAUD B19200
36
+#define BAUD B38400
37 37
 
38 38
 int fd = -1;
39 39
 

+ 1
- 1
CubeControl/libSerial/winSerial.c View File

@@ -28,7 +28,7 @@
28 28
 #include <stdio.h>
29 29
 #include <windows.h>
30 30
 
31
-#define BAUD CBR_19200;
31
+#define BAUD CBR_38400;
32 32
 
33 33
 HANDLE hSerial = INVALID_HANDLE_VALUE;
34 34
 

+ 11
- 2
CubeFirmware/main.c View File

@@ -86,7 +86,7 @@ int main(void) {
86 86
 	uint64_t lastChecked;
87 87
 
88 88
 	initCube();
89
-	serialInit(51, 8, NONE, 1);
89
+	serialInit(25, 8, NONE, 1);
90 90
 	i2c_init();
91 91
 	initSystemTimer();
92 92
 	sei(); // Enable Interrupts
@@ -115,7 +115,7 @@ int main(void) {
115 115
 #ifdef DEBUG
116 116
 	refreshAnimationCount = 0; // Don't talk to FRAM yet...
117 117
 
118
-	serialWriteString("Initialized: ");
118
+	serialWriteString("\n\nInitialized: ");
119 119
 	serialWriteString(VERSION);
120 120
 	serialWriteString("Took ");
121 121
 	serialWriteString(itoa(getSystemTime(), buffer, 10));
@@ -220,6 +220,7 @@ void serialHandler(char c) {
220 220
 #ifdef DEBUG
221 221
 		serialWriteString("(t)ime, (a)udio, (c)ount, (x)Custom count\n");
222 222
 		serialWriteString("(y)Set fixed animation count\n");
223
+		serialWriteString("S(e)lf Test\n");
223 224
 #endif
224 225
 		break;
225 226
 
@@ -286,6 +287,14 @@ void serialHandler(char c) {
286 287
 		setAnimationCount(0x2201);
287 288
 		serialWriteString("Animation count now 8705!\n");
288 289
 		break;
290
+
291
+	case 'e': case 'E':
292
+		c = selfTest();
293
+		serialWriteString("Self-Test: 0b");
294
+		serialWriteString(itoa(c, buffer, 2));
295
+		serialWrite('\n');
296
+		printErrors(c);
297
+		break;
289 298
 #endif
290 299
 
291 300
 	default:

+ 8
- 8
CubeFirmware/mem.c View File

@@ -37,8 +37,8 @@ uint8_t memGetByte(uint32_t address) {
37 37
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
38 38
 		memAddress |= 2;
39 39
 	}
40
-	addA = memAddress & 0xFF00;
41
-	addB = memAddress & 0xFF;
40
+	addA = address & 0xFF00;
41
+	addB = address & 0xFF;
42 42
 
43 43
 	if (i2c_start(memAddress | I2C_WRITE) == 0) { // Send start, write address to read
44 44
 		i2c_write(addA);
@@ -61,8 +61,8 @@ uint8_t *memGetBytes(uint32_t address, uint8_t length) {
61 61
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
62 62
 		memAddress |= 2;
63 63
 	}
64
-	addA = memAddress & 0xFF00;
65
-	addB = memAddress & 0xFF;
64
+	addA = address & 0xFF00;
65
+	addB = address & 0xFF;
66 66
 	ret = (uint8_t *)malloc(length); // Allocate memory for values read
67 67
 	if (ret == NULL) {
68 68
 #ifdef DEBUG
@@ -92,8 +92,8 @@ void memWriteByte(uint32_t address, uint8_t data) {
92 92
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
93 93
 		memAddress |= 2;
94 94
 	}
95
-	addA = memAddress & 0xFF00;
96
-	addB = memAddress & 0xFF;
95
+	addA = address & 0xFF00;
96
+	addB = address & 0xFF;
97 97
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
98 98
 		i2c_write(addA);
99 99
 		i2c_write(addB); // Give address to memory
@@ -108,8 +108,8 @@ void memWriteBytes(uint32_t address, uint8_t *data, uint8_t length) {
108 108
 		// Address needs more than 16 bits, we have to set the PAGE bit in i2c address
109 109
 		memAddress |= 2;
110 110
 	}
111
-	addA = memAddress & 0xFF00;
112
-	addB = memAddress & 0xFF;
111
+	addA = address & 0xFF00;
112
+	addB = address & 0xFF;
113 113
 	if (i2c_start(memAddress | I2C_WRITE) == 0) {
114 114
 		i2c_write(addA);
115 115
 		i2c_write(addB); // Give address to memory

Loading…
Cancel
Save