aboutsummaryrefslogtreecommitdiffstats
path: root/os/io/templates
diff options
context:
space:
mode:
Diffstat (limited to 'os/io/templates')
-rw-r--r--os/io/templates/adc_lld.c42
-rw-r--r--os/io/templates/adc_lld.h40
2 files changed, 37 insertions, 45 deletions
diff --git a/os/io/templates/adc_lld.c b/os/io/templates/adc_lld.c
index 0f3246cf0..f8fdb609a 100644
--- a/os/io/templates/adc_lld.c
+++ b/os/io/templates/adc_lld.c
@@ -49,11 +49,11 @@ void adc_lld_init(void) {
/**
* @brief Configures and activates the ADC peripheral.
*
- * @param[in] adcp pointer to the @p ADCDriver object
+ * @param[in] adcp pointer to the @p ADCDriver object
*/
void adc_lld_start(ADCDriver *adcp) {
- if (adcp->spd_state == ADC_STOP) {
+ if (adcp->adc_state == ADC_STOP) {
/* Clock activation.*/
}
/* Configuration.*/
@@ -62,7 +62,7 @@ void adc_lld_start(ADCDriver *adcp) {
/**
* @brief Deactivates the ADC peripheral.
*
- * @param[in] adcp pointer to the @p ADCDriver object
+ * @param[in] adcp pointer to the @p ADCDriver object
*/
void adc_lld_stop(ADCDriver *adcp) {
@@ -70,21 +70,47 @@ void adc_lld_stop(ADCDriver *adcp) {
/**
* @brief Starts an ADC conversion.
+ * @details Starts a conversion operation, there are two kind of conversion
+ * modes:
+ * - <b>LINEAR</b>, this mode is activated when the @p callback
+ * parameter is set to @p NULL, in this mode the buffer is filled
+ * once and then the conversion stops automatically.
+ * - <b>CIRCULAR</b>, when a callback function is defined the
+ * conversion never stops and the buffer is filled circularly.
+ * During the conversion the callback function is invoked when
+ * the buffer is 50% filled and when the buffer is 100% filled,
+ * this way is possible to process the conversion stream in real
+ * time. This kind of conversion can only be stopped by explicitly
+ * invoking @p adcStopConversion().
+ * .
*
- * @param[in] adcp pointer to the @p ADCDriver object
- * @param[in] grpp pointer to a @p ADCConversionGroup object
- * @param[out] samples pointer to the samples buffer
+ * @param[in] adcp pointer to the @p ADCDriver object
+ * @param[in] grpp pointer to a @p ADCConversionGroup object
+ * @param[out] samples pointer to the samples buffer
+ * @param[in] depth buffer depth (matrix rows number). The buffer depth
+ * must be one or an even number.
+ * @param[in] callback pointer to the conversion callback function
+ * @return The operation status.
+ * @retval FALSE the conversion has been started.
+ * @retval TRUE the driver is busy, conversion not started.
+ *
+ * @note The buffer is organized as a matrix of M*N elements where M is the
+ * channels number configured into the conversion group and N is the
+ * buffer depth. The samples are sequentially written into the buffer
+ * with no gaps.
*/
void adc_lld_start_conversion(ADCDriver *adcp,
ADCConversionGroup *grpp,
- void *samples) {
+ void *samples,
+ size_t depth,
+ adccallback_t callback) {
}
/**
* @brief Stops an ongoing conversion.
*
- * @param[in] adcp pointer to the @p ADCDriver object
+ * @param[in] adcp pointer to the @p ADCDriver object
*/
void adc_lld_stop_conversion(ADCDriver *adcp) {
diff --git a/os/io/templates/adc_lld.h b/os/io/templates/adc_lld.h
index 6fde9c181..db67a65cd 100644
--- a/os/io/templates/adc_lld.h
+++ b/os/io/templates/adc_lld.h
@@ -35,20 +35,6 @@
/* Driver constants. */
/*===========================================================================*/
-/**
- * @brief Linear buffering mode.
- * @details In the linear buffering mode the buffer is filled one time and
- * then the operation automatically stops.
- */
-#define ADC_GROUP_BUFFER_LINEAR 0
-
-/**
- * @brief Circular buffering mode.
- * @details In the circular buffering mode the buffer is filled one time and
- * then the operation automatically starts again.
- */
-#define ADC_GROUP_BUFFER_CIRCULAR 1
-
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -83,31 +69,9 @@ typedef void (*adccallback_t)(adcsample_t *buffer,
*/
typedef struct {
/**
- * @brief Group mode flags.
- */
- uint_least8_t acg_mode;
-
- /**
* @brief Number of the analog channels belonging to the conversion group.
*/
adc_channels_num_t acg_num_channels;
-
- /**
- * @brief Samples buffer depth.
- * @note The buffer depth must be an even number or one. The 50% callback
- * behavior for buffers with odd depth is unspecified.
- */
- adc_buffer_depth_t acg_buffer_depth;
-
- /**
- * @brief Data streaming callback.
- * @details This callback is invoked at 50% and 100% buffer fill level in
- * order to allow realtime processing of the conversion results
- * when the circular buffer mode is selected.
- * @note The 50% callback is only invoked if @p acg_num_samples is greater
- * than 1.
- */
- adccallback_t acg_callback;
} ADCConversionGroup;
/**
@@ -148,7 +112,9 @@ extern "C" {
void adc_lld_stop(ADCDriver *adcp);
void adc_lld_start_conversion(ADCDriver *adcp,
ADCConversionGroup *grpp,
- void *samples);
+ void *samples,
+ size_t depth,
+ adccallback_t callback);
void adc_lld_stop_conversion(ADCDriver *adcp);
#ifdef __cplusplus
}