Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 42 additions & 64 deletions targets/TARGET_STM/TARGET_STM32G0/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,27 @@

#if defined (STM32G030xx) || defined (STM32G050xx)
#define UART_NUM (2)
#define USART_GROUP1_IRQn USART2_IRQn
#elif defined (STM32G031xx) || defined (STM32G041xx) || defined (STM32G051xx) || defined (STM32G061xx)
#define UART_NUM (3)
#define USART_GROUP1_IRQn USART2_IRQn
#define USART_GROUP2_IRQn LPUART1_IRQn
#elif defined (STM32G070xx)
#define UART_NUM (4)
#define USART3_IRQn USART3_4_IRQn
#define USART4_IRQn USART3_4_IRQn
#define USART_GROUP1_IRQn USART2_IRQn
#define USART_GROUP2_IRQn USART3_4_IRQn
#elif defined (STM32G071xx) || defined (STM32G081xx)
#define UART_NUM (5)
#define USART3_IRQn USART3_4_LPUART1_IRQn
#define USART4_IRQn USART3_4_LPUART1_IRQn
#define LPUART1_IRQn USART3_4_LPUART1_IRQn
#define USART_GROUP1_IRQn USART2_IRQn
#define USART_GROUP2_IRQn USART3_4_LPUART1_IRQn
#elif defined (STM32G0B0xx)
#define UART_NUM (6)
#define USART3_IRQn USART3_4_5_6_IRQn
#define USART4_IRQn USART3_4_5_6_IRQn
#define USART5_IRQn USART3_4_5_6_IRQn
#define USART6_IRQn USART3_4_5_6_IRQn
#define USART_GROUP1_IRQn USART2_IRQn
#define USART_GROUP2_IRQn USART3_4_5_6_IRQn
#elif defined (STM32G0B1xx) || defined (STM32G0C1xx)
#define UART_NUM (8)
#define USART2_IRQn USART2_LPUART2_IRQn
#define USART3_IRQn USART3_4_5_6_LPUART1_IRQn
#define USART4_IRQn USART3_4_5_6_LPUART1_IRQn
#define USART5_IRQn USART3_4_5_6_LPUART1_IRQn
#define USART6_IRQn USART3_4_5_6_LPUART1_IRQn
#define LPUART1_IRQn USART3_4_5_6_LPUART1_IRQn
#define LPUART2_IRQn USART2_LPUART2_IRQn
#define USART_GROUP1_IRQn USART2_LPUART2_IRQn
#define USART_GROUP2_IRQn USART3_4_5_6_LPUART1_IRQn
#endif

uint32_t serial_irq_ids[UART_NUM] = {0};
Expand Down Expand Up @@ -93,52 +88,35 @@ static void uart1_irq(void)
}
#endif

#if defined(USART2_BASE)
static void uart2_irq(void)
#if defined (USART_GROUP1_IRQn)
static void uart_group1_irq(void)
{
#if defined(USART2_BASE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has to be removed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it appeared to be missing an #endif, fixed in fe698ea

uart_irq(UART_2);
}
#endif
#if defined(LPUART2_BASE)
uart_irq(LPUART_2);
#endif
}

#if defined(USART3_BASE)
static void uart3_irq(void)
#if defined(USART_GROUP2_IRQn)
static void uart_group2_irq(void)
{
#if defined(USART3_BASE)
uart_irq(UART_3);
}
#endif

#if defined(USART4_BASE)
static void uart4_irq(void)
{
uart_irq(UART_4);
}
#endif

#if defined(USART5_BASE)
static void uart5_irq(void)
{
uart_irq(UART_5);
}
#endif

#if defined(USART6_BASE)
static void uart6_irq(void)
{
uart_irq(UART_6);
}
#endif

#if defined(LPUART1_BASE)
static void lpuart1_irq(void)
{
uart_irq(LPUART_1);
}
#endif

#if defined(LPUART2_BASE)
static void lpuart2_irq(void)
{
uart_irq(LPUART_2);
}
#endif

Expand Down Expand Up @@ -166,50 +144,50 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)

#if defined(USART2_BASE)
if (obj_s->uart == UART_2) {
irq_n = USART2_IRQn;
vector = (uint32_t)&uart2_irq;
irq_n = USART_GROUP1_IRQn;
vector = (uint32_t)&uart_group1_irq;
}
#endif

#if defined(USART3_BASE)
if (obj_s->uart == UART_3) {
irq_n = USART3_IRQn;
vector = (uint32_t)&uart3_irq;
irq_n = USART_GROUP2_IRQn;
vector = (uint32_t)&uart_group2_irq;
}
#endif

#if defined(USART4_BASE)
if (obj_s->uart == UART_4) {
irq_n = USART4_IRQn;
vector = (uint32_t)&uart4_irq;
irq_n = USART_GROUP2_IRQn;
vector = (uint32_t)&uart_group2_irq;
}
#endif

#if defined(USART5_BASE)
if (obj_s->uart == UART_5) {
irq_n = USART5_IRQn;
vector = (uint32_t)&uart5_irq;
irq_n = USART_GROUP2_IRQn;
vector = (uint32_t)&uart_group2_irq;
}
#endif

#if defined(USART6_BASE)
if (obj_s->uart == UART_6) {
irq_n = USART6_IRQn;
vector = (uint32_t)&uart6_irq;
irq_n = USART_GROUP2_IRQn;
vector = (uint32_t)&uart_group2_irq;
}
#endif

#if defined(LPUART1_BASE)
if (obj_s->uart == LPUART_1) {
irq_n = LPUART1_IRQn;
vector = (uint32_t)&lpuart1_irq;
irq_n = USART_GROUP2_IRQn;
vector = (uint32_t)&uart_group2_irq;
}
#endif

#if defined(LPUART2_BASE)
if (obj_s->uart == LPUART_2) {
irq_n = LPUART2_IRQn;
vector = (uint32_t)&lpuart2_irq;
irq_n = USART_GROUP1_IRQn;
vector = (uint32_t)&uart_group1_irq;
}
#endif

Expand Down Expand Up @@ -382,37 +360,37 @@ static IRQn_Type serial_get_irq_n(UARTName uart_name)
#endif
#if defined(USART2_BASE)
case UART_2:
irq_n = USART2_IRQn;
irq_n = USART_GROUP1_IRQn;
break;
#endif
#if defined(USART3_BASE)
case UART_3:
irq_n = USART3_IRQn;
irq_n = USART_GROUP2_IRQn;
break;
#endif
#if defined(USART4_BASE)
case UART_4:
irq_n = USART4_IRQn;
irq_n = USART_GROUP2_IRQn;
break;
#endif
#if defined(USART5_BASE)
case UART_5:
irq_n = USART5_IRQn;
irq_n = USART_GROUP2_IRQn;
break;
#endif
#if defined(USART6_BASE)
case UART_6:
irq_n = USART6_IRQn;
irq_n = USART_GROUP2_IRQn;
break;
#endif
#if defined(LPUART1_BASE)
case LPUART_1:
irq_n = LPUART1_IRQn;
irq_n = USART_GROUP2_IRQn;
break;
#endif
#if defined(LPUART2_BASE)
case LPUART_2:
irq_n = LPUART2_IRQn;
irq_n = USART_GROUP1_IRQn;
break;
#endif
default:
Expand Down
16 changes: 7 additions & 9 deletions targets/TARGET_STM/TARGET_STM32L0/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,15 @@ static void uart2_irq(void)
}
#endif

#if defined(USART4_BASE)
static void uart4_irq(void)
#if defined(USART4_BASE) || defined(USART5_BASE)
static void uart4_5_irq(void)
{
#if defined(USART4_BASE)
uart_irq(UART_4);
}
#endif

#if defined(USART5_BASE)
static void uart5_irq(void)
{
#if defined(USART4_BASE)
uart_irq(UART_5);
#endif
}
#endif

Expand Down Expand Up @@ -132,14 +130,14 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
#if defined(USART4_BASE)
if (obj_s->uart == UART_4) {
irq_n = USART4_5_IRQn;
vector = (uint32_t)&uart4_irq;
vector = (uint32_t)&uart4_5_irq;
}
#endif

#if defined(USART5_BASE)
if (obj_s->uart == UART_5) {
irq_n = USART4_5_IRQn;
vector = (uint32_t)&uart5_irq;
vector = (uint32_t)&uart4_5_irq;
}
#endif

Expand Down