Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 17:faa4d4976d22
- Parent:
- 16:f4277e9b8612
- Child:
- 18:e6ed582f7022
--- a/main.cpp Sat Jun 29 09:53:19 2019 +0000 +++ b/main.cpp Sat Jul 06 09:47:09 2019 +0000 @@ -51,7 +51,7 @@ DigitalOut output3(PB_7); DigitalIn input1(PC_6); DigitalIn input2(PC_8); - +int current_weight; EEPROM ep(SDA,SCL,EEPROM_ADDR,EEPROM::T24C256); extern void eeprom_test(void); int device_address = DEVICE_DEFAULT_ADDRESS; // address 11 bits: last 8 bits is device_address @@ -247,6 +247,26 @@ } } //button4-- +void can_sendData(int can_id, uint8_t *tx_data, int length) +{ + CANMessage txmsg; + + txmsg.format = CANExtended; + txmsg.id = can_id; + txmsg.len = length; + txmsg.data[0] = tx_data[0]; + txmsg.data[1] = tx_data[1]; + txmsg.data[2] = tx_data[2]; + txmsg.data[3] = tx_data[3]; + txmsg.data[4] = tx_data[4]; + txmsg.data[5] = tx_data[5]; + txmsg.data[6] = tx_data[6]; + txmsg.data[7] = tx_data[7]; + + printf("can_sendData can_id=0x%08x \r\n", can_id); + can1.write(txmsg); +} + void can_rxthread() { int loop; @@ -375,7 +395,7 @@ #ifdef LCD_1602 lcd.printf(0, 0, "%d ", idx ); // line# (0 or 1), string #endif - can1.write(CANMessage((init_id + idx%10), reinterpret_cast<char*>(can_tx_data), 8)); + can1.write(CANMessage((init_id + idx%10), reinterpret_cast<char*>(can_tx_data), 8, CANData,CANExtended)); led1 = !led1; can_tx_data[0]++; }