Solution refactored to class SpiReader, test program (main) in spi_test.cpp.