main.c 692 Bytes
Newer Older
Rahix's avatar
Rahix committed
1
2
3
4
#include "py/runtime.h"
#include "py/gc.h"
#include "lib/utils/pyexec.h"

5
6
#include "max32665.h"

Rahix's avatar
Rahix committed
7
static char* stack_top;
Rahix's avatar
Rahix committed
8
9
10
11
12
13
14
15
static char heap[4096];

int main(void)
{
	/* TODO: Replace this with a proper heap implementation */
	int stack_dummy;
	stack_top = (char*)&stack_dummy;

16
17
18
	/* TMR5 is used to notify on keyboard interrupt */
	NVIC_EnableIRQ(TMR5_IRQn);

Rahix's avatar
Rahix committed
19
20
21
22
23
24
25
26
27
28
29
30
31
	gc_init(heap, heap + sizeof(heap));

	mp_init();
	pyexec_friendly_repl();

	while (1) {
		;
	}
}

void gc_collect(void)
{
	/* TODO: Replace this with a proper heap implementation */
Rahix's avatar
Rahix committed
32
	void* dummy;
Rahix's avatar
Rahix committed
33
34

	gc_collect_start();
Rahix's avatar
Rahix committed
35
36
37
	gc_collect_root(
		&dummy,
		((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t));
Rahix's avatar
Rahix committed
38
39
	gc_collect_end();
}