diff --git a/py/objclass.c b/py/objclass.c index a4bde3f00..203923a72 100644 --- a/py/objclass.c +++ b/py/objclass.c @@ -77,9 +77,3 @@ mp_obj_t mp_obj_new_class(mp_map_t *class_locals) { o->locals = class_locals; return o; } - -// temporary way of making C modules -// hack: use class to mimic a module -mp_obj_t mp_module_new(void) { - return mp_obj_new_class(mp_map_new(MP_MAP_QSTR, 0)); -} diff --git a/stm/Makefile b/stm/Makefile index 174b14c3e..6868f85ba 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -1,4 +1,5 @@ STMSRC=lib +#STMOTGSRC=lib-otg FATFSSRC=fatfs CC3KSRC=cc3k PYSRC=../py @@ -10,6 +11,7 @@ CC = arm-none-eabi-gcc LD = arm-none-eabi-ld 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 CFLAGS = -I. -I$(PYSRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) +#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE LDFLAGS = --nostdlib -T stm32f405.ld SRC_C = \ @@ -122,6 +124,11 @@ SRC_STM = \ stm324x7i_eval.c \ stm324x7i_eval_sdio_sd.c \ +#SRC_STM_OTG = \ +# usb_hcd.c \ +# usb_hcd_int.c \ +# usb_otg.c \ + SRC_CC3K = \ cc3000_common.c \ evnt_handler.c \ @@ -135,6 +142,7 @@ SRC_CC3K = \ pybcc3k.c \ 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)) +#OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o)) all: $(BUILD) $(BUILD)/flash.dfu @@ -166,6 +174,9 @@ $(BUILD)/%.o: $(FATFSSRC)/%.c $(BUILD)/%.o: $(STMSRC)/%.c $(CC) $(CFLAGS) -c -o $@ $< +#$(BUILD)/%.o: $(STMOTGSRC)/%.c +# $(CC) $(CFLAGS) -c -o $@ $< + $(BUILD)/%.o: $(CC3KSRC)/%.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/stm/audio.c b/stm/audio.c index 62d2ff2f8..38e0012b4 100644 --- a/stm/audio.c +++ b/stm/audio.c @@ -91,7 +91,7 @@ void audio_init(void) { // enable interrupt // Python interface - mp_obj_t m = mp_module_new(); + mp_obj_t m = mp_obj_new_module(qstr_from_str_static("audio")); rt_store_attr(m, qstr_from_str_static("dac"), rt_make_function_1(pyb_audio_dac)); rt_store_attr(m, qstr_from_str_static("is_full"), rt_make_function_0(pyb_audio_is_full)); rt_store_attr(m, qstr_from_str_static("fill"), rt_make_function_1(pyb_audio_fill)); diff --git a/stm/lcd.c b/stm/lcd.c index cec5bf548..9f5a157d0 100644 --- a/stm/lcd.c +++ b/stm/lcd.c @@ -220,7 +220,7 @@ void lcd_init(void) { lcd_next_line = 0; // Python interface - mp_obj_t m = mp_module_new(); + mp_obj_t m = mp_obj_new_module(qstr_from_str_static("lcd")); rt_store_attr(m, qstr_from_str_static("lcd8"), rt_make_function_2(lcd_draw_pixel_8)); rt_store_attr(m, qstr_from_str_static("clear"), rt_make_function_0(lcd_pix_clear)); rt_store_attr(m, qstr_from_str_static("get"), rt_make_function_2(lcd_pix_get)); diff --git a/stm/pybwlan.c b/stm/pybwlan.c index 73aa8273f..6341d0676 100644 --- a/stm/pybwlan.c +++ b/stm/pybwlan.c @@ -20,6 +20,7 @@ #include "parse.h" #include "compile.h" #include "obj.h" +#include "map.h" #include "runtime.h" #include "cc3k/ccspi.h" @@ -74,7 +75,7 @@ mp_obj_t pyb_wlan_get_ip(void) { return mp_const_none; } - mp_obj_t data = mp_module_new(); // TODO should really be a class + mp_obj_t data = mp_obj_new_class(mp_map_new(MP_MAP_QSTR, 0)); // TODO should this be an instance of a class? decode_addr_and_store(data, qstr_from_str_static("ip"), &ipconfig.aucIP[0], 4); decode_addr_and_store(data, qstr_from_str_static("subnet"), &ipconfig.aucSubnetMask[0], 4); decode_addr_and_store(data, qstr_from_str_static("gateway"), &ipconfig.aucDefaultGateway[0], 4); @@ -345,7 +346,7 @@ void pyb_wlan_init(void) { SpiInit(); wlan_init(CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); - mp_obj_t m = mp_module_new(); + mp_obj_t m = mp_obj_new_module(qstr_from_str_static("wlan")); rt_store_attr(m, qstr_from_str_static("connect"), rt_make_function_var(0, pyb_wlan_connect)); rt_store_attr(m, qstr_from_str_static("disconnect"), rt_make_function_0(pyb_wlan_disconnect)); rt_store_attr(m, qstr_from_str_static("ip"), rt_make_function_0(pyb_wlan_get_ip)); diff --git a/stm/timer.c b/stm/timer.c index 2236bbce4..28148b0c1 100644 --- a/stm/timer.c +++ b/stm/timer.c @@ -72,7 +72,7 @@ void timer_init(void) { TIM_Cmd(TIM6, ENABLE); // Python interface - mp_obj_t m = mp_module_new(); + mp_obj_t m = mp_obj_new_module(qstr_from_str_static("timer")); rt_store_attr(m, qstr_from_str_static("callback"), rt_make_function_1(timer_py_set_callback)); rt_store_attr(m, qstr_from_str_static("period"), rt_make_function_1(timer_py_set_period)); rt_store_attr(m, qstr_from_str_static("prescaler"), rt_make_function_1(timer_py_set_prescaler));