Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
90202b4c
Commit
90202b4c
authored
Nov 24, 2015
by
Paul Sokolovsky
Browse files
esp8266/modesp: Implement flash_read(offset, size_bytes) function.
Based on vendor API documentation, untested on real hardware.
parent
ff8c4188
Changes
2
Show whitespace changes
Inline
Side-by-side
esp8266/modesp.c
View file @
90202b4c
...
...
@@ -27,6 +27,7 @@
#include
<stdio.h>
#include
<string.h>
#include
<stdbool.h>
#include
<errno.h>
#include
"py/nlr.h"
#include
"py/obj.h"
...
...
@@ -569,6 +570,20 @@ STATIC mp_obj_t esp_flash_id() {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
esp_flash_id_obj
,
esp_flash_id
);
STATIC
mp_obj_t
esp_flash_read
(
mp_obj_t
offset_in
,
mp_obj_t
len_in
)
{
mp_int_t
offset
=
mp_obj_get_int
(
offset_in
);
mp_int_t
len
=
mp_obj_get_int
(
len_in
);
byte
*
buf
=
m_new
(
byte
,
len
);
// We know that allocation will be 4-byte aligned for sure
SpiFlashOpResult
res
=
spi_flash_read
(
offset
,
(
uint32_t
*
)
buf
,
len
);
if
(
res
==
SPI_FLASH_RESULT_OK
)
{
return
mp_obj_new_bytes
(
buf
,
len
);
}
m_del
(
byte
,
buf
,
len
);
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
res
==
SPI_FLASH_RESULT_TIMEOUT
?
ETIMEDOUT
:
EIO
)));
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_3
(
esp_flash_read_obj
,
esp_flash_read
);
STATIC
const
mp_map_elem_t
esp_module_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_esp
)
},
...
...
@@ -579,6 +594,7 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_sleep_type
),
(
mp_obj_t
)
&
esp_sleep_type_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_deepsleep
),
(
mp_obj_t
)
&
esp_deepsleep_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_flash_id
),
(
mp_obj_t
)
&
esp_flash_id_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_flash_read
),
(
mp_obj_t
)
&
esp_flash_read_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_socket
),
(
mp_obj_t
)
&
esp_socket_type
},
#if MODESP_INCLUDE_CONSTANTS
...
...
esp8266/qstrdefsport.h
View file @
90202b4c
...
...
@@ -64,6 +64,7 @@ Q(adc)
Q
(
vdd33
)
Q
(
chip_id
)
Q
(
flash_id
)
Q
(
flash_read
)
Q
(
sdk_version
)
Q
(
mac
)
Q
(
getaddrinfo
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment