Added proper support for ChibiOS 4; added compile-time check that fails if IRQ vectors are not properly defined

This commit is contained in:
Pavel Kirienko 2017-01-23 04:09:00 +03:00
parent dcbb573972
commit f1fc72ef7a
3 changed files with 21 additions and 7 deletions

View File

@ -59,7 +59,7 @@
# ifndef UAVCAN_STM32_IRQ_PRIORITY_MASK
# if (CH_KERNEL_MAJOR == 2)
# define UAVCAN_STM32_IRQ_PRIORITY_MASK CORTEX_PRIORITY_MASK(CORTEX_MAX_KERNEL_PRIORITY)
# else // ChibiOS 3
# else // ChibiOS 3+
# define UAVCAN_STM32_IRQ_PRIORITY_MASK CORTEX_MAX_KERNEL_PRIORITY
# endif
# endif

View File

@ -34,7 +34,7 @@
# endif
#endif
#if (UAVCAN_STM32_CHIBIOS && CH_KERNEL_MAJOR == 3)
#if (UAVCAN_STM32_CHIBIOS && (CH_KERNEL_MAJOR == 3 || CH_KERNEL_MAJOR == 4))
#define CAN1_TX_IRQHandler STM32_CAN1_TX_HANDLER
#define CAN1_RX0_IRQHandler STM32_CAN1_RX0_HANDLER
#define CAN1_RX1_IRQHandler STM32_CAN1_RX1_HANDLER
@ -1084,7 +1084,15 @@ static int can2_irq(const int irq, void*)
}
# endif
#else // UAVCAN_STM32_NUTTX
#if !defined(CAN1_TX_IRQHandler) ||\
!defined(CAN1_RX0_IRQHandler) ||\
!defined(CAN1_RX1_IRQHandler)
# error "Misconfigured build"
#endif
UAVCAN_STM32_IRQ_HANDLER(CAN1_TX_IRQHandler);
UAVCAN_STM32_IRQ_HANDLER(CAN1_TX_IRQHandler)
{
@ -1111,6 +1119,12 @@ UAVCAN_STM32_IRQ_HANDLER(CAN1_RX1_IRQHandler)
# if UAVCAN_STM32_NUM_IFACES > 1
#if !defined(CAN2_TX_IRQHandler) ||\
!defined(CAN2_RX0_IRQHandler) ||\
!defined(CAN2_RX1_IRQHandler)
# error "Misconfigured build"
#endif
UAVCAN_STM32_IRQ_HANDLER(CAN2_TX_IRQHandler);
UAVCAN_STM32_IRQ_HANDLER(CAN2_TX_IRQHandler)
{

View File

@ -26,7 +26,7 @@ bool BusEvent::wait(uavcan::MonotonicDuration duration)
{
# if (CH_KERNEL_MAJOR == 2)
ret = sem_.waitTimeout(TIME_IMMEDIATE);
# else // ChibiOS 3
# else // ChibiOS 3+
ret = sem_.wait(TIME_IMMEDIATE);
# endif
}
@ -34,13 +34,13 @@ bool BusEvent::wait(uavcan::MonotonicDuration duration)
{
# if (CH_KERNEL_MAJOR == 2)
ret = sem_.waitTimeout((msec > MaxDelayMSec) ? MS2ST(MaxDelayMSec) : MS2ST(msec));
# else // ChibiOS 3
# else // ChibiOS 3+
ret = sem_.wait((msec > MaxDelayMSec) ? MS2ST(MaxDelayMSec) : MS2ST(msec));
# endif
}
# if (CH_KERNEL_MAJOR == 2)
return ret == RDY_OK;
# else // ChibiOS 3
# else // ChibiOS 3+
return ret == MSG_OK;
# endif
}
@ -56,7 +56,7 @@ void BusEvent::signalFromInterrupt()
chSysLockFromIsr();
sem_.signalI();
chSysUnlockFromIsr();
# else // ChibiOS 3
# else // ChibiOS 3+
chSysLockFromISR();
sem_.signalI();
chSysUnlockFromISR();
@ -75,7 +75,7 @@ void Mutex::unlock()
{
# if (CH_KERNEL_MAJOR == 2)
chibios_rt::BaseThread::unlockMutex();
# else // ChibiOS 3
# else // ChibiOS 3+
mtx_.unlock();
# endif
}