CAN-Demo/App/Src/test.cpp
2023-10-25 16:19:32 +02:00

36 lines
832 B
C++

/*
* test.cpp
*
* Created on: Oct 24, 2023
* Author: carlw
*/
//#include <sta/bus/can/controller.hpp>
#include <sta/devices/stm32/can.hpp>
//extern STM32CanController(CAN_HandleTypeDef * handle);
extern "C" void testCan(CAN_HandleTypeDef * handle){
sta::STM32CanController canController(handle);
canController.start();
// Create a CanTxHeader for your message
sta::CanTxHeader txHeader;
txHeader.id.format = sta::CanIdFormat::EXT; // Set to EXT for extended ID
txHeader.id.eid = 0xCAFE; // Set the standard ID or extended ID
txHeader.payloadLength = 8; // Set the payload length (max 8 bytes)
// Create your message payload
uint8_t payload[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
// Send the CAN message
while (true){
canController.sendFrame(txHeader, payload);
}
}