diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-10-02 12:19:24 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-10-02 12:19:24 +0000 |
commit | e65a5b08cda0ef8358b4a851feb74860cdc74625 (patch) | |
tree | a19de51e5e764df0ef0ed36671f5e91f367b03ae /os/common/oslib/include/chfactory.h | |
parent | 23c7476ac4f0ebfc7b09d9858149d9bf79f1122e (diff) | |
download | ChibiOS-e65a5b08cda0ef8358b4a851feb74860cdc74625.tar.gz ChibiOS-e65a5b08cda0ef8358b4a851feb74860cdc74625.tar.bz2 ChibiOS-e65a5b08cda0ef8358b4a851feb74860cdc74625.zip |
Added mailboxes to the factory.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10743 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/common/oslib/include/chfactory.h')
-rw-r--r-- | os/common/oslib/include/chfactory.h | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/os/common/oslib/include/chfactory.h b/os/common/oslib/include/chfactory.h index 9dbcb7b57..ae975d3bd 100644 --- a/os/common/oslib/include/chfactory.h +++ b/os/common/oslib/include/chfactory.h @@ -68,6 +68,13 @@ #define CH_CFG_FACTORY_SEMAPHORES TRUE
#endif
+/**
+ * @brief Enables factory for mailboxes.
+ */
+#if !defined(CH_CFG_FACTORY_MAILBOXES) || defined(__DOXYGEN__)
+#define CH_CFG_FACTORY_MAILBOXES TRUE
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -76,7 +83,8 @@ ((CH_CFG_FACTORY_SEMAPHORES == TRUE))
#define CH_FACTORY_REQUIRES_HEAP \
- ((CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE))
+ ((CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || \
+ (CH_CFG_FACTORY_MAILBOXES == TRUE))
#if (CH_CFG_FACTORY_MAX_NAMES_LENGHT < 0) || \
(CH_CFG_FACTORY_MAX_NAMES_LENGHT > 32)
@@ -99,6 +107,10 @@ #error "CH_CFG_FACTORY_SEMAPHORES requires CH_CFG_USE_SEMAPHORES"
#endif
+#if (CH_CFG_FACTORY_MAILBOXES == TRUE) && (CH_CFG_USE_MAILBOXES == FALSE)
+#error "CH_CFG_FACTORY_MAILBOXES requires CH_CFG_USE_MAILBOXES"
+#endif
+
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
@@ -156,7 +168,7 @@ typedef struct ch_dyn_object { */
dyn_element_t element;
/**
- * @brief Physical buffer objects.
+ * @brief The buffer.
* @note This requires C99.
*/
uint8_t buffer[];
@@ -173,12 +185,33 @@ typedef struct ch_dyn_semaphore { */
dyn_element_t element;
/**
- * @brief Physical semaphore.
+ * @brief The semaphore.
*/
semaphore_t sem;
} dyn_semaphore_t;
#endif
+#if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXIGEN__)
+/**
+ * @brief Type of a dynamic buffer object.
+ */
+typedef struct ch_dyn_mailbox {
+ /**
+ * @brief List element of the dynamic buffer object.
+ */
+ dyn_element_t element;
+ /**
+ * @brief The mailbox.
+ */
+ mailbox_t mbx;
+ /**
+ * @brief Mailbox buffer.
+ * @note This requires C99.
+ */
+ msg_t buffer[];
+} dyn_mailbox_t;
+#endif
+
/**
* @brief Type of the factory main object.
*/
@@ -207,6 +240,12 @@ typedef struct ch_objects_factory { */
memory_pool_t sem_pool;
#endif /* CH_CFG_FACTORY_SEMAPHORES = TRUE */
+#if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXIGEN__)
+ /**
+ * @brief List of the allocated buffer objects.
+ */
+ dyn_list_t mbx_list;
+#endif /* CH_CFG_FACTORY_MAILBOXES = TRUE */
} objects_factory_t;
/*===========================================================================*/
@@ -241,6 +280,11 @@ extern "C" { dyn_semaphore_t *chFactoryFindSemaphore(const char *name);
void chFactoryReleaseSemaphore(dyn_semaphore_t *dsp);
#endif
+#if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXIGEN__)
+ dyn_mailbox_t *chFactoryCreateMailbox(const char *name, cnt_t n);
+ dyn_mailbox_t *chFactoryFindMailbox(const char *name);
+ void chFactoryReleaseMailbox(dyn_mailbox_t *dmp);
+#endif
#ifdef __cplusplus
}
#endif
|