mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
refactor(timg): clean up soc layer meta data
This commit is contained in:
+15
-15
@@ -18,7 +18,7 @@
|
||||
#include "unity.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "driver/gptimer.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "soc/system_intr.h"
|
||||
#if SOC_GPSPI_SUPPORTED
|
||||
#include "soc/spi_periph.h"
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/gptimer.h"
|
||||
|
||||
#if SOC_GPTIMER_SUPPORTED
|
||||
#if SOC_HAS(GPTIMER)
|
||||
static bool on_timer_alarm(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx)
|
||||
{
|
||||
volatile int *count = (volatile int *)user_ctx;
|
||||
@@ -38,9 +38,9 @@ static bool on_timer_alarm(gptimer_handle_t timer, const gptimer_alarm_event_dat
|
||||
|
||||
static void timer_test(int flags)
|
||||
{
|
||||
static int count[SOC_TIMER_GROUP_TOTAL_TIMERS] = {0};
|
||||
gptimer_handle_t gptimers[SOC_TIMER_GROUP_TOTAL_TIMERS];
|
||||
intr_handle_t inth[SOC_TIMER_GROUP_TOTAL_TIMERS];
|
||||
static int count[SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL)] = {0};
|
||||
gptimer_handle_t gptimers[SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL)];
|
||||
intr_handle_t inth[SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL)];
|
||||
|
||||
gptimer_config_t config = {
|
||||
.clk_src = GPTIMER_CLK_SRC_DEFAULT,
|
||||
@@ -48,7 +48,7 @@ static void timer_test(int flags)
|
||||
.resolution_hz = 1000000,
|
||||
.flags.intr_shared = (flags & ESP_INTR_FLAG_SHARED) == ESP_INTR_FLAG_SHARED,
|
||||
};
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
TEST_ESP_OK(gptimer_new_timer(&config, &gptimers[i]));
|
||||
}
|
||||
gptimer_alarm_config_t alarm_config = {
|
||||
@@ -60,7 +60,7 @@ static void timer_test(int flags)
|
||||
.on_alarm = on_timer_alarm,
|
||||
};
|
||||
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
TEST_ESP_OK(gptimer_register_event_callbacks(gptimers[i], &cbs, &count[i]));
|
||||
alarm_config.alarm_count += 10000 * i;
|
||||
TEST_ESP_OK(gptimer_set_alarm_action(gptimers[i], &alarm_config));
|
||||
@@ -73,39 +73,39 @@ static void timer_test(int flags)
|
||||
if ((flags & ESP_INTR_FLAG_SHARED)) {
|
||||
/* Check that the allocated interrupts are actually shared */
|
||||
int intr_num = esp_intr_get_intno(inth[0]);
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
TEST_ASSERT_EQUAL(intr_num, esp_intr_get_intno(inth[i]));
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
printf("Timer values after 1 sec:");
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
printf(" %d", count[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
TEST_ASSERT_NOT_EQUAL(0, count[i]);
|
||||
}
|
||||
|
||||
printf("Disabling timers' interrupt...\r\n");
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
esp_intr_disable(inth[i]);
|
||||
count[i] = 0;
|
||||
}
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
printf("Timer values after 1 sec:");
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
printf(" %d", count[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
TEST_ASSERT_EQUAL(0, count[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < SOC_TIMER_GROUP_TOTAL_TIMERS; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL); i++) {
|
||||
TEST_ESP_OK(gptimer_stop(gptimers[i]));
|
||||
TEST_ESP_OK(gptimer_disable(gptimers[i]));
|
||||
TEST_ESP_OK(gptimer_del_timer(gptimers[i]));
|
||||
@@ -121,7 +121,7 @@ TEST_CASE("Intr_alloc test, shared ints", "[intr_alloc]")
|
||||
{
|
||||
timer_test(ESP_INTR_FLAG_SHARED);
|
||||
}
|
||||
#endif //SOC_GPTIMER_SUPPORTED
|
||||
#endif // SOC_HAS(GPTIMER)
|
||||
|
||||
void static test_isr(void*arg)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user