pico-ice
RaspberryPi Pico with an iCE40 FPGA
|
TinyUSB and TinyUF2 configuration. More...
Enumerations | |
enum | { STRID_LANGID , STRID_MANUFACTURER , STRID_PRODUCT , STRID_SERIAL_NUMBER , STRID_VENDOR , STRID_CDC = 10 , STRID_MSC = 20 , STRID_DFU = 30 , STRID_NUM_TOTAL = 40 } |
Functions | |
void | ice_usb_init (void) |
void | ice_usb_sleep_ms (uint32_t ms) |
TinyUSB and TinyUF2 configuration.
The pico-ice-sdk makes use of the pico-sdk which uses the TinyUSB library for providing USB device mode and host mode.
"ice_usb" comes as a separate "pico_ice_usb" library to add in the CMakeLists.txt.
The library user needs to provide tusb_config.h
and usb_descriptors.c
. Examples listed below. tud_task() needs to be called frequently in the firmware.
The pico-ice-sdk allows to configure forwarding from an USB CDC interface to an UART interface with the two defines below:
To enable:
ICE_USB_UART0_CDC
or ICE_USB_UART1_CDC
to the CDC interface number to use.ITF_NUM_CDCx
, ITF_NUM_DATAx
, CFG_TUD_CDC
, TUD_CDC_DESCRIPTOR
, STRID_CDC+x
See the pico_usb_uart
example.
The pico-ice-sdk allows to configure forwarding data between an USB CDC interface and the main SPI interface around which everything is hooked-up together. This allows to exchange data with the iCE40, SRAM and flash directly from USB. To do so, a very small protocol was added on op of USB-CDC to control SPI:
When wanting to write \x31\x32\x33\x34\x35
over SPI, the I/O over USB-CDC would be:
When trying to read 4 bytes from SPI, the I/O over USB-CDC would be:
To change to a different SPI chip select pin, the I/O over USB-CDC would be:
You can use this python library: pico_ice_spi.py
To enable:
ICE_USB_SPI_CDC
to the CDC interface number to use.ITF_NUM_CDCx
, ITF_NUM_DATAx
, CFG_TUD_CDC
, TUD_CDC_DESCRIPTOR
, STRID_CDC+x
See the pico_usb_spi
example.
The pico-ice-sdk allows to configure forwarding from the USB CDC interface using the wishbone-serial protocol to the FPGA SPI interface using the wishbone-spi protocol..
To enable:
ICE_USB_FPGA_CDC
to the CDC interface number to use.ITF_NUM_CDCx
, ITF_NUM_DATAx
, CFG_TUD_CDC
, TUD_CDC_DESCRIPTOR
, STRID_CDC+x
See the pico_usb_fpga
example.
The TinyUF2 library from Adafruit permits to expose an MSC USB storage device, with a fake FAT filesystem. This will allow to copy UF2-formatted files using a drag-and-drop scheme containing a bitstream programmed into the FPGA flash. This means no Zadig driver setup needed on Windows.
You would need something like the uf2-utils
to generate the UF2-formatted files.
To enable:
ICE_USB_USE_TINYUF2_MSC
ITF_NUM_MSCx
, CFG_TUD_MSC
, TUD_MSC_DESCRIPTOR
, STRID_MSC+x
See the pico_usb_uf2
example.
#define CONFIG_TOTAL_LEN |