#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_err.h"
#include "esp_log.h"
#include "driver/twai.h"
#define EXAMPLE_TAG "TWAI master"
#define SENDMSG 0
#define RECEIVEMSG 1
#define RX_GPIO_PIN 36
#define TX_GPIO_PIN 37
/* --------------------------- Tasks and Functions -------------------------- */
void printf_msg(int flag, twai_message_t *msg) // flag:0-send 1-receive
{
int j;
if (flag)
printf("Receive: ");
else
printf("Send : ");
if (msg->extd)
printf("Extended ");
else
printf("Standard ");
if (msg->rtr)
printf("Remote Frame, ");
else
printf("Data Frame, ");
// printf("ID: 0x%lx", (unsigned long)msg->identifier);
if (msg->rtr =&#
ESP32 TWAI(can总线)设备通信
最新推荐文章于 2025-03-27 16:04:14 发布