If you want to program the iCE40 NVCM using a microcontroller, then you need the "iCE40 NVCM Programming Spec". The iCE40 NVCM programming spec is released by creating a support case via Lattice Technical Support portal. In case you want to program the CRAM, refer to the iCE40 Programming and Configuration User Guide (FPGA-TN-02001) by going to this link:
http://www.latticesemi.com/view_document?document_id=46502.
The TN gives most of the details on the configuration procedure. Below is an example pseudo code that can be used:
gpio_pin_clear(SPI_CS); // CS high to lowdelay_us(8);
delay_us(8); // delay for 8 us
gpio_pin_clear(CRST);
// CRST high to low
delay_us(800);
// delay 800 us
gpio_pin_set(CRST);
// CRST low to high
delay_us(1000);
// delay 1200 us
gpio_pin_set(SPI_CS);
// CS low to high
// 8 dummy clk when CS is high
gpio_pin_clear(SPI_CS);
// CS high to low
//send the bitstream
gpio_pin_set(SPI_CS);
// CS low to high
// Send 100 dummy
// delay of 1000 us