Skip to content

Commit

Permalink
MachXO2-1200 initial update
Browse files Browse the repository at this point in the history
  • Loading branch information
mattzamora committed Oct 4, 2024
1 parent 7e2d459 commit 69b5f75
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
19 changes: 16 additions & 3 deletions examples/TcpFipsyLoader/TcpFipsyLoader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,26 @@ WiFiServer listener(34779);
void
setup() {
Serial.begin(115200);
if (!fpga.begin(14, 12, 13, 15)) {

// Choose either fuseTable.resize(343936) for MachX02-1200 or fuseTable.resize(73600) for MachXO2-256.
// These are the QF values from the .jed file.
// fuseTable.resize(73600);
fuseTable.resize(343936);

// Known alternate pinouts for SPI include:
// 18, 19, 23, 5
// 14, 12, 13, 15
// These pins are sck, miso, mosi, ss
if (!fpga.begin(18, 19, 23, 5)) {
Serial.println("Fipsy not found");
return;
} else {
uint32_t deviceID = fpga.getID();
Serial.print("Device ID: ");
Serial.printf("0x%08lx", deviceID);
Serial.println();
}

fuseTable.resize(73600);

WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=esp-fipsy
version=0.0.20240618
version=0.0.20241004
author=Junxiao Shi
maintainer=Junxiao Shi
sentence=Fipsy FPGA programmer.
paragraph=This library programs MocoMakers Fipsy FPGA chip from ESP32 microcontroller.
category=Device Control
url=https://yoursunny.com
url=https://www.fipsyfpga.com
architectures=esp32
9 changes: 8 additions & 1 deletion src/fipsy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ Fipsy::begin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1

auto rsp = spiTrans<8>({0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
uint32_t deviceId = (rsp[4] << 24) | (rsp[5] << 16) | (rsp[6] << 8) | (rsp[7] << 0);
return deviceId == 0x012B8043;
// 0x012B8043 is for MachXO2-256 and 0x012BA043 is MachXO2-1200HC
return deviceId == 0x012B8043 || deviceId == 0x012BA043;
}

uint32_t Fipsy::getID() {
auto resp = spiTrans<8>({0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
uint32_t deviceId = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | (resp[7] << 0);
return deviceId; // Return the Device ID directly
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/fipsy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Fipsy {
* @brief Detect Fipsy device ID.
* @return Return any Device ID found.
*/
uint32_t getID(int8_t sck, int8_t miso, int8_t mosi, int8_t ss);
uint32_t getID();

/**
* @brief Release SPI bus.
Expand Down

0 comments on commit 69b5f75

Please sign in to comment.