Skip to content

Commit bfb77d0

Browse files
committed
move ULPArch to Architecture
1 parent 2bb1229 commit bfb77d0

File tree

10 files changed

+47
-40
lines changed

10 files changed

+47
-40
lines changed

ports/espressif/bindings/espulp/ULPArch.c renamed to ports/espressif/bindings/espulp/Architecture.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@
2626

2727
#include "py/enum.h"
2828

29-
#include "bindings/espulp/ULPArch.h"
29+
#include "bindings/espulp/Architecture.h"
3030

31-
MAKE_ENUM_VALUE(espulp_ulparch_type, ulparch, FSM, FSM);
32-
MAKE_ENUM_VALUE(espulp_ulparch_type, ulparch, RISCV, RISCV);
31+
MAKE_ENUM_VALUE(espulp_architecture_type, architecture, FSM, FSM);
32+
MAKE_ENUM_VALUE(espulp_architecture_type, architecture, RISCV, RISCV);
3333

34-
//| class ULPArch:
34+
//| class Architecture:
3535
//| """The ULP architectures available."""
3636
//|
37-
//| FSM: ULPArch
37+
//| FSM: Architecture
3838
//| """The ULP Finite State Machine."""
3939
//|
40-
//| RISCV: ULPArch
40+
//| RISCV: Architecture
4141
//| """The ULP RISC-V Coprocessor."""
4242
//|
43-
MAKE_ENUM_MAP(espulp_ulparch) {
44-
MAKE_ENUM_MAP_ENTRY(ulparch, FSM),
45-
MAKE_ENUM_MAP_ENTRY(ulparch, RISCV),
43+
MAKE_ENUM_MAP(espulp_architecture) {
44+
MAKE_ENUM_MAP_ENTRY(architecture, FSM),
45+
MAKE_ENUM_MAP_ENTRY(architecture, RISCV),
4646
};
47-
STATIC MP_DEFINE_CONST_DICT(espulp_ulparch_locals_dict, espulp_ulparch_locals_table);
47+
STATIC MP_DEFINE_CONST_DICT(espulp_architecture_locals_dict, espulp_architecture_locals_table);
4848

49-
MAKE_PRINTER(espulp, espulp_ulparch);
49+
MAKE_PRINTER(espulp, espulp_architecture);
5050

51-
MAKE_ENUM_TYPE(espulp, ULPArch, espulp_ulparch);
51+
MAKE_ENUM_TYPE(espulp, Architecture, espulp_architecture);

ports/espressif/bindings/espulp/ULPArch.h renamed to ports/espressif/bindings/espulp/Architecture.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#ifndef MICROPY_INCLUDED_BINDINGS_ESPULP_ULPARCH_H
28-
#define MICROPY_INCLUDED_BINDINGS_ESPULP_ULPARCH_H
27+
#ifndef MICROPY_INCLUDED_BINDINGS_ESPULP_ARCHITECTURE_H
28+
#define MICROPY_INCLUDED_BINDINGS_ESPULP_ARCHITECTURE_H
2929

3030
#include "py/enum.h"
3131

3232
typedef enum {
3333
FSM,
3434
RISCV
35-
} espulp_ulparch_t;
35+
} espulp_architecture_t;
3636

37-
extern const mp_obj_type_t espulp_ulparch_type;
38-
extern const cp_enum_obj_t ulparch_FSM_obj;
37+
extern const mp_obj_type_t espulp_architecture_type;
38+
extern const cp_enum_obj_t architecture_FSM_obj;
3939

40-
#endif // MICROPY_INCLUDED_BINDINGS_ESPULP_ULPARCH_H
40+
#endif // MICROPY_INCLUDED_BINDINGS_ESPULP_ARCHITECTURE_H

ports/espressif/bindings/espulp/ULP.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@
3333
#include "py/objproperty.h"
3434

3535
//| class ULP:
36-
//| def __init__(self, arch: ULPArch = ULPArch.FSM):
36+
//| def __init__(self, arch: Architecture = Architecture.FSM):
3737
//| """The ultra-low-power processor.
3838
//|
3939
//| Raises an exception if another ULP has been instantiated. This
4040
//| ensures that is is only used by one piece of code at a time.
4141
//|
42-
//| :param ULPArch arch: The ulp arch"""
42+
//| :param Architecture arch: The ulp arch"""
4343
//| ...
4444
STATIC mp_obj_t espulp_ulp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
4545
enum { ARG_arch };
4646
static const mp_arg_t allowed_args[] = {
47-
{ MP_QSTR_arch, MP_ARG_OBJ, {.u_obj = (void *)&ulparch_FSM_obj} },
47+
{ MP_QSTR_arch, MP_ARG_OBJ, {.u_obj = (void *)&architecture_FSM_obj} },
4848
};
4949

5050
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
5151
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
5252

53-
const espulp_ulparch_t arch = cp_enum_value(&espulp_ulparch_type, args[ARG_arch].u_obj, MP_QSTR_arch);
53+
const espulp_architecture_t arch = cp_enum_value(&espulp_architecture_type, args[ARG_arch].u_obj, MP_QSTR_arch);
5454

5555
espulp_ulp_obj_t *self = m_new_obj(espulp_ulp_obj_t);
5656
self->base.type = &espulp_ulp_type;
@@ -149,27 +149,27 @@ STATIC mp_obj_t espulp_ulp_halt(mp_obj_t self_in) {
149149
}
150150
STATIC MP_DEFINE_CONST_FUN_OBJ_1(espulp_ulp_halt_obj, espulp_ulp_halt);
151151

152-
//| arch: ULPArch
153-
//| """The ulp arch. (read-only)"""
152+
//| arch: Architecture
153+
//| """The ulp architecture. (read-only)"""
154154
//|
155155
STATIC mp_obj_t espulp_ulp_get_arch(mp_obj_t self_in) {
156156
espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(self_in);
157157
check_for_deinit(self);
158158

159-
return cp_enum_find(&espulp_ulparch_type, self->arch);
159+
return cp_enum_find(&espulp_architecture_type, self->arch);
160160
}
161161
MP_DEFINE_CONST_FUN_OBJ_1(espulp_ulp_get_arch_obj, espulp_ulp_get_arch);
162162

163163
MP_PROPERTY_GETTER(espulp_ulp_arch_obj,
164164
(mp_obj_t)&espulp_ulp_get_arch_obj);
165165

166166
STATIC const mp_rom_map_elem_t espulp_ulp_locals_table[] = {
167-
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&espulp_ulp_deinit_obj) },
168-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
169-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espulp_ulp___exit___obj) },
170-
{ MP_ROM_QSTR(MP_QSTR_run), MP_ROM_PTR(&espulp_ulp_run_obj) },
171-
{ MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&espulp_ulp_halt_obj) },
172-
{ MP_ROM_QSTR(MP_QSTR_arch), MP_ROM_PTR(&espulp_ulp_arch_obj) },
167+
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&espulp_ulp_deinit_obj) },
168+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
169+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espulp_ulp___exit___obj) },
170+
{ MP_ROM_QSTR(MP_QSTR_run), MP_ROM_PTR(&espulp_ulp_run_obj) },
171+
{ MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&espulp_ulp_halt_obj) },
172+
{ MP_ROM_QSTR(MP_QSTR_arch), MP_ROM_PTR(&espulp_ulp_arch_obj) },
173173
};
174174
STATIC MP_DEFINE_CONST_DICT(espulp_ulp_locals_dict, espulp_ulp_locals_table);
175175

ports/espressif/bindings/espulp/ULP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
extern const mp_obj_type_t espulp_ulp_type;
3333

34-
void common_hal_espulp_ulp_construct(espulp_ulp_obj_t *self, espulp_ulparch_t arch);
34+
void common_hal_espulp_ulp_construct(espulp_ulp_obj_t *self, espulp_architecture_t arch);
3535
bool common_hal_espulp_ulp_deinited(espulp_ulp_obj_t *self);
3636
void common_hal_espulp_ulp_deinit(espulp_ulp_obj_t *self);
3737

ports/espressif/bindings/espulp/ULPAlarm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
*/
2626

2727
#include "bindings/espulp/ULPAlarm.h"
28-
#include "bindings/espulp/ULPArch.h"
2928

3029
#include "py/runtime.h"
30+
#include "py/objproperty.h"
3131

3232
//| class ULPAlarm:
3333
//| """Trigger an alarm when the ULP requests wake-up."""
@@ -52,7 +52,10 @@ STATIC mp_obj_t espulp_ulpalarm_make_new(const mp_obj_type_t *type, size_t n_arg
5252

5353
espulp_ulpalarm_obj_t *self = m_new_obj(espulp_ulpalarm_obj_t);
5454
self->base.type = &espulp_ulpalarm_type;
55-
self->ulp = mp_arg_validate_type(args[ARG_ulp].u_obj, &espulp_ulp_type, MP_QSTR_ulp);
55+
56+
espulp_ulp_obj_t *ulp = mp_arg_validate_type(args[ARG_ulp].u_obj, &espulp_ulp_type, MP_QSTR_ulp);
57+
58+
common_hal_espulp_ulpalarm_construct(self, ulp);
5659

5760
return MP_OBJ_FROM_PTR(self);
5861
}

ports/espressif/bindings/espulp/ULPAlarm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030

3131
extern const mp_obj_type_t espulp_ulpalarm_type;
3232

33-
void common_hal_espulp_ulpalarm_construct(espulp_ulpalarm_obj_t *self);
33+
void common_hal_espulp_ulpalarm_construct(espulp_ulpalarm_obj_t *self, espulp_ulp_obj_t *ulp);

ports/espressif/bindings/espulp/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "bindings/espulp/__init__.h"
3030
#include "bindings/espulp/ULP.h"
3131
#include "bindings/espulp/ULPAlarm.h"
32-
#include "bindings/espulp/ULPArch.h"
32+
#include "bindings/espulp/Architecture.h"
3333

3434
#include "py/runtime.h"
3535

@@ -82,7 +82,7 @@ STATIC const mp_rom_map_elem_t espulp_module_globals_table[] = {
8282
// module classes
8383
{ MP_ROM_QSTR(MP_QSTR_ULP), MP_OBJ_FROM_PTR(&espulp_ulp_type) },
8484
{ MP_ROM_QSTR(MP_QSTR_ULPAlarm), MP_OBJ_FROM_PTR(&espulp_ulpalarm_type) },
85-
{ MP_ROM_QSTR(MP_QSTR_ULPArch), MP_ROM_PTR(&espulp_ulparch_type) },
85+
{ MP_ROM_QSTR(MP_QSTR_Architecture), MP_ROM_PTR(&espulp_architecture_type) },
8686
};
8787
STATIC MP_DEFINE_CONST_DICT(espulp_module_globals, espulp_module_globals_table);
8888

ports/espressif/common-hal/espulp/ULP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void common_hal_espulp_ulp_halt(espulp_ulp_obj_t *self) {
133133
}
134134
}
135135

136-
void common_hal_espulp_ulp_construct(espulp_ulp_obj_t *self, espulp_ulparch_t arch) {
136+
void common_hal_espulp_ulp_construct(espulp_ulp_obj_t *self, espulp_architecture_t arch) {
137137
// Use a static variable to track ULP in use so that subsequent code runs can
138138
// use a running ULP. This is only to prevent multiple portions of user code
139139
// from using the ULP concurrently.

ports/espressif/common-hal/espulp/ULP.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
#pragma once
2828

2929
#include "py/obj.h"
30-
#include "bindings/espulp/ULPArch.h"
30+
#include "bindings/espulp/Architecture.h"
3131

3232
typedef struct {
3333
mp_obj_base_t base;
34-
espulp_ulparch_t arch;
34+
espulp_architecture_t arch;
3535
bool inited;
3636
} espulp_ulp_obj_t;

ports/espressif/common-hal/espulp/ULPAlarm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
static volatile bool woke_up = false;
3838
static bool alarm_set = false;
3939

40+
void common_hal_espulp_ulpalarm_construct(espulp_ulpalarm_obj_t *self, espulp_ulp_obj_t *ulp) {
41+
self->ulp = ulp;
42+
}
43+
4044
mp_obj_t espulp_ulpalarm_find_triggered_alarm(const size_t n_alarms, const mp_obj_t *alarms) {
4145
for (size_t i = 0; i < n_alarms; i++) {
4246
if (mp_obj_is_type(alarms[i], &espulp_ulpalarm_type)) {

0 commit comments

Comments
 (0)