RP UART IRQ support STM32-style.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14090 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-03-27 08:50:17 +00:00
parent d6c3fe0d46
commit fedede7989
7 changed files with 309 additions and 0 deletions

View File

@ -62,6 +62,14 @@
/* Derived constants and error checks. */
/*===========================================================================*/
#if RP_SIO_USE_UART0 && !RP_HAS_UART0
#error "UART0 not present in the selected device"
#endif
#if RP_SIO_USE_UART1 && !RP_HAS_UART1
#error "UART1 not present in the selected device"
#endif
#if !RP_SIO_USE_UART0 && !RP_SIO_USE_UART1
#error "SIO driver activated but no UART peripheral assigned"
#endif

View File

@ -0,0 +1,115 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file UARTv1/rp_uart0.inc
* @brief Shared UART0 handler.
*
* @addtogroup RP_UART0_HANDLER
* @{
*/
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/* Registry checks for robustness.*/
#if !defined(RP_HAS_UART0)
#error "RP_HAS_UART0 not defined in registry"
#endif
#if RP_HAS_UART0
/* Priority settings checks.*/
#if !defined(RP_IRQ_UART0_PRIORITY)
#error "RP_IRQ_UART0_PRIORITY not defined in mcuconf.h"
#endif
#if !OSAL_IRQ_IS_VALID_PRIORITY(RP_IRQ_UART0_PRIORITY)
#error "Invalid IRQ priority assigned to RP_IRQ_UART0_PRIORITY"
#endif
#endif /* RP_HAS_UART0 */
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
static inline void uart0_irq_init(void) {
#if defined(RP_UART0_IS_USED)
nvicEnableVector(RP_UART0_IRQ_NUMBER, RP_IRQ_UART0_PRIORITY);
#endif
}
static inline void uart0_irq_deinit(void) {
#if defined(RP_UART0_IS_USED)
nvicDisableVector(RP_UART0_IRQ_NUMBER);
#endif
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
#if defined(RP_UART0_IS_USED) || defined(__DOXYGEN__)
/**
* @brief UART0 interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(RP_UART0_IRQ_HANDLER) {
OSAL_IRQ_PROLOGUE();
#if HAL_USE_SERIAL
#if RP_SERIAL_USE_UART0
sd_lld_serve_interrupt(&SD1);
#endif
#endif
#if HAL_USE_SIO
#if RP_SIO_USE_UART0
sio_lld_serve_interrupt(&SIOD1);
#endif
#endif
#if HAL_USE_UART
#if RP_UART_USE_UART0
uart_lld_serve_interrupt(&UARTD1);
#endif
#endif
OSAL_IRQ_EPILOGUE();
}
#endif
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/** @} */

View File

@ -0,0 +1,115 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file UARTv1/rp_uart1.inc
* @brief Shared UART1 handler.
*
* @addtogroup RP_UART1_HANDLER
* @{
*/
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/* Registry checks for robustness.*/
#if !defined(RP_HAS_UART1)
#error "RP_HAS_UART1 not defined in registry"
#endif
#if RP_HAS_UART1
/* Priority settings checks.*/
#if !defined(RP_IRQ_UART1_PRIORITY)
#error "RP_IRQ_UART1_PRIORITY not defined in mcuconf.h"
#endif
#if !OSAL_IRQ_IS_VALID_PRIORITY(RP_IRQ_UART1_PRIORITY)
#error "Invalid IRQ priority assigned to RP_IRQ_UART1_PRIORITY"
#endif
#endif /* RP_HAS_UART1 */
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
static inline void uart1_irq_init(void) {
#if defined(RP_UART1_IS_USED)
nvicEnableVector(RP_UART1_IRQ_NUMBER, RP_IRQ_UART1_PRIORITY);
#endif
}
static inline void uart1_irq_deinit(void) {
#if defined(RP_UART1_IS_USED)
nvicDisableVector(RP_UART1_IRQ_NUMBER);
#endif
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
#if defined(RP_UART1_IS_USED) || defined(__DOXYGEN__)
/**
* @brief UART1 interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(RP_UART1_IRQ_HANDLER) {
OSAL_IRQ_PROLOGUE();
#if HAL_USE_SERIAL
#if RP_SERIAL_USE_UART1
sd_lld_serve_interrupt(&SD2);
#endif
#endif
#if HAL_USE_SIO
#if RP_SIO_USE_UART1
sio_lld_serve_interrupt(&SIOD2);
#endif
#endif
#if HAL_USE_UART
#if RP_UART_USE_UART1
uart_lld_serve_interrupt(&UARTD2);
#endif
#endif
OSAL_IRQ_EPILOGUE();
}
#endif
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/** @} */

View File

@ -123,6 +123,7 @@ typedef enum clock_index clock_index_t;
/* Various helpers.*/
#include "nvic.h"
#include "cache.h"
#include "rp_isr.h"
#ifdef __cplusplus
extern "C" {

View File

@ -44,6 +44,9 @@
/* Driver interrupt handlers. */
/*===========================================================================*/
#include "rp_uart0.inc"
#include "rp_uart1.inc"
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
@ -55,6 +58,8 @@
*/
void irqInit(void) {
uart0_irq_init();
uart1_irq_init();
}
/**
@ -64,6 +69,8 @@ void irqInit(void) {
*/
void irqDeinit(void) {
uart0_irq_deinit();
uart1_irq_deinit();
}
/** @} */

View File

@ -33,7 +33,59 @@
* @name ISR names and numbers
* @{
*/
#define RP_TIMER_IRQ0_HANDLER Vector40
#define RP_TIMER_IRQ1_HANDLER Vector44
#define RP_TIMER_IRQ2_HANDLER Vector48
#define RP_TIMER_IRQ3_HANDLER Vector4C
#define RP_PWM_IRQ_WRAP_HANDLER Vector50
#define RP_USBCTRL_IRQ_HANDLER Vector54
#define RP_XIP_IRQ_HANDLER Vector58
#define RP_PIO0_IRQ_0_HANDLER Vector5C
#define RP_PIO0_IRQ_1_HANDLER Vector60
#define RP_PIO1_IRQ_0_HANDLER Vector64
#define RP_PIO1_IRQ_1_HANDLER Vector68
#define RP_DMA_IRQ_0_HANDLER Vector6C
#define RP_DMA_IRQ_1_HANDLER Vector70
#define RP_IO_IRQ_BANK0_HANDLER Vector74
#define RP_IO_IRQ_QSPI_HANDLER Vector78
#define RP_SIO_IRQ_PROC0_HANDLER Vector7C
#define RP_SIO_IRQ_PROC1_HANDLER Vector80
#define RP_CLOCKS_IRQ_HANDLER Vector84
#define RP_SPI0_IRQ_HANDLER Vector88
#define RP_SPI1_IRQ_HANDLER Vector8C
#define RP_UART0_IRQ_HANDLER Vector90
#define RP_UART1_IRQ_HANDLER Vector94
#define RP_ADC_IRQ_FIFO_HANDLER Vector98
#define RP_I2C0_IRQ_HANDLER Vector9C
#define RP_I2C1_IRQ_HANDLER VectorA0
#define RP_RTC_IRQ_HANDLER VectorA4
#define RP_TIMER_IRQ0_NUMBER 0
#define RP_TIMER_IRQ1_NUMBER 1
#define RP_TIMER_IRQ2_NUMBER 2
#define RP_TIMER_IRQ3_NUMBER 3
#define RP_PWM_IRQ_WRAP_NUMBER 4
#define RP_USBCTRL_IRQ_NUMBER 5
#define RP_XIP_IRQ_NUMBER 6
#define RP_PIO0_IRQ_0_NUMBER 7
#define RP_PIO0_IRQ_1_NUMBER 8
#define RP_PIO1_IRQ_0_NUMBER 9
#define RP_PIO1_IRQ_1_NUMBER 10
#define RP_DMA_IRQ_0_NUMBER 11
#define RP_DMA_IRQ_1_NUMBER 12
#define RP_IO_IRQ_BANK0_NUMBER 13
#define RP_IO_IRQ_QSPI_NUMBER 14
#define RP_SIO_IRQ_PROC0_NUMBER 15
#define RP_SIO_IRQ_PROC1_NUMBER 16
#define RP_CLOCKS_IRQ_NUMBER 17
#define RP_SPI0_IRQ_NUMBER 18
#define RP_SPI1_IRQ_NUMBER 19
#define RP_UART0_IRQ_NUMBER 20
#define RP_UART1_IRQ_NUMBER 21
#define RP_ADC_IRQ_FIFO_NUMBER 22
#define RP_I2C0_IRQ_NUMBER 23
#define RP_I2C1_IRQ_NUMBER 24
#define RP_RTC_IRQ_NUMBER 25
/** @} */
/*===========================================================================*/

View File

@ -38,6 +38,17 @@
/* Common. */
/*===========================================================================*/
/*===========================================================================*/
/* RP2040. */
/*===========================================================================*/
/* UART attributes.*/
#define RP_HAS_UART0 TRUE
#define RP_HAS_UART1 TRUE
/* TIMER attributes.*/
#define RP_HAS_TIMER TRUE
/** @} */
#endif /* RP_REGISTRY_H */