return true; | return true; | ||||
} | } | ||||
bool SPIClass::pinIsMOSI(uint8_t pin) | |||||
{ | |||||
for (unsigned int i = 0; i < sizeof(hardware().mosi_pin); i++) { | |||||
if (pin == hardware().mosi_pin[i]) return true; | |||||
} | |||||
return false; | |||||
} | |||||
bool SPIClass::pinIsMISO(uint8_t pin) | |||||
{ | |||||
for (unsigned int i = 0; i < sizeof(hardware().miso_pin); i++) { | |||||
if (pin == hardware().miso_pin[i]) return true; | |||||
} | |||||
return false; | |||||
} | |||||
bool SPIClass::pinIsSCK(uint8_t pin) | |||||
{ | |||||
for (unsigned int i = 0; i < sizeof(hardware().sck_pin); i++) { | |||||
if (pin == hardware().sck_pin[i]) return true; | |||||
} | |||||
return false; | |||||
} | |||||
// setCS() is not intended for use from normal Arduino programs/sketches. | // setCS() is not intended for use from normal Arduino programs/sketches. | ||||
uint8_t SPIClass::setCS(uint8_t pin) | uint8_t SPIClass::setCS(uint8_t pin) | ||||
{ | { | ||||
return 0; | return 0; | ||||
} | } | ||||
bool SPIClass::pinIsMOSI(uint8_t pin) | |||||
{ | |||||
for (unsigned int i = 0; i < sizeof(hardware().mosi_pin); i++) { | |||||
if (pin == hardware().mosi_pin[i]) return true; | |||||
} | |||||
return false; | |||||
} | |||||
bool SPIClass::pinIsMISO(uint8_t pin) | |||||
{ | |||||
for (unsigned int i = 0; i < sizeof(hardware().miso_pin); i++) { | |||||
if (pin == hardware().miso_pin[i]) return true; | |||||
} | |||||
return false; | |||||
} | |||||
bool SPIClass::pinIsSCK(uint8_t pin) | |||||
{ | |||||
for (unsigned int i = 0; i < sizeof(hardware().sck_pin); i++) { | |||||
if (pin == hardware().sck_pin[i]) return true; | |||||
} | |||||
return false; | |||||
} | |||||
// setCS() is not intended for use from normal Arduino programs/sketches. | // setCS() is not intended for use from normal Arduino programs/sketches. | ||||
uint8_t SPIClass::setCS(uint8_t pin) | uint8_t SPIClass::setCS(uint8_t pin) | ||||
{ | { |
// return true if "pin" has special chip select capability | // return true if "pin" has special chip select capability | ||||
uint8_t pinIsChipSelect(uint8_t pin); | uint8_t pinIsChipSelect(uint8_t pin); | ||||
bool pinIsMOSI(uint8_t pin); | |||||
bool pinIsMISO(uint8_t pin); | |||||
bool pinIsSCK(uint8_t pin); | |||||
// return true if both pin1 and pin2 have independent chip select capability | // return true if both pin1 and pin2 have independent chip select capability | ||||
bool pinIsChipSelect(uint8_t pin1, uint8_t pin2); | bool pinIsChipSelect(uint8_t pin1, uint8_t pin2); | ||||
// configure a pin for chip select and return its SPI_MCR_PCSIS bitmask | // configure a pin for chip select and return its SPI_MCR_PCSIS bitmask | ||||
void setSCK(uint8_t pin); | void setSCK(uint8_t pin); | ||||
// return true if "pin" has special chip select capability | // return true if "pin" has special chip select capability | ||||
bool pinIsChipSelect(uint8_t pin); | bool pinIsChipSelect(uint8_t pin); | ||||
bool pinIsMOSI(uint8_t pin); | |||||
bool pinIsMISO(uint8_t pin); | |||||
bool pinIsSCK(uint8_t pin); | |||||
// return true if both pin1 and pin2 have independent chip select capability | // return true if both pin1 and pin2 have independent chip select capability | ||||
bool pinIsChipSelect(uint8_t pin1, uint8_t pin2) { return false; } | bool pinIsChipSelect(uint8_t pin1, uint8_t pin2) { return false; } | ||||
// configure a pin for chip select and return its SPI_MCR_PCSIS bitmask | // configure a pin for chip select and return its SPI_MCR_PCSIS bitmask |