Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
3bbceeaa
Commit
3bbceeaa
authored
11 years ago
by
Dave Hylands
Browse files
Options
Downloads
Patches
Plain Diff
Fix make-pins.py to support having multiple names for a pin.
SW and X17 now both map to PB3
parent
88d7bba9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stmhal/boards/make-pins.py
+47
-28
47 additions, 28 deletions
stmhal/boards/make-pins.py
with
47 additions
and
28 deletions
stmhal/boards/make-pins.py
+
47
−
28
View file @
3bbceeaa
...
...
@@ -92,17 +92,23 @@ class Pin(object):
self
.
port
=
port
self
.
pin
=
pin
self
.
alt_fn
=
[]
self
.
board_name
=
None
self
.
alt_fn_count
=
0
self
.
adc_num
=
0
self
.
adc_channel
=
0
self
.
board_pin
=
False
def
port_letter
(
self
):
return
chr
(
self
.
port
+
ord
(
'
A
'
))
def
pin_name
(
self
):
def
cpu_
pin_name
(
self
):
return
'
{:s}{:d}
'
.
format
(
self
.
port_letter
(),
self
.
pin
)
def
is_board_pin
(
self
):
return
self
.
board_pin
def
set_is_board_pin
(
self
):
self
.
board_pin
=
True
def
parse_adc
(
self
,
adc_str
):
if
(
adc_str
[:
3
]
!=
'
ADC
'
):
return
...
...
@@ -127,7 +133,7 @@ class Pin(object):
def
alt_fn_name
(
self
,
null_if_0
=
False
):
if
null_if_0
and
self
.
alt_fn_count
==
0
:
return
'
NULL
'
return
'
pin_{:s}_af
'
.
format
(
self
.
pin_name
())
return
'
pin_{:s}_af
'
.
format
(
self
.
cpu_
pin_name
())
def
adc_num_str
(
self
):
str
=
''
...
...
@@ -152,27 +158,40 @@ class Pin(object):
print
(
'
};
'
)
print
(
''
)
print
(
'
const pin_obj_t pin_{:s} = PIN({:s}, {:d}, {:d}, {:s}, {:s}, {:d});
'
.
format
(
self
.
pin_name
(),
self
.
port_letter
(),
self
.
pin
,
self
.
cpu_
pin_name
(),
self
.
port_letter
(),
self
.
pin
,
self
.
alt_fn_count
,
self
.
alt_fn_name
(
null_if_0
=
True
),
self
.
adc_num_str
(),
self
.
adc_channel
))
print
(
''
)
def
print_header
(
self
,
hdr_file
):
hdr_file
.
write
(
'
extern const pin_obj_t pin_{:s};
\n
'
.
format
(
self
.
pin_name
()))
format
(
self
.
cpu_
pin_name
()))
if
self
.
alt_fn_count
>
0
:
hdr_file
.
write
(
'
extern const pin_af_obj_t pin_{:s}_af[];
\n
'
.
format
(
self
.
pin_name
()))
format
(
self
.
cpu_pin_name
()))
class
NamedPin
(
object
):
def
__init__
(
self
,
name
,
pin
):
self
.
_name
=
name
self
.
_pin
=
pin
def
pin
(
self
):
return
self
.
_pin
def
name
(
self
):
return
self
.
_name
class
Pins
(
object
):
def
__init__
(
self
):
self
.
pins
=
[]
self
.
board_pins
=
[]
self
.
cpu_
pins
=
[]
# list of NamedPin objects
self
.
board_pins
=
[]
# list of NamedPin objects
def
find_pin
(
self
,
port_num
,
pin_num
):
for
pin
in
self
.
pins
:
for
named_pin
in
self
.
cpu_pins
:
pin
=
named_pin
.
pin
()
if
pin
.
port
==
port_num
and
pin
.
pin
==
pin_num
:
return
pin
...
...
@@ -190,7 +209,7 @@ class Pins(object):
pin
.
parse_af
(
af_idx
-
af_col
,
row
[
af_idx
])
elif
af_idx
==
af_col
+
16
:
pin
.
parse_adc
(
row
[
af_idx
])
self
.
pins
.
append
(
pin
)
self
.
cpu_
pins
.
append
(
NamedPin
(
pin
.
cpu_pin_name
(),
pin
)
)
def
parse_board_file
(
self
,
filename
):
with
open
(
filename
,
'
r
'
)
as
csvfile
:
...
...
@@ -202,26 +221,24 @@ class Pins(object):
continue
pin
=
self
.
find_pin
(
port_num
,
pin_num
)
if
pin
:
pin
.
board_name
=
row
[
0
]
self
.
board_pins
.
append
(
pin
)
pin
.
set_is_board_pin
()
self
.
board_pins
.
append
(
NamedPin
(
row
[
0
],
pin
)
)
def
print_named
(
self
,
label
,
pins
):
def
print_named
(
self
,
label
,
named_
pins
):
print
(
'
const pin_named_pin_t pin_{:s}_pins[] = {{
'
.
format
(
label
))
for
pin
in
pins
:
if
pin
.
board_name
:
if
label
==
'
board
'
:
pin_name
=
pin
.
board_name
else
:
pin_name
=
pin
.
pin_name
()
print
(
'
{{
"
{:s}
"
, &pin_{:s} }},
'
.
format
(
pin_name
,
pin
.
pin_name
()))
for
named_pin
in
named_pins
:
pin
=
named_pin
.
pin
()
if
pin
.
is_board_pin
():
print
(
'
{{
"
{:s}
"
, &pin_{:s} }},
'
.
format
(
named_pin
.
name
(),
pin
.
cpu_pin_name
()))
print
(
'
{ NULL, NULL }
'
)
print
(
'
};
'
)
def
print
(
self
):
for
pin
in
self
.
pins
:
if
pin
.
board_name
:
for
named_pin
in
self
.
cpu_pins
:
pin
=
named_pin
.
pin
()
if
pin
.
is_board_pin
():
pin
.
print
()
self
.
print_named
(
'
cpu
'
,
self
.
pins
)
self
.
print_named
(
'
cpu
'
,
self
.
cpu_
pins
)
print
(
''
)
self
.
print_named
(
'
board
'
,
self
.
board_pins
)
...
...
@@ -230,10 +247,11 @@ class Pins(object):
print
(
'
const pin_obj_t * const pin_adc{:d}[] = {{
'
.
format
(
adc_num
))
for
channel
in
range
(
16
):
adc_found
=
False
for
pin
in
self
.
pins
:
if
(
pin
.
board_name
and
for
named_pin
in
self
.
cpu_pins
:
pin
=
named_pin
.
pin
()
if
(
pin
.
is_board_pin
()
and
(
pin
.
adc_num
&
(
1
<<
(
adc_num
-
1
)))
and
(
pin
.
adc_channel
==
channel
)):
print
(
'
&pin_{:s}, // {:d}
'
.
format
(
pin
.
pin_name
(),
channel
))
print
(
'
&pin_{:s}, // {:d}
'
.
format
(
pin
.
cpu_
pin_name
(),
channel
))
adc_found
=
True
break
if
not
adc_found
:
...
...
@@ -243,8 +261,9 @@ class Pins(object):
def
print_header
(
self
,
hdr_filename
):
with
open
(
hdr_filename
,
'
wt
'
)
as
hdr_file
:
for
pin
in
self
.
pins
:
if
pin
.
board_name
:
for
named_pin
in
self
.
cpu_pins
:
pin
=
named_pin
.
pin
()
if
pin
.
is_board_pin
():
pin
.
print_header
(
hdr_file
)
hdr_file
.
write
(
'
extern const pin_obj_t * const pin_adc1[];
\n
'
)
hdr_file
.
write
(
'
extern const pin_obj_t * const pin_adc2[];
\n
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment