WarningThis module is only available on the MCH2022 badge, only use this module if you plan to use hardware features specific to the MCH2022 badge.
The ICE40UP5K FPGA on the MCH2022 badge can be controlled using these APIs.
Loading a bitstream
A bitstream can be loaded into the FPGA by calling
x being a bytes object containing the bitstream binary. Loading a bitstream automatically enables the FPGA.
Disabling the FPGA
To disable the FPGA after a bitstream was loaded call
mch22.fpga_disable(). Note that to enable the FPGA a bitstream has to be loaded in again.
Communicating with the FPGA
The FPGA is connected to the ESP32 via an SPI bus. Communication over SPI can be done in full-duplex mode (sending while receiving) or in half-duplex mode (only sending or receiving).
The transmitting functions require a bytes object, the receiving functions return a bytes object.
|receive||Read from FPGA||40MHz|
|send||Write to FPGA||40MHz|
|send_turbo||Write to FPGA||40MHz|
In case you get communication errors please check the timing constraints of your bitstream.
To connect the LCD to the FPGA call
mch22.lcd_mode(True), to connect the LCD to the ESP32 call
mch22.lcd_mode(False). To send the contents of the framebuffer to the LCD call
True argument forces the flush to happen even though the contents of the framebuffer haven’t changed.
You can set the direction of a GPIO pin using
mch22.set_gpio_dir(pin, direction), where pin is one of
False for input or
True for output.
Inputs can be read using
value = mch22.get_gpio_value(pin) and outputs can be set using
These functions have been moved to other, more generic APIs. Please use those APIs instead.
mch22 module exposes a direct interface to the button handler code via the
set_handler functions. Please do not use these, use the buttons API instead. Using these APIs directly can cause crashes to occur.
Please use the display API instead, brightness can be set using
x being a value from 0 to 255.