Created
October 23, 2020 14:54
-
-
Save jepler/1c90b383888ca40f3dbafd0b4d68ce9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/examples/peripherals/twai/twai_self_test/main/Kconfig.projbuild b/examples/peripherals/twai/twai_self_test/main/Kconfig.projbuild | |
index 125931f16..25b1f306f 100644 | |
--- a/examples/peripherals/twai/twai_self_test/main/Kconfig.projbuild | |
+++ b/examples/peripherals/twai/twai_self_test/main/Kconfig.projbuild | |
@@ -2,7 +2,7 @@ menu "Example Configuration" | |
config EXAMPLE_TX_GPIO_NUM | |
int "TX GPIO number" | |
- default 20 if IDF_TARGET_ESP32S2 | |
+ default 17 if IDF_TARGET_ESP32S2 | |
default 21 if IDF_TARGET_ESP32 | |
help | |
This option selects the GPIO pin used for the TX signal. Connect the | |
@@ -10,7 +10,7 @@ menu "Example Configuration" | |
config EXAMPLE_RX_GPIO_NUM | |
int "RX GPIO number" | |
- default 21 if IDF_TARGET_ESP32S2 | |
+ default 18 if IDF_TARGET_ESP32S2 | |
default 22 if IDF_TARGET_ESP32 | |
help | |
This option selects the GPIO pin used for the RX signal. Connect the | |
diff --git a/examples/peripherals/twai/twai_self_test/main/twai_self_test_example_main.c b/examples/peripherals/twai/twai_self_test/main/twai_self_test_example_main.c | |
index 0feda1d24..16a4984cf 100644 | |
--- a/examples/peripherals/twai/twai_self_test/main/twai_self_test_example_main.c | |
+++ b/examples/peripherals/twai/twai_self_test/main/twai_self_test_example_main.c | |
@@ -26,6 +26,7 @@ | |
#include "esp_err.h" | |
#include "esp_log.h" | |
#include "driver/twai.h" | |
+#include "hal/twai_ll.h" | |
/* --------------------- Definitions and static variables ------------------ */ | |
@@ -41,10 +42,7 @@ | |
#define EXAMPLE_TAG "TWAI Self Test" | |
static const twai_timing_config_t t_config = TWAI_TIMING_CONFIG_25KBITS(); | |
-//Filter all other IDs except MSG_ID | |
-static const twai_filter_config_t f_config = {.acceptance_code = (MSG_ID << 21), | |
- .acceptance_mask = ~(TWAI_STD_ID_MASK << 21), | |
- .single_filter = true}; | |
+static const twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); | |
//Set to NO_ACK mode due to self testing with single module | |
static const twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPIO_NUM, RX_GPIO_NUM, TWAI_MODE_NO_ACK); | |
@@ -122,7 +120,31 @@ void app_main(void) | |
//Install TWAI driver | |
ESP_ERROR_CHECK(twai_driver_install(&g_config, &t_config, &f_config)); | |
+ | |
+ ESP_LOGI(EXAMPLE_TAG, "TWAI @ %p", &TWAI); | |
+ | |
ESP_LOGI(EXAMPLE_TAG, "Driver installed"); | |
+ ESP_LOGI(EXAMPLE_TAG, "f_config.acceptance_code = 0x%08x", f_config.acceptance_code); | |
+ ESP_LOGI(EXAMPLE_TAG, "f_config.acceptance_mask = 0x%08x", f_config.acceptance_mask); | |
+ ESP_LOGI(EXAMPLE_TAG, "f_config.single_filter = 0x%08x", f_config.single_filter); | |
+ | |
+#define PRINT_REG(x) \ | |
+ ESP_LOGI(EXAMPLE_TAG, #x " = 0x%08x", TWAI.x.val); | |
+ PRINT_REG(mode_reg); | |
+ PRINT_REG(command_reg); | |
+ PRINT_REG(status_reg); | |
+ PRINT_REG(clock_divider_reg); | |
+ | |
+ ESP_LOGI(EXAMPLE_TAG, "acceptance_filter.acr[] ="); | |
+ for(int i=0; i<4; i++) { | |
+ ESP_LOGI(EXAMPLE_TAG, " %02x", TWAI.acceptance_filter.acr[i].byte); | |
+ } | |
+ ESP_LOGI(EXAMPLE_TAG, "\n"); | |
+ ESP_LOGI(EXAMPLE_TAG, "acceptance_filter.amr[] ="); | |
+ for(int i=0; i<4; i++) { | |
+ ESP_LOGI(EXAMPLE_TAG, " %02x", TWAI.acceptance_filter.amr[i].byte); | |
+ } | |
+ ESP_LOGI(EXAMPLE_TAG, "\n"); | |
//Start control task | |
xSemaphoreGive(ctrl_sem); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment