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
a6320378
Commit
a6320378
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Add better support for UART having Tx and Rx on different ports.
Thanks to Dave Hylands for the patch.
parent
c0e39864
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/uart.c
+11
-11
11 additions, 11 deletions
stmhal/uart.c
with
11 additions
and
11 deletions
stmhal/uart.c
+
11
−
11
View file @
a6320378
...
...
@@ -114,9 +114,10 @@ void uart_deinit(void) {
STATIC
bool
uart_init2
(
pyb_uart_obj_t
*
uart_obj
)
{
USART_TypeDef
*
UARTx
;
IRQn_Type
irqn
;
uint32_t
GPIO_Pin
;
uint32_t
GPIO_Pin
,
GPIO_Pin2
;
uint8_t
GPIO_AF_UARTx
=
0
;
GPIO_TypeDef
*
GPIO_Port
=
NULL
;
GPIO_TypeDef
*
GPIO_Port2
=
NULL
;
switch
(
uart_obj
->
uart_id
)
{
#if defined(MICROPY_HW_UART1_PORT) && defined(MICROPY_HW_UART1_PINS)
...
...
@@ -197,18 +198,10 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
irqn
=
UART5_IRQn
;
GPIO_AF_UARTx
=
GPIO_AF8_UART5
;
GPIO_Port
=
MICROPY_HW_UART5_TX_PORT
;
GPIO_Port2
=
MICROPY_HW_UART5_RX_PORT
;
GPIO_Pin
=
MICROPY_HW_UART5_TX_PIN
;
GPIO_Pin2
=
MICROPY_HW_UART5_RX_PIN
;
__UART5_CLK_ENABLE
();
// The code after the case only deals with the case where the TX & RX
// pins are on the same port. UART5 has them on different ports.
GPIO_InitTypeDef
GPIO_InitStructure
;
GPIO_InitStructure
.
Pin
=
MICROPY_HW_UART5_RX_PIN
;
GPIO_InitStructure
.
Speed
=
GPIO_SPEED_HIGH
;
GPIO_InitStructure
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStructure
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStructure
.
Alternate
=
GPIO_AF_UARTx
;
HAL_GPIO_Init
(
MICROPY_HW_UART5_RX_PORT
,
&
GPIO_InitStructure
);
break
;
#endif
...
...
@@ -242,6 +235,13 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
GPIO_InitStructure
.
Alternate
=
GPIO_AF_UARTx
;
HAL_GPIO_Init
(
GPIO_Port
,
&
GPIO_InitStructure
);
// init GPIO for second pin if needed
if
(
GPIO_Port2
!=
NULL
)
{
mp_hal_gpio_clock_enable
(
GPIO_Port2
);
GPIO_InitStructure
.
Pin
=
GPIO_Pin2
;
HAL_GPIO_Init
(
GPIO_Port2
,
&
GPIO_InitStructure
);
}
// init UARTx
HAL_UART_Init
(
&
uart_obj
->
uart
);
...
...
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