Skip to content

Commit

Permalink
Refine firmware debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed Aug 31, 2024
1 parent 875436d commit 9fd7b59
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions firmware/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static int next_chunk_num = 0;
static int next_offset = 0;

static void init_all_hardware() {
sram_init();
registers_init();
sram_init();

// Use LED as a primitive visual status.
pinMode(LED_BUILTIN, OUTPUT);
Expand Down Expand Up @@ -105,6 +105,8 @@ static void init_all_hardware() {
} else {
http_init(client);
}

Serial.println("All hardware initialized.");
}

static bool http_sram_callback(const uint8_t* buffer, int bytes) {
Expand Down Expand Up @@ -167,6 +169,11 @@ static bool await_fetch() {
}

static void process_command(uint8_t command, uint8_t arg) {
Serial.print("Command ");
Serial.print(command);
Serial.print(" arg ");
Serial.println(arg);

switch (command) {
case KINETOSCOPE_CMD_ECHO:
// Write the argument to SRAM so the ROM software knows we are listening.
Expand Down Expand Up @@ -259,7 +266,14 @@ static void process_command(uint8_t command, uint8_t arg) {
break;
}

#ifdef DEBUG
// Don't clear the flag too quickly.
// TODO: Determine if this is necessary once hardware prototypes are working.
delay(10 /* ms */);
#endif

clear_cmd();
Serial.println("Command complete.");
}

// Setup and loop for the first core. This core will initialize all hardware
Expand All @@ -270,11 +284,9 @@ void setup() {

#ifdef DEBUG
while (!Serial) { delay(10 /* ms */); } // Wait for serial port to connect
#endif

// Delay startup so we can have the serial monitor attached.
delay(1000 /* ms */);
Serial.println("Kinetoscope boot!\n");
#endif

init_all_hardware();

Expand Down

0 comments on commit 9fd7b59

Please sign in to comment.