pico-ice
RaspberryPi Pico with an iCE40 FPGA
|
Main SPI bus I/O. More...
Macros | |
#define | ICE_SPI_BAUDRATE (33 * 1000 * 1000) |
This is chosen to allow all commands to the flash and SRAM to work. | |
Functions | |
void | ice_spi_init (void) |
Configure the GPIO pins of the SPI library to high-impedance. | |
void | ice_spi_init_cs_pin (uint8_t cs_pin, bool active_high) |
void | ice_spi_chip_select (uint8_t cs_pin) |
Sets the SPI chip select pin to low state. | |
void | ice_spi_chip_deselect (uint8_t csn_pin) |
Sets the SPI chip select pin to high state. | |
void | ice_spi_write_async (const uint8_t *data, size_t data_size, void(*callback)(volatile void *), void *context) |
Wait previous transfer completion if any and enqueue a new one in the background (interrupt-driven). | |
void | ice_spi_write_blocking (const uint8_t *data, size_t data_size) |
Blocking version of ice_spi_write_async(). | |
void | ice_spi_read_async (uint8_t *data, size_t data_size, void(*callback)(volatile void *), void *context) |
Wait previous transfer completion if any and enqueue a new one in the background (interrupt-driven). | |
void | ice_spi_read_blocking (uint8_t *data, size_t data_size) |
Blocking version of ice_spi_read_async(). | |
bool | ice_spi_is_async_complete (void) |
Checks for compmletion of the current async operation. | |
void | ice_spi_wait_completion (void) |
Waits until SPI transfer commpletes. | |
Main SPI bus I/O.
SPI library exclusive to the main SPI bus between the RP2040 and the various other board components, including the iCE40 CRAM, iCE40 hardened SPI core, SRAM chip, FLASH chip.
#define ICE_SPI_BAUDRATE (33 * 1000 * 1000) |
This is chosen to allow all commands to the flash and SRAM to work.
33MHz is the fastest the SRAM supports a 03h read command.
void ice_spi_chip_deselect | ( | uint8_t | csn_pin | ) |
Sets the SPI chip select pin to high state.
csn_pin | User-selectable GPIO pin to assert, set to LOW voltage level. |
Also set the SPI TX and SCK pins back to input/high-z mode.
void ice_spi_chip_select | ( | uint8_t | cs_pin | ) |
Sets the SPI chip select pin to low state.
csn_pin | User-selectable GPIO pin to assert, set to LOW voltage level. |
active_high | true for active-high chip-select pin, false for active-low. |
Also set the SPI TX and SCK pins to output/drive mode, and keeps the RX pin to input/high-z mode.
void ice_spi_init | ( | void | ) |
Configure the GPIO pins of the SPI library to high-impedance.
This lets others access the bus, such as the iCE40 during initial configuration.
bool ice_spi_is_async_complete | ( | void | ) |
Checks for compmletion of the current async operation.
void ice_spi_read_async | ( | uint8_t * | data, |
size_t | data_size, | ||
void(*)(volatile void *) | callback, | ||
void * | context | ||
) |
Wait previous transfer completion if any and enqueue a new one in the background (interrupt-driven).
tx | Byte to send conotinuously while readying |
buf | Buffer to fill from SPI. |
len | Size of that buffer. |
callback | Function called at the end of the transfer. |
context | Argument passed to that function. |
If callback
is NULL
, then nothing will be done.
void ice_spi_read_blocking | ( | uint8_t * | data, |
size_t | data_size | ||
) |
Blocking version of ice_spi_read_async().
tx | Byte to send conotinuously while readying |
buf | Buffer to fill from SPI. |
len | Size of that buffer. |
void ice_spi_write_async | ( | const uint8_t * | data, |
size_t | data_size, | ||
void(*)(volatile void *) | callback, | ||
void * | context | ||
) |
Wait previous transfer completion if any and enqueue a new one in the background (interrupt-driven).
buf | buffer to send over SPI. |
len | size of that buffer. |
callback | function called at the end of the transfer. |
context | argument passed to that function. |
If callback is NULL, then nothing will be done.
void ice_spi_write_blocking | ( | const uint8_t * | data, |
size_t | data_size | ||
) |
Blocking version of ice_spi_write_async().
buf | Buffer to send over SPI. |
len | Size of that buffer. |