add flash routines and rework spi transaction