ChibiOS/HAL  6.1.0
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 /**
66  * @brief Starts the alarm.
67  * @note Makes sure that no spurious alarms are triggered after
68  * this call.
69  * @note This functionality is only available in free running mode, the
70  * behavior in periodic mode is undefined.
71  *
72  * @param[in] abstime the time to be set for the first alarm
73  *
74  * @api
75  */
76 void stStartAlarm(systime_t abstime) {
77 
78  osalDbgAssert(stIsAlarmActive() == false, "already active");
79 
80  st_lld_start_alarm(abstime);
81 }
82 
83 /**
84  * @brief Stops the alarm interrupt.
85  * @note This functionality is only available in free running mode, the
86  * behavior in periodic mode is undefined.
87  *
88  * @api
89  */
90 void stStopAlarm(void) {
91 
93 }
94 
95 /**
96  * @brief Sets the alarm time.
97  * @note This functionality is only available in free running mode, the
98  * behavior in periodic mode is undefined.
99  *
100  * @param[in] abstime the time to be set for the next alarm
101  *
102  * @api
103  */
104 void stSetAlarm(systime_t abstime) {
105 
106  osalDbgAssert(stIsAlarmActive() != false, "not active");
107 
108  st_lld_set_alarm(abstime);
109 }
110 
111 /**
112  * @brief Returns the current alarm time.
113  * @note This functionality is only available in free running mode, the
114  * behavior in periodic mode is undefined.
115  *
116  * @return The currently set alarm time.
117  *
118  * @api
119  */
121 
122  osalDbgAssert(stIsAlarmActive() != false, "not active");
123 
124  return st_lld_get_alarm();
125 }
126 
127 #endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */
128 
129 /** @} */
systime_t stGetAlarm(void)
Returns the current alarm time.
Definition: hal_st.c:120
void stStartAlarm(systime_t abstime)
Starts the alarm.
Definition: hal_st.c:76
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:104
#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:90
#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