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
3ac2d06b
Commit
3ac2d06b
authored
9 years ago
by
Dave Hylands
Committed by
Damien George
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Add support for UART5
I tested this on my CERB40 board and it seems to be working fine.
parent
18fda7b4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
stmhal/boards/CERB40/mpconfigboard.h
+4
-0
4 additions, 0 deletions
stmhal/boards/CERB40/mpconfigboard.h
stmhal/stm32f4xx_it.c
+4
-0
4 additions, 0 deletions
stmhal/stm32f4xx_it.c
stmhal/uart.c
+32
-0
32 additions, 0 deletions
stmhal/uart.c
with
40 additions
and
0 deletions
stmhal/boards/CERB40/mpconfigboard.h
+
4
−
0
View file @
3ac2d06b
...
...
@@ -38,6 +38,10 @@
#define MICROPY_HW_UART3_CTS (GPIO_PIN_11)
#define MICROPY_HW_UART4_PORT (GPIOA)
#define MICROPY_HW_UART4_PINS (GPIO_PIN_0 | GPIO_PIN_1)
#define MICROPY_HW_UART5_TX_PORT (GPIOC)
#define MICROPY_HW_UART5_TX_PIN (GPIO_PIN_12)
#define MICROPY_HW_UART5_RX_PORT (GPIOD)
#define MICROPY_HW_UART5_RX_PIN (GPIO_PIN_2)
#define MICROPY_HW_UART6_PORT (GPIOC)
#define MICROPY_HW_UART6_PINS (GPIO_PIN_6 | GPIO_PIN_7)
...
...
This diff is collapsed.
Click to expand it.
stmhal/stm32f4xx_it.c
+
4
−
0
View file @
3ac2d06b
...
...
@@ -413,6 +413,10 @@ void UART4_IRQHandler(void) {
uart_irq_handler
(
4
);
}
void
UART5_IRQHandler
(
void
)
{
uart_irq_handler
(
5
);
}
void
USART6_IRQHandler
(
void
)
{
uart_irq_handler
(
6
);
}
...
...
This diff is collapsed.
Click to expand it.
stmhal/uart.c
+
32
−
0
View file @
3ac2d06b
...
...
@@ -185,6 +185,31 @@ STATIC bool uart_init2(pyb_uart_obj_t *uart_obj) {
break
;
#endif
#if defined(UART5) && \
defined(MICROPY_HW_UART5_TX_PORT) && \
defined(MICROPY_HW_UART5_TX_PIN) && \
defined(MICROPY_HW_UART5_RX_PORT) && \
defined(MICROPY_HW_UART5_RX_PIN)
case
PYB_UART_5
:
UARTx
=
UART5
;
irqn
=
UART5_IRQn
;
GPIO_AF_UARTx
=
GPIO_AF8_UART5
;
GPIO_Port
=
MICROPY_HW_UART5_TX_PORT
;
GPIO_Pin
=
MICROPY_HW_UART5_TX_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
#if defined(MICROPY_HW_UART6_PORT) && defined(MICROPY_HW_UART6_PINS)
// USART6 is on PC6/PC7 (CK on PC8)
case
PYB_UART_6
:
...
...
@@ -596,6 +621,13 @@ STATIC mp_obj_t pyb_uart_deinit(mp_obj_t self_in) {
__UART4_RELEASE_RESET
();
__UART4_CLK_DISABLE
();
#endif
#if defined(UART5)
}
else
if
(
uart
->
Instance
==
UART5
)
{
HAL_NVIC_DisableIRQ
(
UART5_IRQn
);
__UART5_FORCE_RESET
();
__UART5_RELEASE_RESET
();
__UART5_CLK_DISABLE
();
#endif
}
else
if
(
uart
->
Instance
==
USART6
)
{
HAL_NVIC_DisableIRQ
(
USART6_IRQn
);
__USART6_FORCE_RESET
();
...
...
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