aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/templates/hal_gpt_lld.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_gpt_lld.h')
-rw-r--r--lib/chibios/os/hal/templates/hal_gpt_lld.h154
1 files changed, 154 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_gpt_lld.h b/lib/chibios/os/hal/templates/hal_gpt_lld.h
new file mode 100644
index 000000000..468dfd0cc
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_gpt_lld.h
@@ -0,0 +1,154 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_gpt_lld.h
19 * @brief PLATFORM GPT subsystem low level driver header.
20 *
21 * @addtogroup GPT
22 * @{
23 */
24
25#ifndef HAL_GPT_LLD_H
26#define HAL_GPT_LLD_H
27
28#if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/*===========================================================================*/
35/* Driver pre-compile time settings. */
36/*===========================================================================*/
37
38/**
39 * @name PLATFORM configuration options
40 * @{
41 */
42/**
43 * @brief GPTD1 driver enable switch.
44 * @details If set to @p TRUE the support for GPTD1 is included.
45 * @note The default is @p FALSE.
46 */
47#if !defined(PLATFORM_GPT_USE_GPT1) || defined(__DOXYGEN__)
48#define PLATFORM_GPT_USE_GPT1 FALSE
49#endif
50/** @} */
51
52/*===========================================================================*/
53/* Derived constants and error checks. */
54/*===========================================================================*/
55
56/*===========================================================================*/
57/* Driver data structures and types. */
58/*===========================================================================*/
59
60/**
61 * @brief GPT frequency type.
62 */
63typedef uint32_t gptfreq_t;
64
65/**
66 * @brief GPT counter type.
67 */
68typedef uint16_t gptcnt_t;
69
70/**
71 * @brief Driver configuration structure.
72 * @note It could be empty on some architectures.
73 */
74typedef struct {
75 /**
76 * @brief Timer clock in Hz.
77 * @note The low level can use assertions in order to catch invalid
78 * frequency specifications.
79 */
80 gptfreq_t frequency;
81 /**
82 * @brief Timer callback pointer.
83 * @note This callback is invoked on GPT counter events.
84 */
85 gptcallback_t callback;
86 /* End of the mandatory fields.*/
87} GPTConfig;
88
89/**
90 * @brief Structure representing a GPT driver.
91 */
92struct GPTDriver {
93 /**
94 * @brief Driver state.
95 */
96 gptstate_t state;
97 /**
98 * @brief Current configuration data.
99 */
100 const GPTConfig *config;
101#if defined(GPT_DRIVER_EXT_FIELDS)
102 GPT_DRIVER_EXT_FIELDS
103#endif
104 /* End of the mandatory fields.*/
105};
106
107/*===========================================================================*/
108/* Driver macros. */
109/*===========================================================================*/
110
111/**
112 * @brief Changes the interval of GPT peripheral.
113 * @details This function changes the interval of a running GPT unit.
114 * @pre The GPT unit must have been activated using @p gptStart().
115 * @pre The GPT unit must have been running in continuous mode using
116 * @p gptStartContinuous().
117 * @post The GPT unit interval is changed to the new value.
118 * @note The function has effect at the next cycle start.
119 *
120 * @param[in] gptp pointer to a @p GPTDriver object
121 * @param[in] interval new cycle time in timer ticks
122 * @notapi
123 */
124#define gpt_lld_change_interval(gptp, interval) { \
125 (void)gptp; \
126 (void)interval; \
127}
128
129/*===========================================================================*/
130/* External declarations. */
131/*===========================================================================*/
132
133#if (PLATFORM_GPT_USE_GPT1 == TRUE) && !defined(__DOXYGEN__)
134extern GPTDriver GPTD1;
135#endif
136
137#ifdef __cplusplus
138extern "C" {
139#endif
140 void gpt_lld_init(void);
141 void gpt_lld_start(GPTDriver *gptp);
142 void gpt_lld_stop(GPTDriver *gptp);
143 void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval);
144 void gpt_lld_stop_timer(GPTDriver *gptp);
145 void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval);
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* HAL_USE_GPT == TRUE */
151
152#endif /* HAL_GPT_LLD_H */
153
154/** @} */