Pārlūkot izejas kodu

Add pinIsMOSI(), pinIsMISO(), pinIsSCK()

main
PaulStoffregen pirms 7 gadiem
vecāks
revīzija
3f5108d197
2 mainītis faili ar 54 papildinājumiem un 0 dzēšanām
  1. +48
    -0
      SPI.cpp
  2. +6
    -0
      SPI.h

+ 48
- 0
SPI.cpp Parādīt failu

@@ -379,6 +379,30 @@ bool SPIClass::pinIsChipSelect(uint8_t pin1, uint8_t pin2)
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.
uint8_t SPIClass::setCS(uint8_t pin)
{
@@ -649,6 +673,30 @@ bool SPIClass::pinIsChipSelect(uint8_t pin)
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.
uint8_t SPIClass::setCS(uint8_t pin)
{

+ 6
- 0
SPI.h Parādīt failu

@@ -597,6 +597,9 @@ public:

// return true if "pin" has special chip select capability
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
bool pinIsChipSelect(uint8_t pin1, uint8_t pin2);
// configure a pin for chip select and return its SPI_MCR_PCSIS bitmask
@@ -919,6 +922,9 @@ public:
void setSCK(uint8_t pin);
// return true if "pin" has special chip select capability
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
bool pinIsChipSelect(uint8_t pin1, uint8_t pin2) { return false; }
// configure a pin for chip select and return its SPI_MCR_PCSIS bitmask

Notiek ielāde…
Atcelt
Saglabāt