From 6b5ddb71fcb396ec826a283427b4771018d193e8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 28 Feb 2011 18:44:46 +0000 Subject: GPT driver model, STM32 GPT driver implementation, not tested, documentation not done yet. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2779 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/gpt.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 os/hal/include/gpt.h (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h new file mode 100644 index 000000000..d4063cd6c --- /dev/null +++ b/os/hal/include/gpt.h @@ -0,0 +1,107 @@ +/* + 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 gpt.h + * @brief GPT Driver macros and structures. + * + * @addtogroup GPT + * @{ + */ + +#ifndef _GPT_H_ +#define _GPT_H_ + +#if HAL_USE_GPT || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(GPT_USE_WAIT) || defined(__DOXYGEN__) +#define GPT_USE_WAIT TRUE +#endif + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +#if GPT_USE_WAIT && !CH_USE_SEMAPHORES +#error "GPT driver requires CH_USE_SEMAPHORES when GPT_USE_WAIT is enabled" +#endif + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + GPT_UNINIT = 0, /**< Not initialized. */ + GPT_STOP = 1, /**< Stopped. */ + GPT_READY = 2, /**< Ready. */ + GPT_CONTINUOUS = 3, /**< Active in continuous mode. */ + GPT_ONESHOT = 4 /**< Active in one shot mode. */ +} gptstate_t; + +#include "gpt_lld.h" + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void gptInit(void); + void gptObjectInit(GPTDriver *gptp); + void gptStart(GPTDriver *gptp, const GPTConfig *config); + void gptStop(GPTDriver *gptp); + void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval); + void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval); + void gptStartOneShot(GPTDriver *gptp, gptcnt_t interval); + void gptStartOneShotI(GPTDriver *gptp, gptcnt_t interval); + void gptStopTimer(GPTDriver *gptp); + void gptStopTimerI(GPTDriver *gptp); + void gptPolledDelay(GPTDriver *gptp, gptcnt_t interval); +#if GPT_USE_WAIT + void gptDelay(GPTDriver *gptp, gptcnt_t interval); +#endif +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_GPT */ + +#endif /* _GPT_H_ */ + +/** @} */ -- cgit v1.2.3 From 2de96c4c5776fe2c029b6b6ee543f13a07585107 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Mar 2011 16:56:01 +0000 Subject: Better a KISS approach. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2790 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/gpt.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index d4063cd6c..c1ce72edf 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.h @@ -38,22 +38,10 @@ /* Driver pre-compile time settings. */ /*===========================================================================*/ -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(GPT_USE_WAIT) || defined(__DOXYGEN__) -#define GPT_USE_WAIT TRUE -#endif - /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ -#if GPT_USE_WAIT && !CH_USE_SEMAPHORES -#error "GPT driver requires CH_USE_SEMAPHORES when GPT_USE_WAIT is enabled" -#endif - /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ @@ -93,9 +81,6 @@ extern "C" { void gptStopTimer(GPTDriver *gptp); void gptStopTimerI(GPTDriver *gptp); void gptPolledDelay(GPTDriver *gptp, gptcnt_t interval); -#if GPT_USE_WAIT - void gptDelay(GPTDriver *gptp, gptcnt_t interval); -#endif #ifdef __cplusplus } #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/hal/include/gpt.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index c1ce72edf..c65cd7cee 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.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 91e4dee81eef472b69d7b5fe321d8c16b4a0ac59 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 31 Mar 2011 12:35:42 +0000 Subject: Generic improvements to the GPT driver organization. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2854 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/gpt.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index c65cd7cee..5bb385078 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.h @@ -58,6 +58,18 @@ typedef enum { GPT_ONESHOT = 4 /**< Active in one shot mode. */ } gptstate_t; +/** + * @brief Type of a structure representing a GPT driver. + */ +typedef struct GPTDriver GPTDriver; + +/** + * @brief GPT notification callback type. + * + * @param[in] gptp pointer to a @p GPTDriver object + */ +typedef void (*gptcallback_t)(GPTDriver *gptp); + #include "gpt_lld.h" /*===========================================================================*/ -- 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/hal/include/gpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index 5bb385078..e43f334e8 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.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/hal/include/gpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index e43f334e8..4a8245df5 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.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 From f571b507132cc77e401dee68535c2b9f3370c60c Mon Sep 17 00:00:00 2001 From: barthess Date: Wed, 27 Mar 2013 20:03:40 +0000 Subject: STM32. GPT. Added abillity to change interval of running GPT unit on the fly. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5510 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/gpt.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index 4a8245df5..379b90be9 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.h @@ -76,6 +76,23 @@ typedef void (*gptcallback_t)(GPTDriver *gptp); /* Driver macros. */ /*===========================================================================*/ +/** + * @brief Changes the interval of GPT peripheral. + * @details This function changes the interval of a running GPT unit. + * @pre The GPT unit must have been activated using @p gptStart(). + * @pre The GPT unit must have been running in continuous mode using + * @p gptStartContinuous(). + * @post The GPT unit interval is changed to the new value. + * + * @param[in] gptp pointer to a @p GPTDriver object + * @param[in] interval new cycle time in timer ticks + * + * @iclass + */ +#define stm32_gptChangeIntervalI(gptp, interval) { \ + gpt_lld_change_interval(gptp, interval); \ +} + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -89,6 +106,7 @@ extern "C" { void gptStop(GPTDriver *gptp); void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval); void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval); + void stm32_gptChangeInterval(GPTDriver *gptp, gptcnt_t interval); void gptStartOneShot(GPTDriver *gptp, gptcnt_t interval); void gptStartOneShotI(GPTDriver *gptp, gptcnt_t interval); void gptStopTimer(GPTDriver *gptp); -- cgit v1.2.3 From 042c2ddba82250d60de4882ae7b0293666747d2d Mon Sep 17 00:00:00 2001 From: barthess Date: Fri, 29 Mar 2013 19:27:32 +0000 Subject: STM32. GPT. Removed prefix "stm32" from names of functions changing interval. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5518 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/gpt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/hal/include/gpt.h') diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h index 379b90be9..3b474cb14 100644 --- a/os/hal/include/gpt.h +++ b/os/hal/include/gpt.h @@ -89,7 +89,7 @@ typedef void (*gptcallback_t)(GPTDriver *gptp); * * @iclass */ -#define stm32_gptChangeIntervalI(gptp, interval) { \ +#define gptChangeIntervalI(gptp, interval) { \ gpt_lld_change_interval(gptp, interval); \ } @@ -106,7 +106,7 @@ extern "C" { void gptStop(GPTDriver *gptp); void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval); void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval); - void stm32_gptChangeInterval(GPTDriver *gptp, gptcnt_t interval); + void gptChangeInterval(GPTDriver *gptp, gptcnt_t interval); void gptStartOneShot(GPTDriver *gptp, gptcnt_t interval); void gptStartOneShotI(GPTDriver *gptp, gptcnt_t interval); void gptStopTimer(GPTDriver *gptp); -- cgit v1.2.3