Skip to content
Snippets Groups Projects
Select Git revision
  • 3ae54c3c66a456c975ee5b27003e6d0e8a48a7e8
  • master default protected
  • sonopard/display-pixels-drawimage
  • TilCreator/firmware-master
  • rahix/simple_menu
  • genofire/leds_rgb_get_state
  • genofire/rockets-state
  • genofire/ble-follow-py
  • hauke/ble-cleanups
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • ios-workarounds
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
33 results

build_image

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    gccollect.c 1.27 KiB
    #include <stdio.h>
    
    #include "misc.h"
    #include "mpconfig.h"
    #include "qstr.h"
    #include "obj.h"
    #include "gc.h"
    #include "gccollect.h"
    #include "systick.h"
    
    void gc_helper_get_regs_and_clean_stack(machine_uint_t *regs, machine_uint_t heap_end);
    
    void gc_collect(void) {
        uint32_t start = sys_tick_counter;
        gc_collect_start();
        gc_collect_root((void**)&_ram_start, ((uint32_t)&_heap_start - (uint32_t)&_ram_start) / sizeof(uint32_t));
        machine_uint_t regs[10];
        gc_helper_get_regs_and_clean_stack(regs, (machine_uint_t)&_heap_end);
        gc_collect_root((void**)&_heap_end, ((uint32_t)&_ram_end - (uint32_t)&_heap_end) / sizeof(uint32_t)); // will trace regs since they now live in this function on the stack
        gc_collect_end();
        uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly
    
        if (0) {
            // print GC info
            gc_info_t info;
            gc_info(&info);
            printf("GC@%lu %lums\n", start, ticks);
            printf(" %lu total\n", info.total);
            printf(" %lu : %lu\n", info.used, info.free);
            printf(" 1=%lu 2=%lu m=%lu\n", info.num_1block, info.num_2block, info.max_block);
        }
    }
    
    static mp_obj_t pyb_gc(void) {
        gc_collect();
        return mp_const_none;
    }
    
    MP_DEFINE_CONST_FUN_OBJ_0(pyb_gc_obj, pyb_gc);