Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
aae78475
Commit
aae78475
authored
Jan 03, 2014
by
Damien George
Browse files
Change old use of module creation to new proper use.
parent
28708626
Changes
6
Hide whitespace changes
Inline
Side-by-side
py/objclass.c
View file @
aae78475
...
...
@@ -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
));
}
stm/Makefile
View file @
aae78475
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
$@
$<
...
...
stm/audio.c
View file @
aae78475
...
...
@@ -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
));
...
...
stm/lcd.c
View file @
aae78475
...
...
@@ -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
));
...
...
stm/pybwlan.c
View file @
aae78475
...
...
@@ -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
));
...
...
stm/timer.c
View file @
aae78475
...
...
@@ -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
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment