From 75c309d20863f86b499708689bd62920c02cbb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Betto?= <niccolo.betto@skywarder.eu> Date: Fri, 1 Dec 2023 17:15:16 +0100 Subject: [PATCH] [USART] Update to Miosix 2.7 API This commit drops support for using more than 3 USART ports with our STM Serial Miosix wrapper. Our driver should be used in cases where more than 3 ports are needed. --- src/shared/drivers/usart/USART.cpp | 63 ++++++++++++++---------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/src/shared/drivers/usart/USART.cpp b/src/shared/drivers/usart/USART.cpp index 6f416be18..f5c787d6f 100644 --- a/src/shared/drivers/usart/USART.cpp +++ b/src/shared/drivers/usart/USART.cpp @@ -36,6 +36,11 @@ Boardcore::USART *ports[N_USART_PORTS]; #ifdef USART1 +/** + * \internal interrupt routine for usart1 miosix implementation + */ +void usart1irqImpl(); + /** * \internal Interrupt routine for usart1 actual implementation. */ @@ -43,12 +48,12 @@ void __attribute__((used)) usart1irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[0]; if (port_boardcore) + { port_boardcore->IRQhandleInterrupt(); + } else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[0]; - if (port) - port->IRQhandleInterrupt(); + usart1irqImpl(); } } @@ -64,6 +69,11 @@ void __attribute__((naked, used)) USART1_IRQHandler() #endif #ifdef USART2 +/** + * \internal interrupt routine for usart2 miosix implementation + */ +void usart2irqImpl(); + /** * \internal Interrupt routine for usart2 actual implementation. */ @@ -71,12 +81,12 @@ void __attribute__((used)) usart2irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[1]; if (port_boardcore) + { port_boardcore->IRQhandleInterrupt(); + } else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[1]; - if (port) - port->IRQhandleInterrupt(); + usart2irqImpl(); } } @@ -92,6 +102,11 @@ void __attribute__((naked, used)) USART2_IRQHandler() #endif #ifdef USART3 +/** + * \internal interrupt routine for usart3 miosix implementation + */ +void usart3irqImpl(); + /** * \internal Interrupt routine for usart3 actual implementation. */ @@ -99,12 +114,12 @@ void __attribute__((used)) usart3irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[2]; if (port_boardcore) + { port_boardcore->IRQhandleInterrupt(); + } else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[2]; - if (port) - port->IRQhandleInterrupt(); + usart3irqImpl(); } } @@ -127,12 +142,8 @@ void __attribute__((used)) uart4irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[3]; if (port_boardcore) - port_boardcore->IRQhandleInterrupt(); - else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[3]; - if (port) - port->IRQhandleInterrupt(); + port_boardcore->IRQhandleInterrupt(); } } @@ -155,12 +166,8 @@ void __attribute__((used)) uart5irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[4]; if (port_boardcore) - port_boardcore->IRQhandleInterrupt(); - else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[4]; - if (port) - port->IRQhandleInterrupt(); + port_boardcore->IRQhandleInterrupt(); } } @@ -183,12 +190,8 @@ void __attribute__((used)) usart6irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[5]; if (port_boardcore) - port_boardcore->IRQhandleInterrupt(); - else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[5]; - if (port) - port->IRQhandleInterrupt(); + port_boardcore->IRQhandleInterrupt(); } } @@ -211,12 +214,8 @@ void __attribute__((used)) uart7irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[6]; if (port_boardcore) - port_boardcore->IRQhandleInterrupt(); - else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[6]; - if (port) - port->IRQhandleInterrupt(); + port_boardcore->IRQhandleInterrupt(); } } @@ -239,12 +238,8 @@ void __attribute__((used)) uart8irqImplBoardcore() { Boardcore::USART *port_boardcore = ports[7]; if (port_boardcore) - port_boardcore->IRQhandleInterrupt(); - else { - miosix::STM32Serial *port = miosix::STM32Serial::ports[7]; - if (port) - port->IRQhandleInterrupt(); + port_boardcore->IRQhandleInterrupt(); } } -- GitLab