Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
751485fe
Commit
751485fe
authored
Aug 03, 2015
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stmhal: Add support for USART1 and conditional pins in make-pins.py.
Thanks to Dave Hylands for the patch.
parent
a6320378
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
stmhal/Makefile
stmhal/Makefile
+4
-0
stmhal/boards/make-pins.py
stmhal/boards/make-pins.py
+13
-10
stmhal/uart.c
stmhal/uart.c
+16
-0
No files found.
stmhal/Makefile
View file @
751485fe
...
...
@@ -310,6 +310,10 @@ GEN_CDCINF_HEADER = $(HEADER_BUILD)/pybcdc_inf.h
# which source files might need it.
$(OBJ)
:
| $(HEADER_BUILD)/pins.h
# With conditional pins, we may need to regenerate qstrdefs.h when config
# options change.
$(HEADER_BUILD)/qstrdefs.generated.h
:
boards/$(BOARD)/mpconfigboard.h
$(BUILD)/main.o
:
$(GEN_CDCINF_HEADER)
# Use a pattern rule here so that make will only call make-pins.py once to make
...
...
stmhal/boards/make-pins.py
View file @
751485fe
...
...
@@ -24,6 +24,7 @@ CONDITIONAL_VAR = {
'UART'
:
'MICROPY_HW_UART{num}_PORT'
,
'UART5'
:
'MICROPY_HW_UART5_TX_PORT'
,
'USART'
:
'MICROPY_HW_UART{num}_PORT'
,
'USART1'
:
'MICROPY_HW_UART1_TX_PORT'
,
}
def
parse_port_pin
(
name_str
):
...
...
@@ -55,20 +56,22 @@ def conditional_var(name_num):
# Try the specific instance first. For example, if name_num is UART4_RX
# then try UART4 first, and then try UART second.
name
,
num
=
split_name_num
(
name_num
)
var
=
None
var
=
[]
if
name
in
CONDITIONAL_VAR
:
var
.
append
(
CONDITIONAL_VAR
[
name
].
format
(
num
=
num
))
if
name_num
in
CONDITIONAL_VAR
:
var
=
CONDITIONAL_VAR
[
name_num
]
elif
name
in
CONDITIONAL_VAR
:
var
=
CONDITIONAL_VAR
[
name
]
if
var
:
return
var
.
format
(
num
=
num
)
var
.
append
(
CONDITIONAL_VAR
[
name_num
])
return
var
def
print_conditional_if
(
cond_var
,
file
=
None
):
if
cond_var
:
if
cond_var
.
find
(
'ENABLE'
)
>=
0
:
print
(
'#if defined({0}) && {0}'
.
format
(
cond_var
),
file
=
file
)
else
:
print
(
'#if defined({0})'
.
format
(
cond_var
),
file
=
file
)
cond_str
=
[]
for
var
in
cond_var
:
if
var
.
find
(
'ENABLE'
)
>=
0
:
cond_str
.
append
(
'(defined({0}) && {0})'
.
format
(
var
))
else
:
cond_str
.
append
(
'defined({0})'
.
format
(
var
))
print
(
'#if '
+
' || '
.
join
(
cond_str
),
file
=
file
)
def
print_conditional_endif
(
cond_var
,
file
=
None
):
if
cond_var
:
...
...
stmhal/uart.c
View file @
751485fe
...
...
@@ -132,6 +132,22 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
break
;
#endif
#if defined(MICROPY_HW_UART1_TX_PORT) && \
defined(MICROPY_HW_UART1_TX_PIN) && \
defined(MICROPY_HW_UART1_RX_PORT) && \
defined(MICROPY_HW_UART1_RX_PIN)
case
PYB_UART_1
:
UARTx
=
USART1
;
irqn
=
USART1_IRQn
;
GPIO_AF_UARTx
=
GPIO_AF7_USART1
;
GPIO_Port
=
MICROPY_HW_UART1_TX_PORT
;
GPIO_Pin
=
MICROPY_HW_UART1_TX_PIN
;
GPIO_Port2
=
MICROPY_HW_UART1_RX_PORT
;
GPIO_Pin2
=
MICROPY_HW_UART1_RX_PIN
;
__USART1_CLK_ENABLE
();
break
;
#endif
#if defined(MICROPY_HW_UART2_PORT) && defined(MICROPY_HW_UART2_PINS)
// USART2 is on PA2/PA3 (CTS,RTS,CK on PA0,PA1,PA4), PD5/PD6 (CK on PD7)
case
PYB_UART_2
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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