Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
qm_ss_timer.h
1 /*
2 * {% copyright %}
3 */
4 
5 #ifndef __QM_SS_TIMER_H__
6 #define __QM_SS_TIMER_H__
7 
8 #include "qm_common.h"
9 #include "qm_sensor_regs.h"
10 
11 /**
12  * Timer driver for Sensor Subsystem.
13  *
14  * @defgroup groupSSTimer SS Timer
15  * @{
16  */
17 
18 /**
19  * Sensor Subsystem Timer Configuration Type.
20  */
21 typedef struct {
22  bool watchdog_mode; /**< Watchdog mode. */
23 
24  /**
25  * Increments in run state only.
26  *
27  * If this field is set to 0, the timer will count
28  * in both halt state and running state.
29  * When set to 1, this will only increment in
30  * running state.
31  */
33  bool int_en; /**< Interrupt enable. */
34  uint32_t count; /**< Final count value. */
35 
36  /**
37  * User callback.
38  *
39  * Called for any interrupt on the Sensor Subsystem Timer.
40  *
41  * @param[in] data The callback user data.
42  */
43  void (*callback)(void *data);
44  void *callback_data; /**< Callback user data. */
46 
47 /**
48  * Set the SS timer configuration.
49  *
50  * This includes final count value, timer mode and if interrupts are enabled.
51  * If interrupts are enabled, it will configure the callback function.
52  *
53  * @param[in] timer Which SS timer to configure.
54  * @param[in] cfg SS timer configuration. This must not be NULL.
55  *
56  * @return Standard errno return type for QMSI.
57  * @retval 0 on success.
58  * @retval Negative @ref errno for possible error codes.
59  */
61  const qm_ss_timer_config_t *const cfg);
62 
63 /**
64  * Set SS timer count value.
65  *
66  * Set the current count value of the SS timer.
67  *
68  * @param[in] timer Which SS timer to set the count of.
69  * @param[in] count Value to load the timer with.
70  *
71  * @return Standard errno return type for QMSI.
72  * @retval 0 on success.
73  * @retval Negative @ref errno for possible error codes.
74  */
75 int qm_ss_timer_set(const qm_ss_timer_t timer, const uint32_t count);
76 
77 /**
78  * Get SS timer count value.
79  *
80  * Get the current count value of the SS timer.
81  *
82  * @param[in] timer Which SS timer to get the count of.
83  * @param[out] count Current value of timer. This must not be NULL.
84  *
85  * @return Standard errno return type for QMSI.
86  * @retval 0 on success.
87  * @retval Negative @ref errno for possible error codes.
88  */
89 int qm_ss_timer_get(const qm_ss_timer_t timer, uint32_t *const count);
90 
91 /*
92  * Save SS TIMER context.
93  *
94  * Save the configuration of the specified TIMER peripheral
95  * before entering sleep.
96  *
97  * @param[in] timer SS TIMER index.
98  * @param[out] ctx SS TIMER context structure. This must not be NULL.
99  *
100  * @return Standard errno return type for QMSI.
101  * @retval 0 on success.
102  * @retval Negative @ref errno for possible error codes.
103  */
104 int qm_ss_timer_save_context(const qm_ss_timer_t timer,
105  qm_ss_timer_context_t *const ctx);
106 
107 /*
108  * Restore SS TIMER context.
109  *
110  * Restore the configuration of the specified TIMER peripheral
111  * after exiting sleep.
112  *
113  * @param[in] timer SS TIMER index.
114  * @param[in] ctx SS TIMER context structure. This must not be NULL.
115  *
116  * @return Standard errno return type for QMSI.
117  * @retval 0 on success.
118  * @retval Negative @ref errno for possible error codes.
119  */
120 int qm_ss_timer_restore_context(const qm_ss_timer_t timer,
121  const qm_ss_timer_context_t *const ctx);
122 
123 /**
124  * @}
125  */
126 
127 #endif /* __QM_SS_TIMER_H__ */
bool inc_run_only
Increments in run state only.
Definition: qm_ss_timer.h:32
int qm_ss_timer_get(const qm_ss_timer_t timer, uint32_t *const count)
Get SS timer count value.
Definition: qm_ss_timer.c:59
qm_ss_timer_t
Sensor Subsystem Timers.
uint32_t count
Final count value.
Definition: qm_ss_timer.h:34
bool watchdog_mode
Watchdog mode.
Definition: qm_ss_timer.h:22
Sensor Subsystem Timer Configuration Type.
Definition: qm_ss_timer.h:21
int qm_ss_timer_set_config(const qm_ss_timer_t timer, const qm_ss_timer_config_t *const cfg)
Set the SS timer configuration.
Definition: qm_ss_timer.c:29
int qm_ss_timer_set(const qm_ss_timer_t timer, const uint32_t count)
Set SS timer count value.
Definition: qm_ss_timer.c:50
bool int_en
Interrupt enable.
Definition: qm_ss_timer.h:33
void * callback_data
Callback user data.
Definition: qm_ss_timer.h:44