mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
stm32: Add support for G0 MCUs.
This commit adds support for the STM32G0 series of MCUs. Signed-off-by: Asensio Lorenzo Sempere <asensio.aerospace@gmail.com>
This commit is contained in:
committed by
Damien George
parent
3587d8e808
commit
010012c7c3
@@ -76,10 +76,14 @@
|
||||
STATIC void pyb_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
pyb_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
if (!self->is_enabled) {
|
||||
#ifdef LPUART1
|
||||
#if defined(LPUART1)
|
||||
if (self->uart_id == PYB_LPUART_1) {
|
||||
mp_printf(print, "UART('LP1')");
|
||||
} else
|
||||
#elif defined(LPUART2)
|
||||
if (self->uart_id == PYB_LPUART_2) {
|
||||
mp_printf(print, "UART('LP2')");
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
mp_printf(print, "UART(%u)", self->uart_id);
|
||||
@@ -105,12 +109,18 @@ STATIC void pyb_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k
|
||||
if (cr1 & USART_CR1_PCE) {
|
||||
bits -= 1;
|
||||
}
|
||||
#ifdef LPUART1
|
||||
#if defined(LPUART1)
|
||||
if (self->uart_id == PYB_LPUART_1) {
|
||||
mp_printf(print, "UART('LP1', baudrate=%u, bits=%u, parity=",
|
||||
uart_get_baudrate(self), bits);
|
||||
} else
|
||||
#endif
|
||||
#if defined(LPUART2)
|
||||
if (self->uart_id == PYB_LPUART_2) {
|
||||
mp_printf(print, "UART('LP2', baudrate=%u, bits=%u, parity=",
|
||||
uart_get_baudrate(self), bits);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
mp_printf(print, "UART(%u, baudrate=%u, bits=%u, parity=",
|
||||
self->uart_id, uart_get_baudrate(self), bits);
|
||||
@@ -354,10 +364,18 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
|
||||
} else if (strcmp(port, MICROPY_HW_LPUART1_NAME) == 0) {
|
||||
uart_id = PYB_LPUART_1;
|
||||
#endif
|
||||
#ifdef MICROPY_HW_LPUART2_NAME
|
||||
} else if (strcmp(port, MICROPY_HW_LPUART2_NAME) == 0) {
|
||||
uart_id = PYB_LPUART_2;
|
||||
#endif
|
||||
#ifdef LPUART1
|
||||
} else if (strcmp(port, "LP1") == 0 && uart_exists(PYB_LPUART_1)) {
|
||||
uart_id = PYB_LPUART_1;
|
||||
#endif
|
||||
#ifdef LPUART2
|
||||
} else if (strcmp(port, "LP2") == 0 && uart_exists(PYB_LPUART_2)) {
|
||||
uart_id = PYB_LPUART_2;
|
||||
#endif
|
||||
} else {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART(%s) doesn't exist"), port);
|
||||
}
|
||||
@@ -459,7 +477,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_readchar_obj, pyb_uart_readchar);
|
||||
// uart.sendbreak()
|
||||
STATIC mp_obj_t pyb_uart_sendbreak(mp_obj_t self_in) {
|
||||
pyb_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
#if defined(STM32F0) || defined(STM32F7) || defined(STM32G4) || defined(STM32H7) || defined(STM32L0) || defined(STM32L4) || defined(STM32WB) || defined(STM32WL)
|
||||
#if defined(STM32F0) || defined(STM32F7) || defined(STM32G0) || defined(STM32G4) || defined(STM32H7) || defined(STM32L0) || defined(STM32L4) || defined(STM32WB) || defined(STM32WL)
|
||||
self->uartx->RQR = USART_RQR_SBKRQ; // write-only register
|
||||
#else
|
||||
self->uartx->CR1 |= USART_CR1_SBK;
|
||||
|
||||
Reference in New Issue
Block a user