Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
qm_pic_timer.h
1 /*
2 * {% copyright %}
3 */
4 
5 #ifndef __QM_PIC_TIMER_H__
6 #define __QM_PIC_TIMER_H__
7 
8 #include "qm_common.h"
9 #include "qm_soc_regs.h"
10 
11 /**
12  * PIC timer.
13  *
14  * @defgroup groupPICTimer PIC Timer
15  * @{
16  */
17 
18 /**
19  * PIC timer mode type.
20  */
21 typedef enum {
22  QM_PIC_TIMER_MODE_ONE_SHOT, /**< One shot mode. */
23  QM_PIC_TIMER_MODE_PERIODIC /**< Periodic mode. */
25 
26 /**
27  * PIC timer configuration type.
28  */
29 typedef struct {
30  qm_pic_timer_mode_t mode; /**< Operation mode. */
31  bool int_en; /**< Interrupt enable. */
32 
33  /**
34  * User callback.
35  *
36  * @param[in] data User defined data.
37  */
38  void (*callback)(void *data);
39  void *callback_data; /**< Callback user data. */
41 
42 /**
43  * Set the PIC timer configuration.
44  *
45  * Set the PIC timer configuration.
46  * This includes timer mode and if interrupts are enabled. If interrupts are
47  * enabled, it will configure the callback function.
48  *
49  * @param[in] cfg PIC timer configuration. This must not be NULL.
50  *
51  * @return Standard errno return type for QMSI.
52  * @retval 0 on success.
53  * @retval Negative @ref errno for possible error codes.
54  */
56 
57 /**
58  * Set the current count value of the PIC timer.
59  *
60  * Set the current count value of the PIC timer.
61  * A value equal to 0 effectively stops the timer.
62  *
63  * @param[in] count Value to load the timer with.
64  *
65  * @return Standard errno return type for QMSI.
66  * @retval Always returns 0.
67  * @retval Negative @ref errno for possible error codes.
68  */
69 int qm_pic_timer_set(const uint32_t count);
70 
71 /**
72  * Get the current count value of the PIC timer.
73  *
74  * @param[out] count Pointer to the store the timer count.
75  * This must not be NULL.
76  *
77  * @return Standard errno return type for QMSI.
78  * @retval 0 on success.
79  * @retval Negative @ref errno for possible error codes.
80  */
81 int qm_pic_timer_get(uint32_t *const count);
82 
83 /**
84  * Save PIC Timer peripheral's context.
85  *
86  * Saves the configuration of the specified PIC Timer peripheral
87  * before entering sleep.
88  *
89  * @param[out] ctx PIC Timer context structure. This must not be NULL.
90  *
91  * @return Standard errno return type for QMSI.
92  * @retval 0 on success.
93  * @retval Negative @ref errno for possible error codes.
94  */
96 
97 /**
98  * Restore PIC Timer peripheral's context.
99  *
100  * Restore the configuration of the specified PIC Timer peripheral
101  * after exiting sleep.
102  * The timer is restored to the count saved before sleep.
103  *
104  * @param[in] ctx PIC Timer context structure. This must not be NULL.
105  *
106  * @return Standard errno return type for QMSI.
107  * @retval 0 on success.
108  * @retval Negative @ref errno for possible error codes.
109  */
111 
112 /**
113  * @}
114  */
115 
116 #endif /* __QM_PIC_TIMER_H__ */
PIC TIMER context type.
Definition: qm_soc_regs.h:283
int qm_pic_timer_set(const uint32_t count)
Set the current count value of the PIC timer.
Definition: qm_pic_timer.c:69
qm_pic_timer_mode_t
PIC timer mode type.
Definition: qm_pic_timer.h:21
int qm_pic_timer_restore_context(const qm_pic_timer_context_t *const ctx)
Restore PIC Timer peripheral's context.
Definition: qm_pic_timer.c:116
bool int_en
Interrupt enable.
Definition: qm_pic_timer.h:31
int qm_pic_timer_get(uint32_t *const count)
Get the current count value of the PIC timer.
Definition: qm_pic_timer.c:76
qm_pic_timer_mode_t mode
Operation mode.
Definition: qm_pic_timer.h:30
int qm_pic_timer_set_config(const qm_pic_timer_config_t *const cfg)
Set the PIC timer configuration.
Definition: qm_pic_timer.c:41
PIC timer configuration type.
Definition: qm_pic_timer.h:29
int qm_pic_timer_save_context(qm_pic_timer_context_t *const ctx)
Save PIC Timer peripheral's context.
Definition: qm_pic_timer.c:109
void * callback_data
Callback user data.
Definition: qm_pic_timer.h:39