Skip to content
Snippets Groups Projects
Commit aae78475 authored by Damien George's avatar Damien George
Browse files

Change old use of module creation to new proper use.

parent 28708626
Branches
No related tags found
No related merge requests found
...@@ -77,9 +77,3 @@ mp_obj_t mp_obj_new_class(mp_map_t *class_locals) { ...@@ -77,9 +77,3 @@ mp_obj_t mp_obj_new_class(mp_map_t *class_locals) {
o->locals = class_locals; o->locals = class_locals;
return o; 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));
}
STMSRC=lib STMSRC=lib
#STMOTGSRC=lib-otg
FATFSSRC=fatfs FATFSSRC=fatfs
CC3KSRC=cc3k CC3KSRC=cc3k
PYSRC=../py PYSRC=../py
...@@ -10,6 +11,7 @@ CC = arm-none-eabi-gcc ...@@ -10,6 +11,7 @@ CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld 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_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. -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 LDFLAGS = --nostdlib -T stm32f405.ld
SRC_C = \ SRC_C = \
...@@ -122,6 +124,11 @@ SRC_STM = \ ...@@ -122,6 +124,11 @@ SRC_STM = \
stm324x7i_eval.c \ stm324x7i_eval.c \
stm324x7i_eval_sdio_sd.c \ stm324x7i_eval_sdio_sd.c \
#SRC_STM_OTG = \
# usb_hcd.c \
# usb_hcd_int.c \
# usb_otg.c \
SRC_CC3K = \ SRC_CC3K = \
cc3000_common.c \ cc3000_common.c \
evnt_handler.c \ evnt_handler.c \
...@@ -135,6 +142,7 @@ SRC_CC3K = \ ...@@ -135,6 +142,7 @@ SRC_CC3K = \
pybcc3k.c \ 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_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 all: $(BUILD) $(BUILD)/flash.dfu
...@@ -166,6 +174,9 @@ $(BUILD)/%.o: $(FATFSSRC)/%.c ...@@ -166,6 +174,9 @@ $(BUILD)/%.o: $(FATFSSRC)/%.c
$(BUILD)/%.o: $(STMSRC)/%.c $(BUILD)/%.o: $(STMSRC)/%.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<
#$(BUILD)/%.o: $(STMOTGSRC)/%.c
# $(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(CC3KSRC)/%.c $(BUILD)/%.o: $(CC3KSRC)/%.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<
......
...@@ -91,7 +91,7 @@ void audio_init(void) { ...@@ -91,7 +91,7 @@ void audio_init(void) {
// enable interrupt // enable interrupt
// Python interface // 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("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("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)); rt_store_attr(m, qstr_from_str_static("fill"), rt_make_function_1(pyb_audio_fill));
......
...@@ -220,7 +220,7 @@ void lcd_init(void) { ...@@ -220,7 +220,7 @@ void lcd_init(void) {
lcd_next_line = 0; lcd_next_line = 0;
// Python interface // 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("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("clear"), rt_make_function_0(lcd_pix_clear));
rt_store_attr(m, qstr_from_str_static("get"), rt_make_function_2(lcd_pix_get)); rt_store_attr(m, qstr_from_str_static("get"), rt_make_function_2(lcd_pix_get));
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "parse.h" #include "parse.h"
#include "compile.h" #include "compile.h"
#include "obj.h" #include "obj.h"
#include "map.h"
#include "runtime.h" #include "runtime.h"
#include "cc3k/ccspi.h" #include "cc3k/ccspi.h"
...@@ -74,7 +75,7 @@ mp_obj_t pyb_wlan_get_ip(void) { ...@@ -74,7 +75,7 @@ mp_obj_t pyb_wlan_get_ip(void) {
return mp_const_none; 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("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("subnet"), &ipconfig.aucSubnetMask[0], 4);
decode_addr_and_store(data, qstr_from_str_static("gateway"), &ipconfig.aucDefaultGateway[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) { ...@@ -345,7 +346,7 @@ void pyb_wlan_init(void) {
SpiInit(); SpiInit();
wlan_init(CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); 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("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("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)); rt_store_attr(m, qstr_from_str_static("ip"), rt_make_function_0(pyb_wlan_get_ip));
......
...@@ -72,7 +72,7 @@ void timer_init(void) { ...@@ -72,7 +72,7 @@ void timer_init(void) {
TIM_Cmd(TIM6, ENABLE); TIM_Cmd(TIM6, ENABLE);
// Python interface // 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("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("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)); rt_store_attr(m, qstr_from_str_static("prescaler"), rt_make_function_1(timer_py_set_prescaler));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment