refine spi.c