1
Dependents: yezhong_main_controller_copy yezhong_main_controller_copy_1 yezhong_main_controller_copy yezhong_main_controller_copy-
CAN3.h@9:a35b78afe3e3, 2022-01-11 (annotated)
- Committer:
- yezhong
- Date:
- Tue Jan 11 02:18:01 2022 +0000
- Revision:
- 9:a35b78afe3e3
- Parent:
- 7:2abb9b7eec25
1
Who changed what in which revision?
User | Revision | Line number | New 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; |
yezhong | 9:a35b78afe3e3 | 17 | //InterruptIn _itr; |
tecnosys | 1:dbc44582f2f8 | 18 | mcp2515 _mcp; |
tecnosys | 1:dbc44582f2f8 | 19 | public: |
yezhong | 9:a35b78afe3e3 | 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 | // Private functions |
tecnosys | 1:dbc44582f2f8 | 35 | private : |
tecnosys | 1:dbc44582f2f8 | 36 | uint8_t checkReceive(void); |
tecnosys | 1:dbc44582f2f8 | 37 | |
tecnosys | 1:dbc44582f2f8 | 38 | |
tecnosys | 1:dbc44582f2f8 | 39 | }; |
tecnosys | 1:dbc44582f2f8 | 40 | |
yezhong | 9:a35b78afe3e3 | 41 | #endif // _CAN3_H_ |