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
3d945559
Commit
3d945559
authored
Aug 10, 2014
by
Dave Hylands
Committed by
Damien George
Aug 24, 2014
Browse files
Added python script to map AF to a pin name
Added some functions to Pin class to query mode, pull, and af
parent
c668d51b
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/Makefile
View file @
3d945559
...
@@ -238,6 +238,7 @@ GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
...
@@ -238,6 +238,7 @@ GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR
=
$(HEADER_BUILD)
/pins.h
GEN_PINS_HDR
=
$(HEADER_BUILD)
/pins.h
GEN_PINS_QSTR
=
$(BUILD)
/pins_qstr.h
GEN_PINS_QSTR
=
$(BUILD)
/pins_qstr.h
GEN_PINS_AF_CONST
=
$(HEADER_BUILD)
/pins_af_const.h
GEN_PINS_AF_CONST
=
$(HEADER_BUILD)
/pins_af_const.h
GEN_PINS_AF_PY
=
$(BUILD)
/pins_af.py
INSERT_USB_IDS
=
../tools/insert-usb-ids.py
INSERT_USB_IDS
=
../tools/insert-usb-ids.py
FILE2H
=
../tools/file2h.py
FILE2H
=
../tools/file2h.py
...
@@ -260,7 +261,7 @@ $(BUILD)/main.o: $(GEN_CDCINF_HEADER)
...
@@ -260,7 +261,7 @@ $(BUILD)/main.o: $(GEN_CDCINF_HEADER)
# both pins_$(BOARD).c and pins.h
# both pins_$(BOARD).c and pins.h
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(BUILD)/%_qstr.h
:
boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(BUILD)/%_qstr.h
:
boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
$(ECHO)
"Create
$@
"
$(ECHO)
"Create
$@
"
$(Q)$(PYTHON)
$(MAKE_PINS)
--board
$(BOARD_PINS)
--af
$(AF_FILE)
--prefix
$(PREFIX_FILE)
--hdr
$(GEN_PINS_HDR)
--qstr
$(GEN_PINS_QSTR)
--af-const
$(GEN_PINS_AF_CONST)
>
$(GEN_PINS_SRC)
$(Q)$(PYTHON)
$(MAKE_PINS)
--board
$(BOARD_PINS)
--af
$(AF_FILE)
--prefix
$(PREFIX_FILE)
--hdr
$(GEN_PINS_HDR)
--qstr
$(GEN_PINS_QSTR)
--af-const
$(GEN_PINS_AF_CONST)
--af-py
$(GEN_PINS_AF_PY)
>
$(GEN_PINS_SRC)
$(BUILD)/pins_$(BOARD).o
:
$(BUILD)/pins_$(BOARD).c
$(BUILD)/pins_$(BOARD).o
:
$(BUILD)/pins_$(BOARD).c
$(
call
compile_c
)
$(
call
compile_c
)
...
...
stmhal/boards/make-pins.py
View file @
3d945559
...
@@ -315,6 +315,17 @@ class Pins(object):
...
@@ -315,6 +315,17 @@ class Pins(object):
print
(
' { %-*s %s },'
%
(
mux_name_width
+
26
,
key
,
val
),
print
(
' { %-*s %s },'
%
(
mux_name_width
+
26
,
key
,
val
),
file
=
af_const_file
)
file
=
af_const_file
)
def
print_af_py
(
self
,
af_py_filename
):
with
open
(
af_py_filename
,
'wt'
)
as
af_py_file
:
print
(
'PINS_AF = ('
,
file
=
af_py_file
);
for
named_pin
in
self
.
board_pins
:
print
(
" ('%s', "
%
named_pin
.
name
(),
end
=
''
,
file
=
af_py_file
)
for
af
in
named_pin
.
pin
().
alt_fn
:
if
af
.
is_supported
():
print
(
"(%d, '%s'), "
%
(
af
.
idx
,
af
.
af_str
),
end
=
''
,
file
=
af_py_file
)
print
(
'),'
,
file
=
af_py_file
)
print
(
')'
,
file
=
af_py_file
)
def
main
():
def
main
():
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
...
@@ -334,6 +345,12 @@ def main():
...
@@ -334,6 +345,12 @@ def main():
help
=
"Specifies header file for alternate function constants."
,
help
=
"Specifies header file for alternate function constants."
,
default
=
"build/pins_af_const.h"
default
=
"build/pins_af_const.h"
)
)
parser
.
add_argument
(
"--af-py"
,
dest
=
"af_py_filename"
,
help
=
"Specifies the filename for the python alternate function mappings."
,
default
=
"build/pins_af.py"
)
parser
.
add_argument
(
parser
.
add_argument
(
"-b"
,
"--board"
,
"-b"
,
"--board"
,
dest
=
"board_filename"
,
dest
=
"board_filename"
,
...
@@ -383,6 +400,7 @@ def main():
...
@@ -383,6 +400,7 @@ def main():
pins
.
print_header
(
args
.
hdr_filename
)
pins
.
print_header
(
args
.
hdr_filename
)
pins
.
print_qstr
(
args
.
qstr_filename
)
pins
.
print_qstr
(
args
.
qstr_filename
)
pins
.
print_af_hdr
(
args
.
af_const_filename
)
pins
.
print_af_hdr
(
args
.
af_const_filename
)
pins
.
print_af_py
(
args
.
af_py_filename
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
stmhal/pin.c
View file @
3d945559
...
@@ -508,6 +508,33 @@ STATIC mp_obj_t pin_gpio(mp_obj_t self_in) {
...
@@ -508,6 +508,33 @@ STATIC mp_obj_t pin_gpio(mp_obj_t self_in) {
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pin_gpio_obj
,
pin_gpio
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pin_gpio_obj
,
pin_gpio
);
/// \method mode()
/// Returns the currently configured mode of the pin. The integer returned
/// will match one of the allowed constants for the mode argument to the init
/// function.
STATIC
mp_obj_t
pin_mode
(
mp_obj_t
self_in
)
{
return
MP_OBJ_NEW_SMALL_INT
(
pin_get_mode
(
self_in
));
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pin_mode_obj
,
pin_mode
);
/// \method pull()
/// Returns the currently configured pull of the pin. The integer returned
/// will match one of the allowed constants for the pull argument to the init
/// function.
STATIC
mp_obj_t
pin_pull
(
mp_obj_t
self_in
)
{
return
MP_OBJ_NEW_SMALL_INT
(
pin_get_pull
(
self_in
));
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pin_pull_obj
,
pin_pull
);
/// \method af()
/// Returns the currently configured af of the pin. The integer returned
/// will match one of the allowed constants for the af argument to the init
/// function.
STATIC
mp_obj_t
pin_af
(
mp_obj_t
self_in
)
{
return
MP_OBJ_NEW_SMALL_INT
(
pin_get_af
(
self_in
));
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pin_af_obj
,
pin_af
);
STATIC
const
mp_map_elem_t
pin_locals_dict_table
[]
=
{
STATIC
const
mp_map_elem_t
pin_locals_dict_table
[]
=
{
// instance methods
// instance methods
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_init
),
(
mp_obj_t
)
&
pin_init_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_init
),
(
mp_obj_t
)
&
pin_init_obj
},
...
@@ -520,6 +547,9 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = {
...
@@ -520,6 +547,9 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_port
),
(
mp_obj_t
)
&
pin_port_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_port
),
(
mp_obj_t
)
&
pin_port_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_pin
),
(
mp_obj_t
)
&
pin_pin_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_pin
),
(
mp_obj_t
)
&
pin_pin_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_gpio
),
(
mp_obj_t
)
&
pin_gpio_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_gpio
),
(
mp_obj_t
)
&
pin_gpio_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_mode
),
(
mp_obj_t
)
&
pin_mode_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_pull
),
(
mp_obj_t
)
&
pin_pull_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_af
),
(
mp_obj_t
)
&
pin_af_obj
},
// class methods
// class methods
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_mapper
),
(
mp_obj_t
)
&
pin_mapper_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_mapper
),
(
mp_obj_t
)
&
pin_mapper_obj
},
...
...
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