ChibiOS  21.6.0
hal_st.h
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.h
19  * @brief ST Driver macros and structures.
20  * @details This header is designed to be include-able without having to
21  * include other files from the HAL.
22  *
23  * @addtogroup ST
24  * @{
25  */
26 
27 #ifndef HAL_ST_H
28 #define HAL_ST_H
29 
30 #include "hal_st_lld.h"
31 
32 /*===========================================================================*/
33 /* Driver constants. */
34 /*===========================================================================*/
35 
36 /*===========================================================================*/
37 /* Driver pre-compile time settings. */
38 /*===========================================================================*/
39 
40 /*===========================================================================*/
41 /* Derived constants and error checks. */
42 /*===========================================================================*/
43 
44 /* Compatibility with old LLDS.*/
45 #if !defined(ST_LLD_NUM_ALARMS)
46 #define ST_LLD_NUM_ALARMS 1
47 #endif
48 
49 /*===========================================================================*/
50 /* Driver data structures and types. */
51 /*===========================================================================*/
52 
53 typedef void (*st_callback_t)(unsigned alarm);
54 
55 /*===========================================================================*/
56 /* Driver macros. */
57 /*===========================================================================*/
58 
59 /*===========================================================================*/
60 /* External declarations. */
61 /*===========================================================================*/
62 
63 #if (ST_LLD_NUM_ALARMS > 1) && !defined(__DOXYGEN__)
64 extern st_callback_t st_callbacks[ST_LLD_NUM_ALARMS];
65 #endif
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70  void stInit(void);
71 #if defined(ST_LLD_MULTICORE_SUPPORT)
72  void stBind(void);
73 #endif
74 #if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
75  systime_t stGetCounter(void);
76  void stStartAlarm(systime_t abstime);
77  void stStopAlarm(void);
78  void stSetAlarm(systime_t abstime);
79  systime_t stGetAlarm(void);
80  bool stIsAlarmActive(void);
81 #if ST_LLD_NUM_ALARMS > 1
82  void stSetCallback(unsigned alarm, st_callback_t cb);
83 #if defined(ST_LLD_MULTICORE_SUPPORT)
84  void stBindAlarmN(unsigned alarm);
85 #endif
86  void stStartAlarmN(unsigned alarm, systime_t abstime);
87  void stStopAlarmN(unsigned alarm);
88  void stSetAlarmN(unsigned alarm, systime_t abstime);
89  systime_t stGetAlarmN(unsigned alarm);
90  bool stIsAlarmActiveN(unsigned alarm);
91 #endif /* ST_LLD_NUM_ALARMS > 1 */
92 #endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* HAL_ST_H */
98 
99 /** @} */
st_callbacks
st_callback_t st_callbacks[ST_LLD_NUM_ALARMS]
Callback pointers for each alarm.
Definition: hal_st.c:51
stStopAlarmN
void stStopAlarmN(unsigned alarm)
Stops an additional alarm.
Definition: hal_st.c:251
stGetCounter
systime_t stGetCounter(void)
Returns the time counter value.
Definition: hal_st.c:103
stSetAlarm
void stSetAlarm(systime_t abstime)
Sets the alarm zero time.
Definition: hal_st.c:147
stSetCallback
void stSetCallback(unsigned alarm, st_callback_t cb)
Associates a callback to an alarm.
Definition: hal_st.c:197
stGetAlarmN
systime_t stGetAlarmN(unsigned alarm)
Returns an additional alarm current time.
Definition: hal_st.c:286
stInit
void stInit(void)
ST Driver initialization.
Definition: hal_st.c:69
systime_t
uint64_t systime_t
Type of system time.
Definition: chtime.h:107
stIsAlarmActiveN
bool stIsAlarmActiveN(unsigned alarm)
Determines if the specified alarm is active.
Definition: hal_st.c:304
hal_st_lld.h
PLATFORM ST subsystem low level driver header.
stSetAlarmN
void stSetAlarmN(unsigned alarm, systime_t abstime)
Sets an additional alarm time.
Definition: hal_st.c:268
stIsAlarmActive
bool stIsAlarmActive(void)
Determines if the alarm zero is active.
Definition: hal_st.c:179
stBind
void stBind(void)
Enables an alarm interrupt on the invoking core.
Definition: hal_st.c:87
stStopAlarm
void stStopAlarm(void)
Stops the alarm zero interrupt.
Definition: hal_st.c:133
stGetAlarm
systime_t stGetAlarm(void)
Returns the alarm zero current time.
Definition: hal_st.c:163
stStartAlarm
void stStartAlarm(systime_t abstime)
Starts the alarm zero.
Definition: hal_st.c:119
stStartAlarmN
void stStartAlarmN(unsigned alarm, systime_t abstime)
Starts an additional alarm.
Definition: hal_st.c:234
stBindAlarmN
void stBindAlarmN(unsigned alarm)
Enables an alarm interrupt on the invoking core.
Definition: hal_st.c:213