samd/samd_flash: Remove obsolete printf's and return values instead.
Returning values is much more useful.
This commit is contained in:
parent
85fb8b8b02
commit
560170de02
@ -96,21 +96,17 @@ STATIC mp_obj_t eraseblock(uint32_t sector_in) {
|
||||
}
|
||||
|
||||
STATIC mp_obj_t samd_flash_version(void) {
|
||||
printf("Flash Driver Version: %lu\n", flash_get_version());
|
||||
return mp_const_none;
|
||||
return MP_OBJ_NEW_SMALL_INT(flash_get_version());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(samd_flash_version_obj, samd_flash_version);
|
||||
STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(samd_flash_version_static_obj, MP_ROM_PTR(&samd_flash_version_obj));
|
||||
|
||||
STATIC mp_obj_t samd_flash_size(void) {
|
||||
// ASF4 API calls
|
||||
mp_int_t PAGES = flash_get_total_pages(&flash_desc);
|
||||
mp_int_t PAGE_SIZE = flash_get_page_size(&flash_desc);
|
||||
printf("Flash Size: %u Bytes\n", PAGES * PAGE_SIZE);
|
||||
return mp_const_none;
|
||||
return MP_OBJ_NEW_SMALL_INT(PAGES * PAGE_SIZE);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(samd_flash_size_obj, samd_flash_size);
|
||||
STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(samd_flash_size_static_obj, MP_ROM_PTR(&samd_flash_size_obj));
|
||||
|
||||
STATIC mp_obj_t samd_flash_readblocks(size_t n_args, const mp_obj_t *args) {
|
||||
uint32_t offset = (mp_obj_get_int(args[1]) * BLOCK_SIZE) + samd_flash_obj.flash_base;
|
||||
@ -172,8 +168,8 @@ STATIC mp_obj_t samd_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(samd_flash_ioctl_obj, samd_flash_ioctl);
|
||||
|
||||
STATIC const mp_rom_map_elem_t samd_flash_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_flash_version), MP_ROM_PTR(&samd_flash_version_static_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_flash_size), MP_ROM_PTR(&samd_flash_size_static_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_flash_version), MP_ROM_PTR(&samd_flash_version_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_flash_size), MP_ROM_PTR(&samd_flash_size_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_flash_init), MP_ROM_PTR(&samd_flash_init_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&samd_flash_readblocks_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&samd_flash_writeblocks_obj) },
|
||||
|
Loading…
x
Reference in New Issue
Block a user