11

Dependents:   yezhong_main_controller_copy_3_

Revision:
7:2abb9b7eec25
Parent:
1:dbc44582f2f8
Child:
9:4129ee73824c
--- 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