Made spi lib thread safe