30
30
31
31
#include "extmod/vfs.h"
32
32
#include "extmod/vfs_fat.h"
33
- #include "py/gc .h"
33
+ #include "py/misc .h"
34
34
#include "py/obj.h"
35
35
#include "py/runtime.h"
36
36
#include "lib/oofatfs/ff.h"
@@ -256,12 +256,12 @@ void spi_flash_init(void) {
256
256
if (spi_flash_is_initialised ) {
257
257
return ;
258
258
}
259
-
259
+
260
260
samd_peripherals_sercom_clock_init (SPI_FLASH_SERCOM , SPI_FLASH_SERCOM_INDEX );
261
261
262
262
// Set up with defaults, then change.
263
263
spi_m_sync_init (& spi_flash_desc , SPI_FLASH_SERCOM );
264
-
264
+
265
265
hri_sercomspi_write_CTRLA_DOPO_bf (SPI_FLASH_SERCOM , SPI_FLASH_DOPO );
266
266
hri_sercomspi_write_CTRLA_DIPO_bf (SPI_FLASH_SERCOM , SPI_FLASH_DIPO );
267
267
@@ -398,7 +398,7 @@ static bool flush_scratch_flash(void) {
398
398
static bool allocate_ram_cache (void ) {
399
399
uint8_t blocks_per_sector = SPI_FLASH_ERASE_SIZE / FILESYSTEM_BLOCK_SIZE ;
400
400
uint8_t pages_per_block = FILESYSTEM_BLOCK_SIZE / SPI_FLASH_PAGE_SIZE ;
401
- MP_STATE_VM (flash_ram_cache ) = gc_alloc (blocks_per_sector * pages_per_block * sizeof (uint32_t ), false);
401
+ MP_STATE_VM (flash_ram_cache ) = m_malloc_maybe (blocks_per_sector * pages_per_block * sizeof (uint32_t ), false);
402
402
if (MP_STATE_VM (flash_ram_cache ) == NULL ) {
403
403
return false;
404
404
}
@@ -409,7 +409,7 @@ static bool allocate_ram_cache(void) {
409
409
bool success = true;
410
410
for (i = 0 ; i < blocks_per_sector ; i ++ ) {
411
411
for (j = 0 ; j < pages_per_block ; j ++ ) {
412
- uint8_t * page_cache = gc_alloc (SPI_FLASH_PAGE_SIZE , false);
412
+ uint8_t * page_cache = m_malloc_maybe (SPI_FLASH_PAGE_SIZE , false);
413
413
if (page_cache == NULL ) {
414
414
success = false;
415
415
break ;
@@ -427,11 +427,11 @@ static bool allocate_ram_cache(void) {
427
427
i ++ ;
428
428
for (; i > 0 ; i -- ) {
429
429
for (; j > 0 ; j -- ) {
430
- gc_free (MP_STATE_VM (flash_ram_cache )[(i - 1 ) * pages_per_block + (j - 1 )]);
430
+ m_free (MP_STATE_VM (flash_ram_cache )[(i - 1 ) * pages_per_block + (j - 1 )]);
431
431
}
432
432
j = pages_per_block ;
433
433
}
434
- gc_free (MP_STATE_VM (flash_ram_cache ));
434
+ m_free (MP_STATE_VM (flash_ram_cache ));
435
435
MP_STATE_VM (flash_ram_cache ) = NULL ;
436
436
}
437
437
return success ;
@@ -474,13 +474,13 @@ static bool flush_ram_cache(bool keep_cache) {
474
474
MP_STATE_VM (flash_ram_cache )[i * pages_per_block + j ],
475
475
SPI_FLASH_PAGE_SIZE );
476
476
if (!keep_cache ) {
477
- gc_free (MP_STATE_VM (flash_ram_cache )[i * pages_per_block + j ]);
477
+ m_free (MP_STATE_VM (flash_ram_cache )[i * pages_per_block + j ]);
478
478
}
479
479
}
480
480
}
481
481
// We're done with the cache for now so give it back.
482
482
if (!keep_cache ) {
483
- gc_free (MP_STATE_VM (flash_ram_cache ));
483
+ m_free (MP_STATE_VM (flash_ram_cache ));
484
484
MP_STATE_VM (flash_ram_cache ) = NULL ;
485
485
}
486
486
return true;
0 commit comments