@@ -123,14 +123,15 @@ modm::Mcp2515<SPI, CS, INT>::setFilter(accessor::Flash<uint8_t> filter)
123
123
{
124
124
using namespace mcp2515 ;
125
125
126
+ while (!this ->acquireMaster ()){};
127
+
126
128
// change to configuration mode
127
129
bitModify (CANCTRL, 0xe0 , REQOP2);
128
130
129
131
while ((readRegister (CANSTAT) & 0xe0 ) != REQOP2);
130
132
writeRegister (RXB0CTRL, BUKT);
131
133
writeRegister (RXB1CTRL, 0 );
132
134
133
- while (!this ->acquireMaster ()){};
134
135
uint8_t i, j;
135
136
for (i = 0 ; i < 0x30 ; i += 0x10 )
136
137
{
@@ -147,10 +148,10 @@ modm::Mcp2515<SPI, CS, INT>::setFilter(accessor::Flash<uint8_t> filter)
147
148
}
148
149
chipSelect.set ();
149
150
}
150
- while (!this ->releaseMaster ());
151
151
chipSelect.set ();
152
-
153
152
bitModify (CANCTRL, 0xe0 , 0 );
153
+
154
+ while (!this ->releaseMaster ());
154
155
}
155
156
156
157
// ----------------------------------------------------------------------------
@@ -430,13 +431,11 @@ template <typename SPI, typename CS, typename INT>
430
431
void
431
432
modm::Mcp2515<SPI, CS, INT>::bitModify(uint8_t address, uint8_t mask, uint8_t data)
432
433
{
433
- while (!this ->acquireMaster ()){};
434
434
chipSelect.reset ();
435
435
spi.transferBlocking (BIT_MODIFY);
436
436
spi.transferBlocking (address);
437
437
spi.transferBlocking (mask);
438
438
spi.transferBlocking (data);
439
- while (!this ->releaseMaster ()){}
440
439
chipSelect.set ();
441
440
}
442
441
0 commit comments