Skip to content

Commit ceae0e1

Browse files
robert-hhdpgeorge
authored andcommitted
samd/samd_flash: Make flash read/write methods access self parameters.
Use `self` (the first argument) instead of the global `samd_flash_obj` when accessing the `flash_base` parameter. This allows there to be multiple flash objects for various types of filesystem. Signed-off-by: robert-hh <robert@hammelrath.com>
1 parent 4a159d1 commit ceae0e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ports/samd/samd_flash.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ static mp_obj_t samd_flash_version(void) {
103103
static MP_DEFINE_CONST_FUN_OBJ_0(samd_flash_version_obj, samd_flash_version);
104104

105105
static mp_obj_t samd_flash_readblocks(size_t n_args, const mp_obj_t *args) {
106-
uint32_t offset = (mp_obj_get_int(args[1]) * BLOCK_SIZE) + samd_flash_obj.flash_base;
106+
samd_flash_obj_t *self = MP_OBJ_TO_PTR(args[0]);
107+
uint32_t offset = (mp_obj_get_int(args[1]) * BLOCK_SIZE) + self->flash_base;
107108
mp_buffer_info_t bufinfo;
108109
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
109110
if (n_args == 4) {
@@ -118,7 +119,8 @@ static mp_obj_t samd_flash_readblocks(size_t n_args, const mp_obj_t *args) {
118119
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(samd_flash_readblocks_obj, 3, 4, samd_flash_readblocks);
119120

120121
static mp_obj_t samd_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
121-
uint32_t offset = (mp_obj_get_int(args[1]) * BLOCK_SIZE) + samd_flash_obj.flash_base;
122+
samd_flash_obj_t *self = MP_OBJ_TO_PTR(args[0]);
123+
uint32_t offset = (mp_obj_get_int(args[1]) * BLOCK_SIZE) + self->flash_base;
122124
mp_buffer_info_t bufinfo;
123125
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);
124126
if (n_args == 3) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy