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
3ac2d06b
Commit
3ac2d06b
authored
May 31, 2015
by
Dave Hylands
Committed by
Damien George
Jun 01, 2015
Browse files
stmhal: Add support for UART5
I tested this on my CERB40 board and it seems to be working fine.
parent
18fda7b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/boards/CERB40/mpconfigboard.h
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)
...
...
stmhal/stm32f4xx_it.c
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
);
}
...
...
stmhal/uart.c
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
();
...
...
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