ChibiOS/HAL  7.0.3
hal_st.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_st.c
19  * @brief ST Driver code.
20  *
21  * @addtogroup ST
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /*===========================================================================*/
38 /* Driver local types. */
39 /*===========================================================================*/
40 
41 /*===========================================================================*/
42 /* Driver local variables. */
43 /*===========================================================================*/
44 
45 /*===========================================================================*/
46 /* Driver local functions. */
47 /*===========================================================================*/
48 
49 /*===========================================================================*/
50 /* Driver exported functions. */
51 /*===========================================================================*/
52 
53 /**
54  * @brief ST Driver initialization.
55  * @note This function is implicitly invoked by @p halInit(), there is
56  * no need to explicitly initialize the driver.
57  *
58  * @init
59  */
60 void stInit(void) {
61 
62  st_lld_init();
63 }
64 
65 #if (OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING) || defined(__DOXYGEN__)
66 /**
67  * @brief Starts the alarm.
68  * @note Makes sure that no spurious alarms are triggered after
69  * this call.
70  * @note This functionality is only available in free running mode, the
71  * behavior in periodic mode is undefined.
72  *
73  * @param[in] abstime the time to be set for the first alarm
74  *
75  * @api
76  */
77 void stStartAlarm(systime_t abstime) {
78 
79  osalDbgAssert(stIsAlarmActive() == false, "already active");
80 
81  st_lld_start_alarm(abstime);
82 }
83 
84 /**
85  * @brief Stops the alarm interrupt.
86  * @note This functionality is only available in free running mode, the
87  * behavior in periodic mode is undefined.
88  *
89  * @api
90  */
91 void stStopAlarm(void) {
92 
94 }
95 
96 /**
97  * @brief Sets the alarm time.
98  * @note This functionality is only available in free running mode, the
99  * behavior in periodic mode is undefined.
100  *
101  * @param[in] abstime the time to be set for the next alarm
102  *
103  * @api
104  */
105 void stSetAlarm(systime_t abstime) {
106 
107  osalDbgAssert(stIsAlarmActive() != false, "not active");
108 
109  st_lld_set_alarm(abstime);
110 }
111 
112 /**
113  * @brief Returns the current alarm time.
114  * @note This functionality is only available in free running mode, the
115  * behavior in periodic mode is undefined.
116  *
117  * @return The currently set alarm time.
118  *
119  * @api
120  */
122 
123  osalDbgAssert(stIsAlarmActive() != false, "not active");
124 
125  return st_lld_get_alarm();
126 }
127 #endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */
128 
129 #endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */
130 
131 /** @} */
systime_t stGetAlarm(void)
Returns the current alarm time.
Definition: hal_st.c:121
void stStartAlarm(systime_t abstime)
Starts the alarm.
Definition: hal_st.c:77
static void st_lld_stop_alarm(void)
Stops the alarm interrupt.
Definition: hal_st_lld.h:97
static systime_t st_lld_get_alarm(void)
Returns the current alarm time.
Definition: hal_st_lld.h:120
HAL subsystem header.
uint32_t systime_t
Type of system time counter.
Definition: osal.h:165
void stInit(void)
ST Driver initialization.
Definition: hal_st.c:60
void stSetAlarm(systime_t abstime)
Sets the alarm time.
Definition: hal_st.c:105
#define stIsAlarmActive()
Determines if the alarm is active.
Definition: hal_st.h:76
void st_lld_init(void)
Low level ST driver initialization.
Definition: hal_st_lld.c:62
void stStopAlarm(void)
Stops the alarm interrupt.
Definition: hal_st.c:91
#define osalDbgAssert(c, remark)
Condition assertion.
Definition: osal.h:258
static void st_lld_start_alarm(systime_t abstime)
Starts the alarm.
Definition: hal_st_lld.h:87
static void st_lld_set_alarm(systime_t abstime)
Sets the alarm time.
Definition: hal_st_lld.h:108