Skip to content

Commit 570f073

Browse files
committed
Fix UART
UART needs to be initialized along with configure_io() to work
1 parent e2c7d87 commit 570f073

3 files changed

Lines changed: 60 additions & 34 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Constants
2+
#define BAUD_RATE 9600
3+
4+
// Variables
5+
String receivedData = "";
6+
unsigned long lastReceiveTime = 0;
7+
const unsigned long DISPLAY_TIMEOUT = 500; // ms
8+
9+
void setup() {
10+
Serial.begin(BAUD_RATE); // Initialize serial communication with computer
11+
Serial1.begin(BAUD_RATE); // Initialize serial communication with chip
12+
13+
Serial.println("Chip Serial Monitor Started");
14+
Serial.println("Waiting for data...");
15+
}
16+
17+
void loop() {
18+
// Read data from the chip
19+
while (Serial1.available() > 0) {
20+
char inByte = Serial1.read();
21+
receivedData += inByte;
22+
lastReceiveTime = millis();
23+
}
24+
25+
// Print complete messages after timeout
26+
if (receivedData.length() > 0 && (millis() - lastReceiveTime > DISPLAY_TIMEOUT)) {
27+
Serial.print("Received: ");
28+
29+
// Print as ASCII
30+
Serial.print("ASCII: \"");
31+
Serial.print(receivedData);
32+
Serial.print("\" | HEX: ");
33+
34+
// Print as HEX
35+
for (int i = 0; i < receivedData.length(); i++) {
36+
char c = receivedData.charAt(i);
37+
if (c < 0x10) Serial.print("0");
38+
Serial.print(c, HEX);
39+
Serial.print(" ");
40+
}
41+
42+
Serial.println();
43+
receivedData = "";
44+
}
45+
46+
// Send data to chip if entered in Serial Monitor
47+
if (Serial.available() > 0) {
48+
String input = Serial.readStringUntil('\n');
49+
Serial1.println(input);
50+
Serial.println("Sent: " + input);
51+
}
52+
}

firmware/chipignite/polysat/arduino/reader.ino

Lines changed: 0 additions & 29 deletions
This file was deleted.

firmware/chipignite/polysat/src/polysat.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ void configure_io() {
8181
reg_mprj_io_36 = GPIO_MODE_MGMT_STD_INPUT_NOPULL;
8282
reg_mprj_io_37 = GPIO_MODE_MGMT_STD_INPUT_NOPULL;
8383

84+
85+
// Initialize UART
86+
uart_init();
87+
8488
// Initiate the serial transfer to configure IO
8589
reg_mprj_xfer = 1;
8690
while (reg_mprj_xfer == 1);
@@ -121,9 +125,6 @@ void main() {
121125
// Configure IO pins including UART pins
122126
configure_io();
123127

124-
// Initialize UART
125-
uart_init();
126-
127128
// Configure All LA probes as inputs to the cpu
128129
reg_la0_oenb = reg_la0_iena = 0x00000000; // [31:0]
129130
reg_la1_oenb = reg_la1_iena = 0x00000000; // [63:32]
@@ -159,10 +160,12 @@ void main() {
159160

160161
if (!pulse) {
161162
led_off();
162-
reg_mprj_io_33 = 1; // Set GPIO 33 high
163+
// Set GPIO 33 low (bit 1)
164+
gpio_clear(33);
163165
} else {
164166
led_on();
165-
reg_mprj_io_33 = 0; // Set GPIO 33 low
167+
// Set GPIO 33 high (bit 1)
168+
gpio_set(33, true);
166169
}
167170
pulse = !pulse;
168171

0 commit comments

Comments
 (0)