From 411e6a635117a17986c22d98176e80c6921f70a6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:40:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1678 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 os/kernel/include/chsem.h (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h new file mode 100644 index 000000000..cced49601 --- /dev/null +++ b/os/kernel/include/chsem.h @@ -0,0 +1,104 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file semaphores.h + * @brief Semaphores macros and structures. + * + * @addtogroup semaphores + * @{ + */ + +#ifndef _SEMAPHORES_H_ +#define _SEMAPHORES_H_ + +#if CH_USE_SEMAPHORES + +/** + * @brief Semaphore structure. + */ +typedef struct Semaphore { + ThreadsQueue s_queue; /**< @brief Queue of the threads sleeping + on this semaphore. */ + cnt_t s_cnt; /**< @brief The semaphore counter. */ +} Semaphore; + +#ifdef __cplusplus +extern "C" { +#endif + void chSemInit(Semaphore *sp, cnt_t n); + void chSemReset(Semaphore *sp, cnt_t n); + void chSemResetI(Semaphore *sp, cnt_t n); + msg_t chSemWait(Semaphore *sp); + msg_t chSemWaitS(Semaphore *sp); + msg_t chSemWaitTimeout(Semaphore *sp, systime_t time); + msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time); + void chSemSignal(Semaphore *sp); + void chSemSignalI(Semaphore *sp); +#if CH_USE_SEMSW + msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw); +#endif +#ifdef __cplusplus +} +#endif + +/** + * @brief Data part of a static semaphore initializer. + * @details This macro should be used when statically initializing a semaphore + * that is part of a bigger structure. + * + * @param[in] name the name of the semaphore variable + * @param[in] n the counter initial value, this value must be + * non-negative + */ +#define _SEMAPHORE_DATA(name, n) {_THREADSQUEUE_DATA(name.s_queue), n} + +/** + * @brief Static semaphore initializer. + * @details Statically initialized semaphores require no explicit + * initialization using @p chSemInit(). + * + * @param[in] name the name of the semaphore variable + * @param[in] n the counter initial value, this value must be + * non-negative + */ +#define SEMAPHORE_DECL(name, n) Semaphore name = _SEMAPHORE_DATA(name, n) + +/** + * @brief Decreases the semaphore counter. + * @details This macro can be used when the counter is known to be positive. + */ +#define chSemFastWaitI(sp) ((sp)->s_cnt--) + +/** + * @brief Increases the semaphore counter. + * @details This macro can be used when the counter is known to be not negative. + */ +#define chSemFastSignalI(sp) ((sp)->s_cnt++) + +/** + * @brief Returns the semaphore counter current value. + */ +#define chSemGetCounterI(sp) ((sp)->s_cnt) + +#endif /* CH_USE_SEMAPHORES */ + +#endif /* _SEMAPHORES_H_ */ + +/** @} */ -- cgit v1.2.3 From 5fb790997fec3b9d965c57e57b4edd156c8b8954 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:54:22 +0000 Subject: Renamed the kernel header to match their source files. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1679 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index cced49601..02ad3a79f 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -18,15 +18,15 @@ */ /** - * @file semaphores.h + * @file chsem.h * @brief Semaphores macros and structures. * * @addtogroup semaphores * @{ */ -#ifndef _SEMAPHORES_H_ -#define _SEMAPHORES_H_ +#ifndef _CHSEM_H_ +#define _CHSEM_H_ #if CH_USE_SEMAPHORES @@ -99,6 +99,6 @@ extern "C" { #endif /* CH_USE_SEMAPHORES */ -#endif /* _SEMAPHORES_H_ */ +#endif /* _CHSEM_H_ */ /** @} */ -- cgit v1.2.3 From 9ffea7e261ec4016d788abbbf7c4a6d3a78e0a04 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 18 Sep 2010 06:48:56 +0000 Subject: Documentation improvements, renamed some event APIs. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2179 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index 02ad3a79f..cf0897675 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -28,7 +28,7 @@ #ifndef _CHSEM_H_ #define _CHSEM_H_ -#if CH_USE_SEMAPHORES +#if CH_USE_SEMAPHORES || defined(__DOXYGEN__) /** * @brief Semaphore structure. -- cgit v1.2.3 From 07351222e6d0b6b3dcd4f50ecb18bc09e7402d1c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Sep 2010 10:22:06 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2184 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index cf0897675..17c6a03e3 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -83,17 +83,24 @@ extern "C" { /** * @brief Decreases the semaphore counter. * @details This macro can be used when the counter is known to be positive. + * + * @iclass */ #define chSemFastWaitI(sp) ((sp)->s_cnt--) /** * @brief Increases the semaphore counter. - * @details This macro can be used when the counter is known to be not negative. + * @details This macro can be used when the counter is known to be not + * negative. + * + * @iclass */ #define chSemFastSignalI(sp) ((sp)->s_cnt++) /** * @brief Returns the semaphore counter current value. + * + * @iclass */ #define chSemGetCounterI(sp) ((sp)->s_cnt) -- cgit v1.2.3 From 89c12799e185423b6c571b78d5b44e11e67adf72 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 2 Jan 2011 10:13:43 +0000 Subject: Added new semaphore API chSemSetCounterI(). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2569 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 1 + 1 file changed, 1 insertion(+) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index 17c6a03e3..efed15189 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -51,6 +51,7 @@ extern "C" { msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time); void chSemSignal(Semaphore *sp); void chSemSignalI(Semaphore *sp); + void chSemSetCounterI(Semaphore *sp, cnt_t n); #if CH_USE_SEMSW msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw); #endif -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index efed15189..f33b294fa 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From de877486efb49378065f769ff423eef19ceb12e6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 9 Apr 2011 15:10:15 +0000 Subject: Fixed bug 3276379. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2872 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index f33b294fa..04e079466 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -52,7 +52,7 @@ extern "C" { msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time); void chSemSignal(Semaphore *sp); void chSemSignalI(Semaphore *sp); - void chSemSetCounterI(Semaphore *sp, cnt_t n); + void chSemAddCounterI(Semaphore *sp, cnt_t n); #if CH_USE_SEMSW msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw); #endif -- cgit v1.2.3 From c9be79def630f153b0b2d28e905939c15743f989 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Aug 2011 10:09:08 +0000 Subject: Kernel documentation fixes and improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index 04e079466..5f1c37a0a 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -82,6 +82,10 @@ extern "C" { */ #define SEMAPHORE_DECL(name, n) Semaphore name = _SEMAPHORE_DATA(name, n) +/** + * @name Macro Functions + * @{ + */ /** * @brief Decreases the semaphore counter. * @details This macro can be used when the counter is known to be positive. @@ -105,6 +109,7 @@ extern "C" { * @iclass */ #define chSemGetCounterI(sp) ((sp)->s_cnt) +/** @} */ #endif /* CH_USE_SEMAPHORES */ -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index 5f1c37a0a..fbe3ae9bf 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chsem.h') diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h index fbe3ae9bf..b5036af7c 100644 --- a/os/kernel/include/chsem.h +++ b/os/kernel/include/chsem.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3