PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

beta_sample.ino 1.1KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <FlexCAN_T4.h>
  2. FlexCAN_T4FD<CAN3, RX_SIZE_256, TX_SIZE_16> FD;
  3. void setup(void) {
  4. Serial.begin(115200); delay(500);
  5. pinMode(6, OUTPUT); digitalWrite(6, LOW);
  6. FD.begin();
  7. CANFD_timings_t config;
  8. config.clock = CLK_24MHz;
  9. config.baudrate = 1000000;
  10. config.baudrateFD = 2000000;
  11. config.propdelay = 190;
  12. config.bus_length = 1;
  13. config.sample = 87.5;
  14. FD.setRegions(64);
  15. FD.setBaudRate(config);
  16. FD.mailboxStatus();
  17. }
  18. void loop() {
  19. CANFD_message_t msg;
  20. msg.len = 8; msg.id = 0x321;
  21. msg.buf[0] = 1; msg.buf[1] = 2; msg.buf[2] = 3; msg.buf[3] = 4;
  22. msg.buf[4] = 5; msg.buf[5] = 6; msg.buf[6] = 7; msg.buf[7] = 8;
  23. FD.write(msg);
  24. if ( FD.read(msg) ) {
  25. Serial.print("MB: "); Serial.print(msg.mb);
  26. Serial.print(" ID: 0x"); Serial.print(msg.id, HEX );
  27. Serial.print(" EXT: "); Serial.print(msg.flags.extended );
  28. Serial.print(" LEN: "); Serial.print(msg.len);
  29. Serial.print(" DATA: ");
  30. for ( uint8_t i = 0; i < 8; i++ ) {
  31. Serial.print(msg.buf[i]); Serial.print(" ");
  32. }
  33. Serial.print(" TS: "); Serial.println(msg.timestamp);
  34. }
  35. delay(50);
  36. }