Merge pull request #15 from badgeteam/renze/fpga-improvements

FPGA improvements
This commit is contained in:
Renze Nicolai 2022-05-08 18:18:42 +02:00 committed by GitHub
commit b92d8a694c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8734 additions and 13 deletions

13
.gitmodules vendored
View file

@ -3,22 +3,19 @@
url = https://github.com/espressif/esp-idf.git
[submodule "components/bus-i2c"]
path = components/bus-i2c
url = git@github.com:Nicolai-Electronics/esp32-component-bus-i2c.git
[submodule "components/i2c-pca9555"]
path = components/i2c-pca9555
url = git@github.com:Nicolai-Electronics/esp32-component-i2c-pca9555.git
url = https://github.com/Nicolai-Electronics/esp32-component-bus-i2c.git
[submodule "components/i2c-bno055"]
path = components/i2c-bno055
url = git@github.com:Nicolai-Electronics/esp32-component-i2c-bno055.git
url = https://github.com/Nicolai-Electronics/esp32-component-i2c-bno055.git
[submodule "components/spi-ili9341"]
path = components/spi-ili9341
url = git@github.com:Nicolai-Electronics/esp32-component-spi-ili9341.git
url = https://github.com/Nicolai-Electronics/esp32-component-spi-ili9341.git
[submodule "components/spi-ice40"]
path = components/spi-ice40
url = git@github.com:Nicolai-Electronics/esp32-component-spi-ice40.git
url = https://github.com/Nicolai-Electronics/esp32-component-spi-ice40.git
[submodule "components/sdcard"]
path = components/sdcard
url = git@github.com:Nicolai-Electronics/esp32-component-sdcard.git
url = https://github.com/Nicolai-Electronics/esp32-component-sdcard.git
[submodule "components/pax-graphics"]
path = components/pax-graphics
url = https://github.com/robotman2412/pax-graphics.git

@ -1 +0,0 @@
Subproject commit 1ae02d7fe779ed7d6517288a9a85942c16e162b4

View file

@ -131,7 +131,8 @@ esp_err_t board_init(bool* aLcdReady) {
dev_ice40.pin_done = -1;
dev_ice40.pin_reset = -1;
dev_ice40.pin_int = GPIO_INT_FPGA;
dev_ice40.spi_speed = 23000000; // 23MHz
dev_ice40.spi_speed_full_duplex = 26700000;
dev_ice40.spi_speed_half_duplex = 40000000;
dev_ice40.spi_max_transfer_size = SPI_MAX_TRANSFER_SIZE;
dev_ice40.get_done = ice40_get_done_wrapper;
dev_ice40.set_reset = ice40_set_reset_wrapper;

@ -1 +1 @@
Subproject commit 4263f4f60d3d410ebf2ae88a7a26b23bd08eedde
Subproject commit 3b2767dea615e7f4c069f03d900b56d8da48af22

View file

@ -1,4 +1,4 @@
unsigned char proto2_bin[] = {
const unsigned char proto2_bin[] = {
0xff, 0x00, 0x00, 0xff, 0x7e, 0xaa, 0x99, 0x7e, 0x51, 0x00, 0x01, 0x05,
0x92, 0x00, 0x20, 0x62, 0x02, 0xb3, 0x82, 0x00, 0x00, 0x72, 0x01, 0x50,
0x11, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -5,6 +5,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#include "fpga.h"
#include "selftest.h"
#include "ili9341.h"
#include "ice40.h"
#include "rp2040.h"
@ -113,9 +114,43 @@ esp_err_t verify_file_in_psram(ICE40* ice40, FILE* fd) {
return ESP_OK;
}
void test_spi(ICE40* ice40) {
esp_err_t res;
uint8_t r1[8], r2[8];
uint8_t data0[8] = {0x01, 0x23, 0x45, 0x67, 0x01, 0x23, 0x45, 0x67};
uint8_t data1[8] = {0x89, 0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef};
res = ice40_send(ice40, data0, 8);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Transaction 1 failed");
return;
}
res = ice40_transaction(ice40, data1, 8, r1, 8);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Transaction 2 failed");
return;
}
printf("Transaction 2 result: ");
for (uint8_t i = 0; i < 8; i++) printf("%02X ", r1[i]);
printf("\n");
res = ice40_receive(ice40, r2, 8);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Transaction 3 failed");
return;
}
printf("Transaction 3 result: ");
for (uint8_t i = 0; i < 8; i++) printf("%02X ", r2[i]);
printf("\n");
}
void fpga_test(ILI9341* ili9341, ICE40* ice40, xQueueHandle buttonQueue) {
esp_err_t res;
bool reload_fpga = false;
bool load_old_bitstream = false;
do {
printf("Start FPGA test...\n");
reload_fpga = false;
@ -129,13 +164,19 @@ void fpga_test(ILI9341* ili9341, ICE40* ice40, xQueueHandle buttonQueue) {
ili9341_select(ili9341, true);
printf("FPGA load...\n");
res = ice40_load_bitstream(ice40, proto2_bin, proto2_bin_len);
if (load_old_bitstream) {
res = ice40_load_bitstream(ice40, proto2_bin, sizeof(proto2_bin));
} else {
res = ice40_load_bitstream(ice40, selftest_sw_bin, sizeof(selftest_sw_bin));
}
if (res != ESP_OK) {
printf("Failed to load app bitstream into FPGA (%d)\n", res);
return;
} else {
printf("Bitstream loaded succesfully!\n");
}
test_spi(ice40);
bool waitForChoice = true;
while (waitForChoice) {
@ -147,11 +188,16 @@ void fpga_test(ILI9341* ili9341, ICE40* ice40, xQueueHandle buttonQueue) {
switch(buttonMessage.input) {
case RP2040_INPUT_BUTTON_HOME:
case RP2040_INPUT_BUTTON_MENU:
waitForChoice = false;
break;
case RP2040_INPUT_BUTTON_BACK:
reload_fpga = true;
load_old_bitstream = true;
waitForChoice = false;
break;
case RP2040_INPUT_BUTTON_ACCEPT:
reload_fpga = true;
load_old_bitstream = false;
waitForChoice = false;
break;
default:

8678
main/selftest.h Normal file

File diff suppressed because it is too large Load diff