version 2.8
gadc_driver.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.org/license.html
6  */
7 
8 /**
9  * @file src/gadc/gadc_driver.h
10  * @brief GADC - Periodic ADC driver header file.
11  *
12  * @defgroup GADC_Driver Driver
13  * @ingroup GADC
14  *
15  * @brief Driver interface for the GADC module.
16  *
17  * @{
18  */
19 
20 #ifndef _GADC_LLD_H
21 #define _GADC_LLD_H
22 
23 #include "../../gfx.h"
24 
25 #if GFX_USE_GADC || defined(__DOXYGEN__)
26 
27 /*===========================================================================*/
28 /* Type definitions */
29 /*===========================================================================*/
30 
31 /**
32  * @brief The structure passed to start a timer conversion
33  * @{
34  */
35 typedef struct GadcTimerJob_t {
36  uint32_t physdev; // @< The physical device/s. The exact meaning of physdev is hardware dependent.
37  uint32_t frequency; // @< The frequency to sample
38  adcsample_t *buffer; // @< Where to put the samples
39  size_t todo; // @< How many conversions to do
40  size_t done; // @< How many conversions have already been done
41 } GadcTimerJob;
42 /** @} */
43 
44 /**
45  * @brief The structure passed to do a single conversion
46  * @{
47  */
48 typedef struct GadcNonTimerJob_t {
49  uint32_t physdev; // @< The physical device/s. The exact meaning of physdev is hardware dependent.
50  adcsample_t *buffer; // @< Where to put the samples.
52 /** @} */
53 
54 /*===========================================================================*/
55 /* External declarations. */
56 /*===========================================================================*/
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /**
63  * @brief These routines are the callbacks that the driver uses.
64  * @details Defined in the high level GADC code.
65  *
66  * @notapi
67  * @{
68  */
69  /**
70  * @brief Indicate that some data has been placed into the buffer for the current job
71  *
72  * @param[in] n The number of samples placed in the buffer
73  *
74  * @note Calling this with n = 0 causes the current job to be terminated early or aborted.
75  * It can be called in this mode on an ADC conversion error. Any job will then be
76  * restarted by the high level code as appropriate.
77  */
78  void gadcGotDataI(size_t n);
79 /**
80  * @}
81  */
82 
83 /**
84  * @brief Initialise the driver
85  *
86  * @api
87  */
88 void gadc_lld_init(void);
89 
90 /**
91  * @brief Using the hardware dependant "physdev", return the number of samples for each conversion
92  *
93  * @param[in] physdev The hardware dependent physical device descriptor
94  *
95  * @return The number of samples per conversion
96  *
97  * @api
98  */
99 size_t gadc_lld_samplesperconversion(uint32_t physdev);
100 
101 /**
102  * @brief Start a periodic timer for high frequency conversions.
103  *
104  * @param[in] freq The frequency for the timer
105  *
106  * @note This will only be called if the timer is currently stopped.
107  *
108  * @api
109  * @iclass
110  */
111 void gadc_lld_start_timerI(uint32_t freq);
112 
113 /**
114  * @brief Stop the periodic timer for high frequency conversions.
115  *
116  * @note This will only be called if the timer is currently running and all timer jobs
117  * have been completed/aborted.
118  *
119  * @api
120  * @iclass
121  */
122 void gadc_lld_stop_timerI(void);
123 
124 /**
125  * @brief Start a set of high frequency conversions.
126  *
127  * @note This will only be called if the timer is currently running and the ADC should be ready for
128  * a new job.
129  *
130  * @param[in] pjob The job to be started.
131  *
132  * @api
133  * @iclass
134  */
135 void gadc_lld_timerjobI(GadcTimerJob *pjob);
136 
137 /**
138  * @brief Start a non-timer conversion.
139  *
140  * @note This will only be called if the ADC should be ready for a new job.
141  *
142  * @param[in] pjob The job to be started
143  *
144  * @api
145  * @iclass
146  */
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* GFX_USE_GADC */
154 
155 #endif /* _GADC_LLD_H */
156 /** @} */
The structure passed to start a timer conversion.
Definition: gadc_driver.h:35
struct GadcNonTimerJob_t GadcNonTimerJob
The structure passed to do a single conversion.
void gadc_lld_timerjobI(GadcTimerJob *pjob)
Start a set of high frequency conversions.
void gadc_lld_start_timerI(uint32_t freq)
Start a periodic timer for high frequency conversions.
void gadcGotDataI(size_t n)
These routines are the callbacks that the driver uses.
The structure passed to do a single conversion.
Definition: gadc_driver.h:48
size_t gadc_lld_samplesperconversion(uint32_t physdev)
Using the hardware dependant "physdev", return the number of samples for each conversion.
void gadc_lld_init(void)
Initialise the driver.
struct GadcTimerJob_t GadcTimerJob
The structure passed to start a timer conversion.
void gadc_lld_stop_timerI(void)
Stop the periodic timer for high frequency conversions.
void gadc_lld_nontimerjobI(GadcNonTimerJob *pjob)
Start a non-timer conversion.