clang
This commit is contained in:
parent
fb90221892
commit
bd4135b50c
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
// #define DEBUG_SERIAL Serial
|
// #define DEBUG_SERIAL Serial
|
||||||
|
|
||||||
|
|
||||||
#ifdef BUSIO_USE_FAST_PINIO
|
#ifdef BUSIO_USE_FAST_PINIO
|
||||||
#define BUSIO_SET_CLOCK_LOW() (*clkPort = *clkPort & ~clkPinMask)
|
#define BUSIO_SET_CLOCK_LOW() (*clkPort = *clkPort & ~clkPinMask)
|
||||||
#define BUSIO_SET_CLOCK_HIGH() (*clkPort = *clkPort | clkPinMask)
|
#define BUSIO_SET_CLOCK_HIGH() (*clkPort = *clkPort | clkPinMask)
|
||||||
#define BUSIO_READ_MISO() (*misoPort & misoPinMask)
|
#define BUSIO_READ_MISO() (*misoPort & misoPinMask)
|
||||||
#define BUSIO_WRITE_MOSI(value) do { \
|
#define BUSIO_WRITE_MOSI(value) \
|
||||||
if (value) \
|
do { \
|
||||||
*mosiPort = *mosiPort | mosiPinMask; \
|
if (value) \
|
||||||
else \
|
*mosiPort = *mosiPort | mosiPinMask; \
|
||||||
*mosiPort = *mosiPort & ~mosiPinMask; \
|
else \
|
||||||
} while(0)
|
*mosiPort = *mosiPort & ~mosiPinMask; \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define BUSIO_SET_CLOCK_LOW() digitalWrite(_sck, LOW)
|
#define BUSIO_SET_CLOCK_LOW() digitalWrite(_sck, LOW)
|
||||||
#define BUSIO_SET_CLOCK_HIGH() digitalWrite(_sck, HIGH)
|
#define BUSIO_SET_CLOCK_HIGH() digitalWrite(_sck, HIGH)
|
||||||
|
|
@ -195,65 +195,65 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) {
|
||||||
if (bitdelay_us) {
|
if (bitdelay_us) {
|
||||||
delayMicroseconds(bitdelay_us);
|
delayMicroseconds(bitdelay_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dataMode == SPI_MODE0 || _dataMode == SPI_MODE2) {
|
if (_dataMode == SPI_MODE0 || _dataMode == SPI_MODE2) {
|
||||||
towrite = send & b;
|
towrite = send & b;
|
||||||
if ((_mosi != -1) && (lastmosi != towrite)) {
|
if ((_mosi != -1) && (lastmosi != towrite)) {
|
||||||
BUSIO_WRITE_MOSI(towrite);
|
BUSIO_WRITE_MOSI(towrite);
|
||||||
lastmosi = towrite;
|
lastmosi = towrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUSIO_SET_CLOCK_HIGH();
|
BUSIO_SET_CLOCK_HIGH();
|
||||||
|
|
||||||
if (bitdelay_us) {
|
if (bitdelay_us) {
|
||||||
delayMicroseconds(bitdelay_us);
|
delayMicroseconds(bitdelay_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_miso != -1) {
|
if (_miso != -1) {
|
||||||
if (BUSIO_READ_MISO())
|
if (BUSIO_READ_MISO())
|
||||||
reply |= b;
|
reply |= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUSIO_SET_CLOCK_LOW();
|
BUSIO_SET_CLOCK_LOW();
|
||||||
|
|
||||||
} else if (_dataMode == SPI_MODE3) {
|
} else if (_dataMode == SPI_MODE3) {
|
||||||
|
|
||||||
if (_mosi != -1) { // transmit on falling edge
|
if (_mosi != -1) { // transmit on falling edge
|
||||||
BUSIO_WRITE_MOSI(send & b);
|
BUSIO_WRITE_MOSI(send & b);
|
||||||
}
|
}
|
||||||
|
|
||||||
BUSIO_SET_CLOCK_LOW();
|
BUSIO_SET_CLOCK_LOW();
|
||||||
|
|
||||||
if (bitdelay_us) {
|
if (bitdelay_us) {
|
||||||
delayMicroseconds(bitdelay_us);
|
delayMicroseconds(bitdelay_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
BUSIO_SET_CLOCK_HIGH();
|
BUSIO_SET_CLOCK_HIGH();
|
||||||
|
|
||||||
if (bitdelay_us) {
|
if (bitdelay_us) {
|
||||||
delayMicroseconds(bitdelay_us);
|
delayMicroseconds(bitdelay_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_miso != -1) { // read on rising edge
|
if (_miso != -1) { // read on rising edge
|
||||||
if (BUSIO_READ_MISO()) {
|
if (BUSIO_READ_MISO()) {
|
||||||
reply |= b;
|
reply |= b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // || _dataMode == SPI_MODE1)
|
} else { // || _dataMode == SPI_MODE1)
|
||||||
|
|
||||||
BUSIO_SET_CLOCK_HIGH();
|
BUSIO_SET_CLOCK_HIGH();
|
||||||
|
|
||||||
if (bitdelay_us) {
|
if (bitdelay_us) {
|
||||||
delayMicroseconds(bitdelay_us);
|
delayMicroseconds(bitdelay_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mosi != -1) {
|
if (_mosi != -1) {
|
||||||
BUSIO_WRITE_MOSI(send & b);
|
BUSIO_WRITE_MOSI(send & b);
|
||||||
}
|
}
|
||||||
|
|
||||||
BUSIO_SET_CLOCK_LOW();
|
BUSIO_SET_CLOCK_LOW();
|
||||||
|
|
||||||
if (_miso != -1) {
|
if (_miso != -1) {
|
||||||
if (BUSIO_READ_MISO()) {
|
if (BUSIO_READ_MISO()) {
|
||||||
reply |= b;
|
reply |= b;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue