From 8d7074ed5cafff28ae6828386c272dbe420a72a3 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 5 May 2017 14:16:02 +1000 Subject: [PATCH] soc: Move esp_ptr_dma_capable() function to soc_memory_layout.h --- components/driver/spi_master.c | 1 + components/driver/spi_slave.c | 1 + components/soc/esp32/include/soc/soc.h | 4 ++++ components/soc/include/soc/soc_memory_layout.h | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index a1c8978e4d..f34d5bc90c 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -53,6 +53,7 @@ queue and re-enabling the interrupt will trigger the interrupt again, which can #include "freertos/task.h" #include "freertos/ringbuf.h" #include "soc/soc.h" +#include "soc/soc_memory_layout.h" #include "soc/dport_reg.h" #include "rom/lldesc.h" #include "driver/gpio.h" diff --git a/components/driver/spi_slave.c b/components/driver/spi_slave.c index c7816f3678..7600b4e45c 100644 --- a/components/driver/spi_slave.c +++ b/components/driver/spi_slave.c @@ -32,6 +32,7 @@ #include "freertos/task.h" #include "freertos/ringbuf.h" #include "soc/soc.h" +#include "soc/soc_memory_layout.h" #include "soc/dport_reg.h" #include "rom/lldesc.h" #include "driver/gpio.h" diff --git a/components/soc/esp32/include/soc/soc.h b/components/soc/esp32/include/soc/soc.h index 45b6bfc6f0..fdcf92cd3b 100644 --- a/components/soc/esp32/include/soc/soc.h +++ b/components/soc/esp32/include/soc/soc.h @@ -287,6 +287,10 @@ #define SOC_DIRAM_DRAM_LOW 0x3FFE0000 #define SOC_DIRAM_DRAM_HIGH 0x3FFFFFFC +// Region of memory accessible via DMA. See esp_ptr_dma_capable(). +#define SOC_DMA_LOW 0x3FFAE000 +#define SOC_DMA_HIGH 0x40000000 + //Interrupt hardware source table //This table is decided by hardware, don't touch this. #define ETS_WIFI_MAC_INTR_SOURCE 0/**< interrupt of WiFi MAC, level*/ diff --git a/components/soc/include/soc/soc_memory_layout.h b/components/soc/include/soc/soc_memory_layout.h index ad3374fca9..0fac1cc425 100644 --- a/components/soc/include/soc/soc_memory_layout.h +++ b/components/soc/include/soc/soc_memory_layout.h @@ -58,4 +58,7 @@ typedef struct extern const soc_reserved_region_t soc_reserved_regions[]; extern const size_t soc_reserved_region_count; - +inline bool esp_ptr_dma_capable(const void *p) +{ + return (intptr_t)p >= SOC_DMA_LOW && (intptr_t)p < SOC_DMA_HIGH; +}