Skip to content

Commit aae7847

Browse files
committed
Change old use of module creation to new proper use.
1 parent 2870862 commit aae7847

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

py/objclass.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,3 @@ mp_obj_t mp_obj_new_class(mp_map_t *class_locals) {
7777
o->locals = class_locals;
7878
return o;
7979
}
80-
81-
// temporary way of making C modules
82-
// hack: use class to mimic a module
83-
mp_obj_t mp_module_new(void) {
84-
return mp_obj_new_class(mp_map_new(MP_MAP_QSTR, 0));
85-
}

stm/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
STMSRC=lib
2+
#STMOTGSRC=lib-otg
23
FATFSSRC=fatfs
34
CC3KSRC=cc3k
45
PYSRC=../py
@@ -10,6 +11,7 @@ CC = arm-none-eabi-gcc
1011
LD = arm-none-eabi-ld
1112
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion -DSTM32F40XX -DHSE_VALUE=8000000
1213
CFLAGS = -I. -I$(PYSRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4)
14+
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE
1315
LDFLAGS = --nostdlib -T stm32f405.ld
1416

1517
SRC_C = \
@@ -122,6 +124,11 @@ SRC_STM = \
122124
stm324x7i_eval.c \
123125
stm324x7i_eval_sdio_sd.c \
124126

127+
#SRC_STM_OTG = \
128+
# usb_hcd.c \
129+
# usb_hcd_int.c \
130+
# usb_otg.c \
131+
125132
SRC_CC3K = \
126133
cc3000_common.c \
127134
evnt_handler.c \
@@ -135,6 +142,7 @@ SRC_CC3K = \
135142
pybcc3k.c \
136143

137144
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o))
145+
#OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o))
138146

139147
all: $(BUILD) $(BUILD)/flash.dfu
140148

@@ -166,6 +174,9 @@ $(BUILD)/%.o: $(FATFSSRC)/%.c
166174
$(BUILD)/%.o: $(STMSRC)/%.c
167175
$(CC) $(CFLAGS) -c -o $@ $<
168176

177+
#$(BUILD)/%.o: $(STMOTGSRC)/%.c
178+
# $(CC) $(CFLAGS) -c -o $@ $<
179+
169180
$(BUILD)/%.o: $(CC3KSRC)/%.c
170181
$(CC) $(CFLAGS) -c -o $@ $<
171182

stm/audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void audio_init(void) {
9191
// enable interrupt
9292

9393
// Python interface
94-
mp_obj_t m = mp_module_new();
94+
mp_obj_t m = mp_obj_new_module(qstr_from_str_static("audio"));
9595
rt_store_attr(m, qstr_from_str_static("dac"), rt_make_function_1(pyb_audio_dac));
9696
rt_store_attr(m, qstr_from_str_static("is_full"), rt_make_function_0(pyb_audio_is_full));
9797
rt_store_attr(m, qstr_from_str_static("fill"), rt_make_function_1(pyb_audio_fill));

stm/lcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void lcd_init(void) {
220220
lcd_next_line = 0;
221221

222222
// Python interface
223-
mp_obj_t m = mp_module_new();
223+
mp_obj_t m = mp_obj_new_module(qstr_from_str_static("lcd"));
224224
rt_store_attr(m, qstr_from_str_static("lcd8"), rt_make_function_2(lcd_draw_pixel_8));
225225
rt_store_attr(m, qstr_from_str_static("clear"), rt_make_function_0(lcd_pix_clear));
226226
rt_store_attr(m, qstr_from_str_static("get"), rt_make_function_2(lcd_pix_get));

stm/pybwlan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "parse.h"
2121
#include "compile.h"
2222
#include "obj.h"
23+
#include "map.h"
2324
#include "runtime.h"
2425

2526
#include "cc3k/ccspi.h"
@@ -74,7 +75,7 @@ mp_obj_t pyb_wlan_get_ip(void) {
7475
return mp_const_none;
7576
}
7677

77-
mp_obj_t data = mp_module_new(); // TODO should really be a class
78+
mp_obj_t data = mp_obj_new_class(mp_map_new(MP_MAP_QSTR, 0)); // TODO should this be an instance of a class?
7879
decode_addr_and_store(data, qstr_from_str_static("ip"), &ipconfig.aucIP[0], 4);
7980
decode_addr_and_store(data, qstr_from_str_static("subnet"), &ipconfig.aucSubnetMask[0], 4);
8081
decode_addr_and_store(data, qstr_from_str_static("gateway"), &ipconfig.aucDefaultGateway[0], 4);
@@ -345,7 +346,7 @@ void pyb_wlan_init(void) {
345346
SpiInit();
346347
wlan_init(CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin);
347348

348-
mp_obj_t m = mp_module_new();
349+
mp_obj_t m = mp_obj_new_module(qstr_from_str_static("wlan"));
349350
rt_store_attr(m, qstr_from_str_static("connect"), rt_make_function_var(0, pyb_wlan_connect));
350351
rt_store_attr(m, qstr_from_str_static("disconnect"), rt_make_function_0(pyb_wlan_disconnect));
351352
rt_store_attr(m, qstr_from_str_static("ip"), rt_make_function_0(pyb_wlan_get_ip));

stm/timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void timer_init(void) {
7272
TIM_Cmd(TIM6, ENABLE);
7373

7474
// Python interface
75-
mp_obj_t m = mp_module_new();
75+
mp_obj_t m = mp_obj_new_module(qstr_from_str_static("timer"));
7676
rt_store_attr(m, qstr_from_str_static("callback"), rt_make_function_1(timer_py_set_callback));
7777
rt_store_attr(m, qstr_from_str_static("period"), rt_make_function_1(timer_py_set_period));
7878
rt_store_attr(m, qstr_from_str_static("prescaler"), rt_make_function_1(timer_py_set_prescaler));

0 commit comments

Comments
 (0)