mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/CAN-Demo.git
synced 2025-06-10 02:55:59 +00:00
36 lines
832 B
C++
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);
|
|
}
|
|
|
|
}
|
|
|