在使用esp-idf-v4.4的库及esp32-c3-s32模组的情况下,遇到twai功能的两个GPIO2/GPIO3无数据波形的情况,有朋友遇到过吗?如何解决
void app_main(void)
{
twai_message_t message;
esp_err_t err;
//Ini
tialize configuration structures using macro initializers
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPIO_NUM, RX_GPIO_NUM, TWAI_MODE_NORMAL);
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_500KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
//Install TWAI driver
if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK)
{
ESP_LOGI(EXAMPLE_TAG, "Driver installedn");
}
else
{
ESP_LOGI(EXAMPLE_TAG, "Failed to install drivern");
return;
}
//Start TWAI driver
if (twai_start() == ESP_OK)
{
ESP_LOGI(EXAMPLE_TAG, "Driver startedn");
}
else
{
ESP_LOGI(EXAMPLE_TAG, "Failed to start drivern");
return;
}
message.identifier = 0xAAAA;
message.extd = 1;
message.data_length_code = 8;
for (int i = 0; i < 8; i++)
{
message.data
= 0x0A;
}
while(1)
{
//Queue message for transmission
err = twai_transmit(&message, portMAX_DELAY);
if (err == ESP_OK)
{
ESP_LOGI(EXAMPLE_TAG,"Message queued for transmissionn");
}
else
{
ESP_LOGI(EXAMPLE_TAG,"Failed to queue message for transmissionn");
twai_clear_transmit_queue();
}
vTaskDelay(pdMS_TO_TICKS(10000));
}
vTaskDelete(NULL);
}