readWriteHelper method
Implementation
List<int> readWriteHelper(List<int> message) {
// pull the chipSelect low to start communication
if (chipSelectGpio != null) {
chipSelectGpio!.write(false);
sleep(const Duration(microseconds: 1));
}
// reverse bytes (since MSB and LSB differences)
final List<int> reversedMessage = reverseUint8List(message);
// transfer the message and read equally big response
final List<int> reversedResponse = spi.transfer(reversedMessage, false);
// get the actual response data
final List<int> response = reverseUint8List(reversedResponse);
// pull the chipSelect high to stop communication
if (chipSelectGpio != null) {
chipSelectGpio!.write(true);
sleep(const Duration(microseconds: 1));
}
return response;
}