softspim: allow phase mode 2 (safe phase)
This commit is contained in:
parent
50d233fdf7
commit
36cc688479
@ -17,19 +17,19 @@ uint8_t SpiMaster::readWrite(uint8_t in)
|
||||
writePin(_port, _pinOut, in & (1 << i));
|
||||
else
|
||||
writePin(_port, _pinOut, in & (1 << (7-i)));
|
||||
if constexpr (CLOCK_PHASE == 0)
|
||||
if constexpr (CLOCK_PHASE == 0 || CLOCK_PHASE == 2)
|
||||
_delay_us(DELAY_TIME_US);
|
||||
writePin(_port, _pinClock, !CLOCK_POLARITY);
|
||||
if constexpr (CLOCK_PHASE == 1)
|
||||
if constexpr (CLOCK_PHASE == 1 || CLOCK_PHASE == 2)
|
||||
_delay_us(DELAY_TIME_US);
|
||||
if constexpr (BIT_ORDER == 0)
|
||||
recByte |= readPin(_pinReg, _pinIn) << i;
|
||||
else
|
||||
recByte |= readPin(_pinReg, _pinIn) << (7-i);
|
||||
if constexpr (CLOCK_PHASE == 0)
|
||||
if constexpr (CLOCK_PHASE == 0 || CLOCK_PHASE == 2)
|
||||
_delay_us(DELAY_TIME_US);
|
||||
writePin(_port, _pinClock, CLOCK_POLARITY);
|
||||
if constexpr (CLOCK_PHASE == 1)
|
||||
if constexpr (CLOCK_PHASE == 1 || CLOCK_PHASE == 2)
|
||||
_delay_us(DELAY_TIME_US);
|
||||
}
|
||||
return recByte;
|
||||
|
@ -7,7 +7,7 @@ class SpiMaster
|
||||
private:
|
||||
|
||||
static constexpr uint8_t CLOCK_POLARITY = 0;
|
||||
static constexpr uint8_t CLOCK_PHASE = 0;
|
||||
static constexpr uint8_t CLOCK_PHASE = 2;
|
||||
static constexpr uint8_t BIT_ORDER = 1;
|
||||
|
||||
volatile uint8_t * const _port = &PORTB;
|
||||
|
Loading…
x
Reference in New Issue
Block a user