Dependents: Kamal_CAN ReadFromSerial446 USNA-UMBC-KF-02_v3-noise USNA-UMBC-KF-01
Revision 7:2abb9b7eec25, committed 2010-06-18
- Comitter:
- tecnosys
- Date:
- Fri Jun 18 11:27:00 2010 +0000
- Parent:
- 6:36e854e627f6
- Child:
- 8:872137b3a8a8
- Commit message:
Changed in this revision
| CAN3.cpp | Show annotated file Show diff for this revision Revisions of this file |
| CAN3.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/CAN3.cpp Fri Jun 18 11:08:10 2010 +0000
+++ b/CAN3.cpp Fri Jun 18 11:27:00 2010 +0000
@@ -60,18 +60,12 @@
_itr.fall(fptr2);
}
-void CAN3::frequency(int canSpeed) {
+int CAN3::frequency(int canSpeed) {
uint8_t res;
res = _mcp.init(canSpeed); //CAN_500KBPS_8MHZ
wait(.001);
- if (res == MCP2515_OK) {
- printf("CAN Init OK\n\r");
-
- } else {
- printf("CAN Init FAIL\n\r");
- }
_mcp.setRegister(MCP_CANINTE, 0x3);//0x3); //MCP_RX_INT);
_mcp.setRegister(MCP_CANINTF, 0x3);// 0xff);
@@ -83,13 +77,19 @@
//[Set TX0,1,2 as digital inputs
//_mcp.setRegister(TXRTSCTRL, 0x0);
- printf("Setting Normal-Mode - \n\r ");
+ // printf("Setting Normal-Mode - \n\r ");
if ( _mcp.setCANCTRL_Mode(MODE_NORMAL) == MCP2515_OK) { //MODE_NORMAL MODE_LOOPBACK
- printf("OK\n\r");
+ // printf("OK\n\r");
} else {
- printf("failed\n\r");
+ error("failed\n\r");
}
_mcp.dumpExtendedStatus();
wait(.001);
+
+ if (res != MCP2515_OK) {
+ return 0;
+
+ }
+ return 1;
}
\ No newline at end of file
--- a/CAN3.h Fri Jun 18 11:08:10 2010 +0000
+++ b/CAN3.h Fri Jun 18 11:27:00 2010 +0000
@@ -21,7 +21,7 @@
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
+ int 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.