Skip to content

Commit

Permalink
Boot test doesn't turn on LCD
Browse files Browse the repository at this point in the history
This also matches the switches to the same LED and superimposes the
joystick on top of the switches.
  • Loading branch information
marnovandermaas committed Mar 25, 2024
1 parent c8b961b commit 5f90375
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sw/cpp/cheri_sanity/boot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace CHERI;

#define GPIO_VALUE (0xFFFFFFFF)
#define GPIO_VALUE (0x00000FF0)

/**
* C++ entry point for the loader. This is called from assembly, with the
Expand All @@ -29,13 +29,17 @@ extern "C" uint32_t rom_loader_entry(void *rwRoot)

// Use pointer to flash LEDs
uint32_t gpioValue = 0;
uint32_t inputValue = 0;
uint32_t joystickValue = 0;
uint32_t switchValue = 0;
while (true) {
gpioValue ^= GPIO_VALUE;
for (int i = 0; i < 5000000; i++) {
switchValue = *((volatile uint32_t *) gpi);
switchValue <<= 4; // shift input onto LEDs and skipping LCD pins
*((volatile uint32_t *) gpo) = gpioValue ^ switchValue;
inputValue = *((volatile uint32_t *) gpi);
// Shift right to remove joystick, mask to only get 8 switches and shift left to skip LCD controls.
switchValue = ((inputValue >> 5) & 0xFF) << 4;
joystickValue = (inputValue & 0x1F) << 4;
*((volatile uint32_t *) gpo) = (gpioValue ^ switchValue ^ joystickValue) & GPIO_VALUE;
}
}
}

0 comments on commit 5f90375

Please sign in to comment.