aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-01-02 11:17:31 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-01-02 11:17:31 +0000
commitbb806fe4c18e628b546291dab906928ebdb46627 (patch)
tree977b0fd135d2f8041b6a9174062e91bdcc7fcda3 /os/hal/include
parente5b7a9f72317f21038406c8998c76058efbfa157 (diff)
downloadChibiOS-bb806fe4c18e628b546291dab906928ebdb46627.tar.gz
ChibiOS-bb806fe4c18e628b546291dab906928ebdb46627.tar.bz2
ChibiOS-bb806fe4c18e628b546291dab906928ebdb46627.zip
Added callbacks capability to the CAN driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11213 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/hal_can.h69
1 files changed, 68 insertions, 1 deletions
diff --git a/os/hal/include/hal_can.h b/os/hal/include/hal_can.h
index 78bd12a20..16b487d46 100644
--- a/os/hal/include/hal_can.h
+++ b/os/hal/include/hal_can.h
@@ -60,7 +60,7 @@
/**
* @brief Special mailbox identifier.
*/
-#define CAN_ANY_MAILBOX 0
+#define CAN_ANY_MAILBOX 0U
/*===========================================================================*/
/* Driver pre-compile time settings. */
@@ -132,6 +132,73 @@ typedef enum {
canReceiveTimeout(canp, mailbox, crfp, timeout)
/** @} */
+/**
+ * @name Low level driver helper macros
+ * @{
+ */
+#if !defined(CAN_ENFORCE_USE_CALLBACKS)
+/**
+ * @brief TX mailbox empty event.
+ */
+#define _can_tx_empty_isr(canp, flags) { \
+ osalSysLockFromISR(); \
+ osalThreadDequeueAllI(&(canp)->txqueue, MSG_OK); \
+ osalEventBroadcastFlagsI(&(canp)->txempty_event, flags); \
+ osalSysUnlockFromISR(); \
+}
+
+/**
+ * @brief RX mailbox empty full event.
+ */
+#define _can_rx_full_isr(canp, flags) { \
+ osalSysLockFromISR(); \
+ osalThreadDequeueAllI(&(canp)->rxqueue, MSG_OK); \
+ osalEventBroadcastFlagsI(&(canp)->rxfull_event, flags); \
+ osalSysUnlockFromISR(); \
+}
+
+/**
+ * @brief Error event.
+ */
+#define _can_wakeup_isr(canp) { \
+ osalSysLockFromISR(); \
+ osalEventBroadcastFlagsI(&(canp)->wakeup_event, 0U); \
+ osalSysUnlockFromISR(); \
+}
+
+/**
+ * @brief Error event.
+ */
+#define _can_error_isr(canp, flags) { \
+ osalSysLockFromISR(); \
+ osalEventBroadcastFlagsI(&(canp)->error_event, flags); \
+ osalSysUnlockFromISR(); \
+}
+#else /* defined(CAN_ENFORCE_USE_CALLBACKS) */
+#define _can_tx_empty_isr(canp, flags) { \
+ (canp)->txempty_cb(canp, flags); \
+ osalSysLockFromISR(); \
+ osalThreadDequeueAllI(&(canp)->txqueue, MSG_OK); \
+ osalSysUnlockFromISR(); \
+}
+
+#define _can_rx_full_isr(canp, flags) { \
+ (canp)->rxfull_cb(canp, flags); \
+ osalSysLockFromISR(); \
+ osalThreadDequeueAllI(&(canp)->rxqueue, MSG_OK); \
+ osalSysUnlockFromISR(); \
+}
+
+#define _can_wakeup_isr(canp) { \
+ (canp)->wakeup_cb(canp, 0U); \
+}
+
+#define _can_error_isr(canp, flags) { \
+ (canp)->error_cb(canp, flags); \
+}
+#endif /* defined(CAN_ENFORCE_USE_CALLBACKS) */
+/** @} */
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/