17
17
#error "Don't include this file directly, use 'mcp2515.hpp' instead!"
18
18
#endif
19
19
#include " mcp2515_bit_timings.hpp"
20
- #include " mcp2515_definitions .hpp"
20
+ #include " mcp2515_options .hpp"
21
21
#include < modm/architecture/interface/assert.hpp>
22
22
23
23
// Set the log level
@@ -234,46 +234,46 @@ modm::Mcp2515<SPI, CS, INT>::mcp2515ReadMessage()
234
234
RF_BEGIN ();
235
235
236
236
// read status flag of the device
237
- statusBufferR_ = RF_CALL (readStatus (RX_STATUS));
237
+ statusBufferR = RF_CALL (readStatus (RX_STATUS));
238
238
239
- readTemp_ = true ;
240
- if (statusBufferR_ & FLAG_RXB0_FULL) {
241
- addressBufferR_ = READ_RX; // message in buffer 0
239
+ readTemp = true ;
240
+ if (statusBufferR & FLAG_RXB0_FULL) {
241
+ addressBufferR = READ_RX; // message in buffer 0
242
242
}
243
- else if (statusBufferR_ & FLAG_RXB1_FULL) {
244
- addressBufferR_ = READ_RX | 0x04 ; // message in buffer 1 (RXB1SIDH)
243
+ else if (statusBufferR & FLAG_RXB1_FULL) {
244
+ addressBufferR = READ_RX | 0x04 ; // message in buffer 1 (RXB1SIDH)
245
245
}
246
246
else {
247
- readTemp_ = false ; // Error: no message available
247
+ readTemp = false ; // Error: no message available
248
248
}
249
249
250
- if (readTemp_ )
250
+ if (readTemp )
251
251
{
252
252
RF_WAIT_UNTIL (this ->acquireMaster ());
253
253
chipSelect.reset ();
254
- RF_CALL (spi.transfer (addressBufferR_ ));
254
+ RF_CALL (spi.transfer (addressBufferR ));
255
255
256
- messageBuffer_ .flags .extended = RF_CALL (readIdentifier (messageBuffer_ .identifier ));
257
- if (statusBufferR_ & FLAG_RTR) {
258
- messageBuffer_ .flags .rtr = true ;
256
+ messageBuffer .flags .extended = RF_CALL (readIdentifier (messageBuffer .identifier ));
257
+ if (statusBufferR & FLAG_RTR) {
258
+ messageBuffer .flags .rtr = true ;
259
259
}
260
260
else {
261
- messageBuffer_ .flags .rtr = false ;
261
+ messageBuffer .flags .rtr = false ;
262
262
}
263
263
264
- messageBuffer_ .length = RF_CALL (spi.transfer (0xff )) & 0x0f ;
264
+ messageBuffer .length = RF_CALL (spi.transfer (0xff )) & 0x0f ;
265
265
266
- for (j_ = 0 ; j_ < messageBuffer_ .length ; ++j_ ) {
267
- data_ = RF_CALL (spi.transfer (0xff ));
268
- messageBuffer_ .data [j_ ] = data_ ;
266
+ for (j = 0 ; j < messageBuffer .length ; ++j ) {
267
+ data = RF_CALL (spi.transfer (0xff ));
268
+ messageBuffer .data [j ] = data ;
269
269
}
270
270
RF_WAIT_UNTIL (this ->releaseMaster ());
271
271
chipSelect.set ();
272
272
}
273
273
// RX0IF or RX1IF respectivly were already cleared automatically by rising CS.
274
274
// See section 12.4 in datasheet.
275
275
276
- RF_END_RETURN (readTemp_ );
276
+ RF_END_RETURN (readTemp );
277
277
}
278
278
279
279
template <typename SPI, typename CS, typename INT>
@@ -288,7 +288,7 @@ modm::Mcp2515<SPI, CS, INT>::update(){
288
288
if (!interruptPin.read ()){
289
289
if (RF_CALL (mcp2515ReadMessage ()))
290
290
{
291
- if (not modm_assert_continue_ignore (rxQueue.push (messageBuffer_ ), " mcp2515.can.tx" ,
291
+ if (not modm_assert_continue_ignore (rxQueue.push (messageBuffer ), " mcp2515.can.tx" ,
292
292
" CAN transmit software buffer overflowed!" , 1 )){}
293
293
}
294
294
}
@@ -313,16 +313,16 @@ modm::Mcp2515<SPI, CS, INT>::mcp2515IsReadyToSend()
313
313
314
314
RF_BEGIN ();
315
315
316
- tempS_ = true ;
317
- statusBufferReady_ = RF_CALL (readStatus (READ_STATUS));
318
- if (( statusBufferReady_ & (TXB2CNTRL_TXREQ | TXB1CNTRL_TXREQ | TXB0CNTRL_TXREQ)) ==
316
+ tempS = true ;
317
+ statusBufferReady = RF_CALL (readStatus (READ_STATUS));
318
+ if (( statusBufferReady & (TXB2CNTRL_TXREQ | TXB1CNTRL_TXREQ | TXB0CNTRL_TXREQ)) ==
319
319
(TXB2CNTRL_TXREQ | TXB1CNTRL_TXREQ | TXB0CNTRL_TXREQ))
320
320
{
321
321
// all buffers currently in use
322
- tempS_ = false ;
322
+ tempS = false ;
323
323
}
324
324
325
- RF_END_RETURN (tempS_ );
325
+ RF_END_RETURN (tempS );
326
326
}
327
327
template <typename SPI, typename CS, typename INT>
328
328
bool
@@ -347,32 +347,32 @@ modm::Mcp2515<SPI, CS, INT>::mcp2515SendMessage(const can::Message& message)
347
347
using namespace modm ::mcp2515;
348
348
RF_BEGIN ();
349
349
350
- statusBufferS_ = RF_CALL (readStatus (READ_STATUS));
350
+ statusBufferS = RF_CALL (readStatus (READ_STATUS));
351
351
352
- addressBufferS_ = static_cast <uint8_t >(false );
352
+ addressBufferS = static_cast <uint8_t >(false );
353
353
354
354
// /// send if ready, else return that nothing was sent
355
- if (mcp2515IsReadyToSend (statusBufferS_ ))
355
+ if (mcp2515IsReadyToSend (statusBufferS ))
356
356
{
357
- if ((statusBufferS_ & TXB0CNTRL_TXREQ) == 0 )
357
+ if ((statusBufferS & TXB0CNTRL_TXREQ) == 0 )
358
358
{
359
- addressBufferS_ = 0x00 ; // TXB0SIDH
360
- } else if ((statusBufferS_ & TXB1CNTRL_TXREQ) == 0 )
359
+ addressBufferS = 0x00 ; // TXB0SIDH
360
+ } else if ((statusBufferS & TXB1CNTRL_TXREQ) == 0 )
361
361
{
362
- addressBufferS_ = 0x02 ; // TXB1SIDH
363
- } else if ((statusBufferS_ & TXB2CNTRL_TXREQ) == 0 )
362
+ addressBufferS = 0x02 ; // TXB1SIDH
363
+ } else if ((statusBufferS & TXB2CNTRL_TXREQ) == 0 )
364
364
{
365
- addressBufferS_ = 0x04 ; // TXB2SIDH
365
+ addressBufferS = 0x04 ; // TXB2SIDH
366
366
} else
367
367
{
368
368
// all buffer are in use => could not send the message
369
369
}
370
370
371
- if (addressBufferS_ == 0x00 || addressBufferS_ == 0x02 || addressBufferS_ == 0x04 )
371
+ if (addressBufferS == 0x00 || addressBufferS == 0x02 || addressBufferS == 0x04 )
372
372
{
373
373
RF_WAIT_UNTIL (this ->acquireMaster ());
374
374
chipSelect.reset ();
375
- RF_CALL (spi.transfer (WRITE_TX | addressBufferS_ ));
375
+ RF_CALL (spi.transfer (WRITE_TX | addressBufferS ));
376
376
RF_CALL (writeIdentifier (message.identifier , message.flags .extended ));
377
377
378
378
// if the message is a rtr-frame, is has a length but no attached data
@@ -383,24 +383,24 @@ modm::Mcp2515<SPI, CS, INT>::mcp2515SendMessage(const can::Message& message)
383
383
{
384
384
RF_CALL (spi.transfer (message.length ));
385
385
386
- for (i_ = 0 ; i_ < message.length ; ++i_ ) {
387
- RF_CALL (spi.transfer (message.data [i_ ]));
386
+ for (i = 0 ; i < message.length ; ++i ) {
387
+ RF_CALL (spi.transfer (message.data [i ]));
388
388
}
389
389
}
390
- delayS_ .restart (1ms);
390
+ delayS .restart (1ms);
391
391
chipSelect.set ();
392
- RF_WAIT_UNTIL (delayS_ .isExpired ());
392
+ RF_WAIT_UNTIL (delayS .isExpired ());
393
393
394
394
// send message via RTS command
395
395
chipSelect.reset ();
396
- addressBufferS_ = (addressBufferS_ == 0 ) ? 1 : addressBufferS_ ; // 0 2 4 => 1 2 4
397
- RF_CALL (spi.transfer (RTS | addressBufferS_ ));
396
+ addressBufferS = (addressBufferS == 0 ) ? 1 : addressBufferS ; // 0 2 4 => 1 2 4
397
+ RF_CALL (spi.transfer (RTS | addressBufferS ));
398
398
RF_WAIT_UNTIL (this ->releaseMaster ());
399
399
chipSelect.set ();
400
400
}
401
401
}
402
402
403
- RF_END_RETURN (static_cast <bool >(addressBufferS_ ));
403
+ RF_END_RETURN (static_cast <bool >(addressBufferS ));
404
404
}
405
405
406
406
// ----------------------------------------------------------------------------
@@ -449,11 +449,11 @@ modm::Mcp2515<SPI, CS, INT>::readStatus(uint8_t type)
449
449
RF_WAIT_UNTIL (this ->acquireMaster ());
450
450
chipSelect.reset ();
451
451
RF_CALL (spi.transfer (type));
452
- statusBuffer_ = RF_CALL (spi.transfer (0xff ));
452
+ statusBuffer = RF_CALL (spi.transfer (0xff ));
453
453
RF_WAIT_UNTIL (this ->releaseMaster ());
454
454
chipSelect.set ();
455
455
456
- RF_END_RETURN (statusBuffer_ );
456
+ RF_END_RETURN (statusBuffer );
457
457
}
458
458
459
459
// ----------------------------------------------------------------------------
@@ -474,10 +474,10 @@ modm::Mcp2515<SPI, CS, INT>::writeIdentifier(const uint32_t& identifier,
474
474
RF_CALL (spi.transfer (*((uint16_t *)ptr + 1 ) >> 5 ));
475
475
476
476
// calculate the next values
477
- a_ = (*((uint8_t *)ptr + 2 ) << 3 ) & 0xe0 ;
478
- a_ |= MCP2515_IDE;
479
- a_ |= (*((uint8_t *)ptr + 2 )) & 0x03 ;
480
- RF_CALL (spi.transfer (a_ ));
477
+ a = (*((uint8_t *)ptr + 2 ) << 3 ) & 0xe0 ;
478
+ a |= MCP2515_IDE;
479
+ a |= (*((uint8_t *)ptr + 2 )) & 0x03 ;
480
+ RF_CALL (spi.transfer (a ));
481
481
RF_CALL (spi.transfer (*((uint8_t *)ptr + 1 )));
482
482
RF_CALL (spi.transfer (*((uint8_t *)ptr)));
483
483
} else
@@ -502,36 +502,36 @@ modm::Mcp2515<SPI, CS, INT>::readIdentifier(uint32_t &identifier)
502
502
RF_BEGIN ();
503
503
504
504
RF_WAIT_UNTIL (this ->acquireMaster ());
505
- a_ = RF_CALL (spi.transfer (0xff ));
506
- b_ = RF_CALL (spi.transfer (0xff ));
505
+ a = RF_CALL (spi.transfer (0xff ));
506
+ b = RF_CALL (spi.transfer (0xff ));
507
507
508
- temp_ = false ;
508
+ temp = false ;
509
509
510
- if (b_ & MCP2515_IDE)
510
+ if (b & MCP2515_IDE)
511
511
{
512
- *((uint16_t *)ptr + 1 ) = (uint16_t )a_ << 5 ;
512
+ *((uint16_t *)ptr + 1 ) = (uint16_t )a << 5 ;
513
513
*((uint8_t *)ptr + 1 ) = RF_CALL (spi.transfer (0xff ));
514
514
515
- *((uint8_t *)ptr + 2 ) |= (b_ >> 3 ) & 0x1C ;
516
- *((uint8_t *)ptr + 2 ) |= b_ & 0x03 ;
515
+ *((uint8_t *)ptr + 2 ) |= (b >> 3 ) & 0x1C ;
516
+ *((uint8_t *)ptr + 2 ) |= b & 0x03 ;
517
517
518
518
*((uint8_t *)ptr) = RF_CALL (spi.transfer (0xff ));
519
519
520
- temp_ = true ;
520
+ temp = true ;
521
521
} else
522
522
{
523
523
RF_CALL (spi.transfer (0xff ));
524
524
525
525
*((uint8_t *)ptr + 3 ) = 0 ;
526
526
*((uint8_t *)ptr + 2 ) = 0 ;
527
527
528
- *((uint16_t *)ptr) = (uint16_t )a_ << 3 ;
528
+ *((uint16_t *)ptr) = (uint16_t )a << 3 ;
529
529
530
530
RF_CALL (spi.transfer (0xff ));
531
531
532
- *((uint8_t *)ptr) |= b_ >> 5 ;
532
+ *((uint8_t *)ptr) |= b >> 5 ;
533
533
}
534
534
RF_WAIT_UNTIL (this ->releaseMaster ());
535
535
536
- RF_END_RETURN (temp_ );
536
+ RF_END_RETURN (temp );
537
537
}
0 commit comments