Skip to content
Snippets Groups Projects
Select Git revision
  • c5730693c8689247b625bcc0b82ba4e9965ca876
  • master default protected
  • rectangle_fill_off_by_one
  • ble_dev_name
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • rahix/bma
  • rahix/bhi
  • schleicher-test
  • schneider/schleicher-test
  • freertos-btle
  • ch3/api-speed-eval2
  • schneider/mp-for-old-bl
  • ch3/leds-api
  • ch3/genapi-refactor
  • ch3/dual-core
  • dualcore
  • v0.0
22 results

main.c

Blame
  • Forked from card10 / firmware
    1699 commits behind the upstream repository.
    Rahix's avatar
    rahix authored
    This is the first part of #15.
    
    Signed-off-by: default avatarRahix <rahix@rahix.de>
    c5730693
    History
    main.c 700 B
    #include "py/runtime.h"
    #include "py/gc.h"
    #include "lib/utils/pyexec.h"
    #include "py/stackctrl.h"
    #include <stdio.h>
    
    #include "max32665.h"
    
    static char heap[4096];
    
    extern int __StackTop, __StackLimit;
    
    int main(void)
    {
    	if (0) {
    		mp_stack_set_top(&__StackTop);
    		mp_stack_set_limit((mp_int_t)&__StackLimit);
    	}
    
    	/* TMR5 is used to notify on keyboard interrupt */
    	NVIC_EnableIRQ(TMR5_IRQn);
    
    	while (1) {
    		gc_init(heap, heap + sizeof(heap));
    
    		mp_init();
    		pyexec_friendly_repl();
    		mp_deinit();
    	}
    }
    
    void gc_collect(void)
    {
    	void *sp = (void *)__get_MSP();
    
    	gc_collect_start();
    	gc_collect_root(
    		sp,
    		((mp_uint_t)&__StackTop - (mp_uint_t)sp) / sizeof(mp_uint_t)
    	);
    	gc_collect_end();
    }