Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Perform only when on pins are inputs (at powerup)
- bool testConnection() {
- //Read current polarity config
- const uint16_t old_value;
- if (!this->getPolarity16(old_value) {
- return false;
- }
- //Write constant to polarity register
- if (!this->setPolarity16(_connection_test_constant) {
- return false;
- }
- //Read current polarity config
- const uint16_t temp;
- if (!this->getPolarity16(temp) {
- return false;
- }
- //Write old config to polarity register
- if (!this->setPolarity16(old_value) {
- return false;
- }
- if (temp == _connection_test_constant) {
- return true;
- }
- return false;
- }
- //Somewhere in the class private
- const uint16_t _connection_test_constant = 0xAABB;
- //any arbitrary value, but not 0 or 0xFFFF (on teensy an unconnected spi transfer will return 0, but I don't know about other platforms)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement