MCP2515 CAN library

Fork of mcp2515 by Jason Engelman

Committer:
driscoll85
Date:
Mon Jul 24 18:12:55 2017 +0000
Revision:
13:ff12c7f532f9
Parent:
9:d50f103848e0
Child:
15:5a3fdb039965
Updates to remove needed irq pin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tecnosys 1:dbc44582f2f8 1
tecnosys 1:dbc44582f2f8 2 #ifndef _CAN3_H_
tecnosys 1:dbc44582f2f8 3 #define _CAN3_H_
tecnosys 1:dbc44582f2f8 4
tecnosys 1:dbc44582f2f8 5 #include "mbed.h"
tecnosys 1:dbc44582f2f8 6 #include "mcp2515.h"
tecnosys 1:dbc44582f2f8 7 #include "mcp2515_defs.h"
tecnosys 1:dbc44582f2f8 8 #include "mcp2515_can.h"
tecnosys 1:dbc44582f2f8 9 #include "SPI.h"
tecnosys 1:dbc44582f2f8 10
tecnosys 1:dbc44582f2f8 11 #define BFPCTRL 0x0C
tecnosys 1:dbc44582f2f8 12 #define TXRTSCTRL 0x0D
tecnosys 1:dbc44582f2f8 13
tecnosys 1:dbc44582f2f8 14
tecnosys 1:dbc44582f2f8 15 class CAN3 {
tecnosys 1:dbc44582f2f8 16 SPI& spi;
driscoll85 13:ff12c7f532f9 17 //InterruptIn _itr;
tecnosys 1:dbc44582f2f8 18 mcp2515 _mcp;
tecnosys 1:dbc44582f2f8 19 public:
driscoll85 13:ff12c7f532f9 20 CAN3(SPI& _spi, PinName ncs);//, PinName itr);
tecnosys 1:dbc44582f2f8 21
tecnosys 1:dbc44582f2f8 22 uint8_t read(CANMessage *msg); // int read(CANMessage& msg);
tecnosys 1:dbc44582f2f8 23 void write(CANMessage* test); //int write(CANMessage msg);
tecnosys 7:2abb9b7eec25 24 int frequency( int canSpeed); //Set the frequency of the CAN interface hz The bus frequency in hertz
tecnosys 1:dbc44582f2f8 25
tecnosys 1:dbc44582f2f8 26
tecnosys 1:dbc44582f2f8 27 void reset(); //Reset CAN interface. To use after error overflow.
tecnosys 1:dbc44582f2f8 28 unsigned char rderror(); //Returns number of read errors to detect read overflow errors.
tecnosys 1:dbc44582f2f8 29 unsigned char tderror(); //Returns number of write errors to detect write overflow errors.
tecnosys 1:dbc44582f2f8 30
tecnosys 1:dbc44582f2f8 31 void rise(void (*fptr)(void));
tecnosys 1:dbc44582f2f8 32 void fall(void (*fptr2)(void));
tecnosys 1:dbc44582f2f8 33
tecnosys 1:dbc44582f2f8 34
tecnosys 1:dbc44582f2f8 35
tecnosys 1:dbc44582f2f8 36
tecnosys 1:dbc44582f2f8 37 // Private functions
tecnosys 1:dbc44582f2f8 38 private :
tecnosys 1:dbc44582f2f8 39 uint8_t checkReceive(void);
tecnosys 1:dbc44582f2f8 40
tecnosys 1:dbc44582f2f8 41
tecnosys 1:dbc44582f2f8 42 };
tecnosys 1:dbc44582f2f8 43
driscoll85 9:d50f103848e0 44 #endif // _CAN3_H_