1
Dependents: yezhong_main_controller_copy yezhong_main_controller_copy_1 yezhong_main_controller_copy yezhong_main_controller_copy-
Diff: CAN3.h
- Revision:
- 1:dbc44582f2f8
- Child:
- 7:2abb9b7eec25
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CAN3.h Sun Jun 13 09:52:03 2010 +0000 @@ -0,0 +1,44 @@ + +#ifndef _CAN3_H_ +#define _CAN3_H_ + +#include "mbed.h" +#include "mcp2515.h" +#include "mcp2515_defs.h" +#include "mcp2515_can.h" +#include "SPI.h" + +#define BFPCTRL 0x0C +#define TXRTSCTRL 0x0D + + +class CAN3 { + SPI& spi; + InterruptIn _itr; + mcp2515 _mcp; +public: + CAN3(SPI& _spi, PinName ncs, PinName itr); + + uint8_t read(CANMessage *msg); // int read(CANMessage& msg); + void write(CANMessage* test); //int write(CANMessage msg); + void frequency( int canSpeed); //Set the frequency of the CAN interface hz The bus frequency in hertz + + + void reset(); //Reset CAN interface. To use after error overflow. + unsigned char rderror(); //Returns number of read errors to detect read overflow errors. + unsigned char tderror(); //Returns number of write errors to detect write overflow errors. + + void rise(void (*fptr)(void)); + void fall(void (*fptr2)(void)); + + + + + // Private functions +private : + uint8_t checkReceive(void); + + +}; + +#endif // _MCP2515_H_