Skip to content

Commit 80f40c4

Browse files
committed
quectel: syntax fix.
1 parent 353296f commit 80f40c4

File tree

10 files changed

+385
-427
lines changed

10 files changed

+385
-427
lines changed

ports/quectel/gccollect.c

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,34 @@
3333
#include "gccollect.h"
3434

3535
#if defined(PLAT_RDA)
36-
unsigned int ReadSP(void)
37-
{
36+
unsigned int ReadSP(void) {
3837
uint32_t res;
3938
__asm volatile (
4039
"move %0, $29\n"
41-
:"=r"(res)
40+
: "=r" (res)
4241
:
4342
:
44-
);
45-
43+
);
44+
4645
return res;
4746
}
4847
#elif defined(PLAT_ECR6600)
4948

5049
#else
51-
unsigned int ReadSP(void)
52-
{
50+
unsigned int ReadSP(void) {
5351
uint32_t res;
5452
__asm volatile (
5553
"mov %0, r13\n"
56-
:"=r"(res)
54+
: "=r" (res)
5755
:
5856
:
59-
);
60-
57+
);
58+
6159
return res;
6260
}
6361
#endif
6462

65-
void gc_stacktop_set(void * ptr)
66-
{
63+
void gc_stacktop_set(void *ptr) {
6764
MP_STATE_PORT(global_stacktop_ptr) = ptr;
6865
}
6966

@@ -72,31 +69,26 @@ void gc_collect(void) {
7269
#if 0
7370
uint32_t start = mp_hal_ticks_us();
7471
#endif
75-
#if defined(PLAT_ECR6600)
76-
int val = 0;
77-
#endif
72+
#if defined(PLAT_ECR6600)
73+
int val = 0;
74+
#endif
7875
// start the GC
7976
gc_collect_start();
80-
#if defined(PLAT_ECR6600)
81-
uintptr_t sp = (uintptr_t)&val;
82-
#else
77+
#if defined(PLAT_ECR6600)
78+
uintptr_t sp = (uintptr_t)&val;
79+
#else
8380
// get the registers and the sp
8481
uintptr_t sp = (uintptr_t)ReadSP();
85-
#endif
86-
if(mp_is_python_thread())
87-
{
82+
#endif
83+
if (mp_is_python_thread()) {
8884
// trace the stack, including the registers (since they live on the stack in this function)
8985
gc_collect_root((void **)sp, ((uint32_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t));
90-
}
91-
else if(NULL != MP_STATE_PORT(global_stacktop_ptr))
92-
{
86+
} else if (NULL != MP_STATE_PORT(global_stacktop_ptr)) {
9387
gc_collect_root((void **)sp, ((uint32_t)MP_STATE_PORT(global_stacktop_ptr) - sp) / sizeof(uint32_t));
88+
} else {
89+
// do nothing
9490
}
95-
else
96-
{
97-
//do nothing
98-
}
99-
91+
10092
// trace root pointers from any threads
10193
#if MICROPY_PY_THREAD
10294
mp_thread_gc_others();
@@ -117,4 +109,4 @@ void gc_collect(void) {
117109
#endif
118110
}
119111

120-
MP_REGISTER_ROOT_POINTER(volatile void * global_stacktop_ptr);
112+
MP_REGISTER_ROOT_POINTER(volatile void *global_stacktop_ptr);

ports/quectel/gccollect.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
#ifndef __MICROPY_INCLUDED_QUECTEL_GCCOLLECT_H__
2828
#define __MICROPY_INCLUDED_QUECTEL_GCCOLLECT_H__
2929

30-
void gc_stacktop_set(void * ptr);
30+
void gc_stacktop_set(void *ptr);
3131
void gc_collect(void);
3232

33-
//Set a stack address as the end address of the GC collection
34-
//Do not add {} to the macro definition to prevent the scoping of stack_dummy from changing
35-
#define GC_STACKTOP_SET() int stack_dummy;gc_stacktop_set(&stack_dummy);
33+
// Set a stack address as the end address of the GC collection
34+
// Do not add {} to the macro definition to prevent the scoping of stack_dummy from changing
35+
#define GC_STACKTOP_SET() int stack_dummy; gc_stacktop_set(&stack_dummy);
3636

37-
//Clears the gc collection end stack pointer for global non-Python threads
37+
// Clears the gc collection end stack pointer for global non-Python threads
3838
#define GC_STACKTOP_CLEAR() gc_stacktop_set(NULL);
3939

4040
#endif
41-

0 commit comments

Comments
 (0)