Merge pull request #25 from hurvajs/master

Examples & comments clean-up.
This commit is contained in:
Lowaichung
2016-02-19 11:34:20 +08:00
9 changed files with 33 additions and 81 deletions
+3 -9
View File
@@ -19,19 +19,13 @@ void setup()
Serial.begin(115200);
pinMode(LED,OUTPUT);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
}
+6 -12
View File
@@ -17,19 +17,13 @@ void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
}
@@ -45,12 +39,12 @@ void loop()
unsigned char canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.println("get data from ID: ");
Serial.println(canId);
Serial.print("Get data from ID: ");
Serial.println(canId, HEX);
for(int i = 0; i<len; i++) // print the data
{
Serial.print(buf[i]);
Serial.print(buf[i], HEX);
Serial.print("\t");
}
Serial.println();
@@ -21,19 +21,13 @@ void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt
}
+3 -9
View File
@@ -12,19 +12,13 @@ void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
}
unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+3 -9
View File
@@ -14,19 +14,13 @@ void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
}
unsigned char stmp[8] = {ledHIGH, 1, 2, 3, ledLOW, 5, 6, 7};
+3 -9
View File
@@ -45,19 +45,13 @@ void setup()
nh.initNode();
nh.subscribe(sub);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
}
@@ -22,19 +22,13 @@ void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt
@@ -14,19 +14,13 @@ void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
Serial.println(" Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
Serial.println("CAN BUS Shield init ok!");
}
unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+6 -6
View File
@@ -524,8 +524,8 @@ void MCP_CAN::mcp2515_read_canMsg( const INT8U buffer_sidh_addr) /* read
}
/*********************************************************************************************************
** Function name: sendMsg
** Descriptions: send message
** Function name: mcp2515_start_transmit
** Descriptions: start transmit
*********************************************************************************************************/
void MCP_CAN::mcp2515_start_transmit(const INT8U mcp_addr) /* start transmit */
{
@@ -533,8 +533,8 @@ void MCP_CAN::mcp2515_start_transmit(const INT8U mcp_addr) /* start
}
/*********************************************************************************************************
** Function name: sendMsg
** Descriptions: send message
** Function name: mcp2515_getNextFreeTXBuf
** Descriptions: get Next free txbuf
*********************************************************************************************************/
INT8U MCP_CAN::mcp2515_getNextFreeTXBuf(INT8U *txbuf_n) /* get Next free txbuf */
{
@@ -911,7 +911,7 @@ INT8U MCP_CAN::checkError(void)
/*********************************************************************************************************
** Function name: getCanId
** Descriptions: when receive something ,u can get the can id!!
** Descriptions: when receive something you can get the can id!!
*********************************************************************************************************/
INT32U MCP_CAN::getCanId(void)
{
@@ -920,7 +920,7 @@ INT32U MCP_CAN::getCanId(void)
/*********************************************************************************************************
** Function name: isRemoteRequest
** Descriptions: when receive something ,u can check if it was a request
** Descriptions: when receive something you can check if it was a request
*********************************************************************************************************/
INT8U MCP_CAN::isRemoteRequest(void)
{