Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fleur
firmware
Commits
c5730693
Verified
Commit
c5730693
authored
Jul 06, 2019
by
Rahix
Browse files
feat(pycardium): Add proper stack implementation
This is the first part of #15. Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
e563593e
Changes
1
Hide whitespace changes
Inline
Side-by-side
pycardium/main.c
View file @
c5730693
#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
*
stack_top
;
static
char
heap
[
4096
];
extern
int
__StackTop
,
__StackLimit
;
int
main
(
void
)
{
/* TODO: Replace this with a proper heap implementation */
int
stack_dummy
;
stack_top
=
(
char
*
)
&
stack_dummy
;
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
);
...
...
@@ -27,13 +31,12 @@ int main(void)
void
gc_collect
(
void
)
{
/* TODO: Replace this with a proper heap implementation */
void
*
dummy
;
void
*
sp
=
(
void
*
)
__get_MSP
();
gc_collect_start
();
gc_collect_root
(
&
dummy
,
((
mp_uint_t
)
s
tack
_t
op
-
(
mp_uint_t
)
&
dummy
)
/
sizeof
(
mp_uint_t
)
sp
,
((
mp_uint_t
)
&
__S
tack
T
op
-
(
mp_uint_t
)
sp
)
/
sizeof
(
mp_uint_t
)
);
gc_collect_end
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment