Merge branch 'master' into feature/esp32s2beta_merge

This commit is contained in:
Angus Gratton
2019-10-22 13:51:49 +11:00
committed by Angus Gratton
143 changed files with 4319 additions and 1090 deletions

View File

@@ -28,6 +28,7 @@
#include "soc/timer_periph.h"
#include "esp_heap_caps.h"
#define MIN_BLOCK_SIZE 12
/* Base offset in flash for tests. */
static size_t start;
@@ -285,4 +286,37 @@ TEST_CASE("spi_flash_write can write from external RAM buffer", "[spi_flash]")
free(buf_int);
}
TEST_CASE("spi_flash_read less than 16 bytes into buffer in external RAM", "[spi_flash]")
{
uint8_t *buf_ext_8 = (uint8_t *) heap_caps_malloc(MIN_BLOCK_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
TEST_ASSERT_NOT_NULL(buf_ext_8);
uint8_t *buf_int_8 = (uint8_t *) heap_caps_malloc(MIN_BLOCK_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
TEST_ASSERT_NOT_NULL(buf_int_8);
uint8_t data_8[MIN_BLOCK_SIZE];
for (int i = 0; i < MIN_BLOCK_SIZE; i++) {
data_8[i] = i;
}
const esp_partition_t *part = get_test_data_partition();
TEST_ESP_OK(spi_flash_erase_range(part->address, SPI_FLASH_SEC_SIZE));
TEST_ESP_OK(spi_flash_write(part->address, data_8, MIN_BLOCK_SIZE));
TEST_ESP_OK(spi_flash_read(part->address, buf_ext_8, MIN_BLOCK_SIZE));
TEST_ESP_OK(spi_flash_read(part->address, buf_int_8, MIN_BLOCK_SIZE));
TEST_ASSERT_EQUAL(0, memcmp(buf_ext_8, data_8, MIN_BLOCK_SIZE));
TEST_ASSERT_EQUAL(0, memcmp(buf_int_8, data_8, MIN_BLOCK_SIZE));
if (buf_ext_8) {
free(buf_ext_8);
buf_ext_8 = NULL;
}
if (buf_int_8) {
free(buf_int_8);
buf_int_8 = NULL;
}
}
#endif // CONFIG_SPIRAM