ChibiOS/HAL  6.1.0
hal_gpt_lld.c
Go to the documentation of this file.
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.c
19  * @brief PLATFORM GPT subsystem low level driver source.
20  *
21  * @addtogroup GPT
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /**
38  * @brief GPTD1 driver identifier.
39  */
40 #if (PLATFORM_GPT_USE_GPT1 == TRUE) || defined(__DOXYGEN__)
42 #endif
43 
44 /*===========================================================================*/
45 /* Driver local variables and types. */
46 /*===========================================================================*/
47 
48 /*===========================================================================*/
49 /* Driver local functions. */
50 /*===========================================================================*/
51 
52 /*===========================================================================*/
53 /* Driver interrupt handlers. */
54 /*===========================================================================*/
55 
56 /*===========================================================================*/
57 /* Driver exported functions. */
58 /*===========================================================================*/
59 
60 /**
61  * @brief Low level GPT driver initialization.
62  *
63  * @notapi
64  */
65 void gpt_lld_init(void) {
66 
67 #if PLATFORM_GPT_USE_GPT1 == TRUE
68  /* Driver initialization.*/
69  gptObjectInit(&GPTD1);
70 #endif
71 }
72 
73 /**
74  * @brief Configures and activates the GPT peripheral.
75  *
76  * @param[in] gptp pointer to the @p GPTDriver object
77  *
78  * @notapi
79  */
80 void gpt_lld_start(GPTDriver *gptp) {
81 
82  if (gptp->state == GPT_STOP) {
83  /* Enables the peripheral.*/
84 #if PLATFORM_GPT_USE_GPT1 == TRUE
85  if (&GPTD1 == gptp) {
86 
87  }
88 #endif
89  }
90  /* Configures the peripheral.*/
91 
92 }
93 
94 /**
95  * @brief Deactivates the GPT peripheral.
96  *
97  * @param[in] gptp pointer to the @p GPTDriver object
98  *
99  * @notapi
100  */
101 void gpt_lld_stop(GPTDriver *gptp) {
102 
103  if (gptp->state == GPT_READY) {
104  /* Resets the peripheral.*/
105 
106  /* Disables the peripheral.*/
107 #if PLATFORM_GPT_USE_GPT1 == TRUE
108  if (&GPTD1 == gptp) {
109 
110  }
111 #endif
112  }
113 }
114 
115 /**
116  * @brief Starts the timer in continuous mode.
117  *
118  * @param[in] gptp pointer to the @p GPTDriver object
119  * @param[in] interval period in ticks
120  *
121  * @notapi
122  */
123 void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval) {
124 
125  (void)gptp;
126  (void)interval;
127 
128 }
129 
130 /**
131  * @brief Stops the timer.
132  *
133  * @param[in] gptp pointer to the @p GPTDriver object
134  *
135  * @notapi
136  */
138 
139  (void)gptp;
140 
141 }
142 
143 /**
144  * @brief Starts the timer in one shot mode and waits for completion.
145  * @details This function specifically polls the timer waiting for completion
146  * in order to not have extra delays caused by interrupt servicing,
147  * this function is only recommended for short delays.
148  *
149  * @param[in] gptp pointer to the @p GPTDriver object
150  * @param[in] interval time interval in ticks
151  *
152  * @notapi
153  */
154 void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) {
155 
156  (void)gptp;
157  (void)interval;
158 
159 }
160 
161 #endif /* HAL_USE_GPT == TRUE */
162 
163 /** @} */
void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval)
Starts the timer in one shot mode and waits for completion.
Definition: hal_gpt_lld.c:154
void gpt_lld_init(void)
Low level GPT driver initialization.
Definition: hal_gpt_lld.c:65
GPTDriver GPTD1
GPTD1 driver identifier.
Definition: hal_gpt_lld.c:41
HAL subsystem header.
void gpt_lld_stop(GPTDriver *gptp)
Deactivates the GPT peripheral.
Definition: hal_gpt_lld.c:101
void gpt_lld_start(GPTDriver *gptp)
Configures and activates the GPT peripheral.
Definition: hal_gpt_lld.c:80
Structure representing a GPT driver.
Definition: hal_gpt_lld.h:92
uint16_t gptcnt_t
GPT counter type.
Definition: hal_gpt_lld.h:68
gptstate_t state
Driver state.
Definition: hal_gpt_lld.h:96
void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval)
Starts the timer in continuous mode.
Definition: hal_gpt_lld.c:123
void gptObjectInit(GPTDriver *gptp)
Initializes the standard part of a GPTDriver structure.
Definition: hal_gpt.c:68
void gpt_lld_stop_timer(GPTDriver *gptp)
Stops the timer.
Definition: hal_gpt_lld.c:137