esp8266/modesp: flash_write(): Writes in multiples of 4 bytes.

pull/1945/head
Paul Sokolovsky 2016-03-27 15:32:58 +03:00
rodzic 53302f1616
commit fd86bf5917
1 zmienionych plików z 3 dodań i 0 usunięć

Wyświetl plik

@ -553,6 +553,9 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) {
mp_int_t offset = mp_obj_get_int(offset_in);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
if (bufinfo.len & 0x3) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "len must be multiple of 4"));
}
SpiFlashOpResult res = spi_flash_write(offset, bufinfo.buf, bufinfo.len);
if (res == SPI_FLASH_RESULT_OK) {
return mp_const_none;