diff --git a/core/esp_spi.c b/core/esp_spi.c index c6c0546..7a8704c 100644 --- a/core/esp_spi.c +++ b/core/esp_spi.c @@ -178,7 +178,7 @@ static void _spi_buf_prepare(uint8_t bus, size_t len, spi_endianness_t e, spi_wo if (e == SPI_LITTLE_ENDIAN || word_size == SPI_32BIT) return; size_t count = word_size == SPI_16BIT ? (len + 1) / 2 : (len + 3) / 4; - uint32_t *data = (uint32_t *)&SPI(bus).W0; + uint32_t *data = (uint32_t *)SPI(bus).W; for (size_t i = 0; i < count; i ++) { data[i] = word_size == SPI_16BIT @@ -193,14 +193,14 @@ static void _spi_buf_transfer(uint8_t bus, const void *out_data, void *in_data, _wait(bus); size_t bytes = len * (uint8_t)word_size; _set_size(bus, bytes); - memcpy((void *)&SPI(bus).W0, out_data, bytes); + memcpy((void *)SPI(bus).W, out_data, bytes); _spi_buf_prepare(bus, len, e, word_size); _start(bus); _wait(bus); if (in_data) { _spi_buf_prepare(bus, len, e, word_size); - memcpy(in_data, (void *)&SPI(bus).W0, bytes); + memcpy(in_data, (void *)SPI(bus).W, bytes); } } diff --git a/include/espressif/spi_flash.h b/include/espressif/spi_flash.h index f08cda9..61f8ae9 100644 --- a/include/espressif/spi_flash.h +++ b/include/espressif/spi_flash.h @@ -36,7 +36,7 @@ sdk_SpiFlashOpResult sdk_spi_flash_erase_sector(uint16_t sec); src is pointer to a buffer to read bytes from. Should be 4-byte aligned. size is length of buffer in bytes. Should be a multiple of 4. */ -sdk_SpiFlashOpResult sdk_spi_flash_write(uint32_t des_addr, const void *src, uint32_t size); +sdk_SpiFlashOpResult sdk_spi_flash_write(uint32_t des_addr, uint32_t *src, uint32_t size); /* Read data from flash. @@ -44,8 +44,12 @@ sdk_SpiFlashOpResult sdk_spi_flash_write(uint32_t des_addr, const void *src, uin des is pointer to a buffer to read bytes into. Should be 4-byte aligned. size is number of bytes to read. Should be a multiple of 4. */ -sdk_SpiFlashOpResult sdk_spi_flash_read(uint32_t src_addr, void *des, uint32_t size); +sdk_SpiFlashOpResult sdk_spi_flash_read(uint32_t src_addr, uint32_t *des, uint32_t size); +/* SDK uses this structure internally to account for flash size. + + See flashchip.h for more info. +*/ extern sdk_flashchip_t sdk_flashchip; #ifdef __cplusplus diff --git a/open_esplibs/libmain/timers.c b/open_esplibs/libmain/timers.c index 1359fc1..1e2a920 100644 --- a/open_esplibs/libmain/timers.c +++ b/open_esplibs/libmain/timers.c @@ -1,4 +1,5 @@ #include "etstimer.h" +#include "stdio.h" struct timer_list_st { struct timer_list_st *next;