Dependents:   Kamal_CAN ReadFromSerial446

Committer:
tecnosys
Date:
Mon Oct 18 13:40:02 2010 +0000
Revision:
8:872137b3a8a8
Parent:
7:2abb9b7eec25
0.1

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;
tecnosys 1:dbc44582f2f8 17 InterruptIn _itr;
tecnosys 1:dbc44582f2f8 18 mcp2515 _mcp;
tecnosys 1:dbc44582f2f8 19 public:
tecnosys 1:dbc44582f2f8 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
tecnosys 1:dbc44582f2f8 44 #endif // _MCP2515_H_