2013-02-18 07:33:35 +00:00
|
|
|
/*
|
2013-06-15 11:37:22 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
2013-05-03 14:36:17 +00:00
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2013-07-21 20:20:37 +00:00
|
|
|
* http://ugfx.org/license.html
|
2013-02-18 07:33:35 +00:00
|
|
|
*/
|
|
|
|
|
2013-05-06 04:44:47 +00:00
|
|
|
/**
|
2014-02-18 14:36:52 +00:00
|
|
|
* @file src/gadc/driver.h
|
2013-05-06 04:44:47 +00:00
|
|
|
* @brief GADC - Periodic ADC driver header file.
|
|
|
|
*
|
|
|
|
* @defgroup Driver Driver
|
|
|
|
* @ingroup GADC
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-02-18 07:33:35 +00:00
|
|
|
#ifndef _GADC_LLD_H
|
|
|
|
#define _GADC_LLD_H
|
|
|
|
|
|
|
|
#include "gfx.h"
|
|
|
|
|
|
|
|
#if GFX_USE_GADC || defined(__DOXYGEN__)
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Type definitions */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The structure passed to start a timer conversion
|
|
|
|
* @{
|
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
typedef struct GadcTimerJob_t {
|
|
|
|
uint32_t physdev; // @< The physical device/s. The exact meaning of physdev is hardware dependent.
|
|
|
|
uint32_t frequency; // @< The frequency to sample
|
|
|
|
adcsample_t *buffer; // @< Where to put the samples
|
|
|
|
size_t todo; // @< How many conversions to do
|
|
|
|
size_t done; // @< How many conversions have already been done
|
|
|
|
} GadcTimerJob;
|
2014-05-20 16:05:38 +00:00
|
|
|
/** @} */
|
2013-02-18 07:33:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-03-24 00:08:15 +00:00
|
|
|
* @brief The structure passed to do a single conversion
|
2013-02-18 07:33:35 +00:00
|
|
|
* @{
|
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
typedef struct GadcNonTimerJob_t {
|
|
|
|
uint32_t physdev; // @< The physical device/s. The exact meaning of physdev is hardware dependent.
|
|
|
|
adcsample_t *buffer; // @< Where to put the samples.
|
|
|
|
} GadcNonTimerJob;
|
2014-05-20 16:05:38 +00:00
|
|
|
/** @} */
|
2013-02-18 07:33:35 +00:00
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* External declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2014-03-20 13:41:27 +00:00
|
|
|
* @brief These routines are the callbacks that the driver uses.
|
|
|
|
* @details Defined in the high level GADC code.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2014-03-20 13:41:27 +00:00
|
|
|
* @notapi
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/**
|
2014-03-24 00:08:15 +00:00
|
|
|
* @brief Indicate that some data has been placed into the buffer for the current job
|
|
|
|
*
|
|
|
|
* @param[in] n The number of samples placed in the buffer
|
|
|
|
*
|
|
|
|
* @note Calling this with n = 0 causes the current job to be terminated early or aborted.
|
|
|
|
* It can be called in this mode on an ADC conversion error. Any job will then be
|
|
|
|
* restarted by the high level code as appropriate.
|
2014-03-20 13:41:27 +00:00
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
void gadcGotDataI(size_t n);
|
2014-03-20 13:41:27 +00:00
|
|
|
/**
|
|
|
|
* @}
|
2013-02-18 07:33:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-03-20 13:41:27 +00:00
|
|
|
* @brief Initialise the driver
|
2013-03-10 19:17:24 +00:00
|
|
|
*
|
2013-02-18 07:33:35 +00:00
|
|
|
* @api
|
|
|
|
*/
|
2014-03-20 13:41:27 +00:00
|
|
|
void gadc_lld_init(void);
|
2013-02-18 07:33:35 +00:00
|
|
|
|
2014-03-24 00:08:15 +00:00
|
|
|
/**
|
2014-03-30 04:59:17 +00:00
|
|
|
* @brief Using the hardware dependant "physdev", return the number of samples for each conversion
|
2014-03-24 00:08:15 +00:00
|
|
|
*
|
|
|
|
* @param[in] physdev The hardware dependent physical device descriptor
|
|
|
|
*
|
2014-03-30 04:59:17 +00:00
|
|
|
* @return The number of samples per conversion
|
2014-03-28 19:18:03 +00:00
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
size_t gadc_lld_samplesperconversion(uint32_t physdev);
|
|
|
|
|
2013-02-18 07:33:35 +00:00
|
|
|
/**
|
|
|
|
* @brief Start a periodic timer for high frequency conversions.
|
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @param[in] freq The frequency for the timer
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @note This will only be called if the timer is currently stopped.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
|
|
|
* @api
|
2014-03-24 00:08:15 +00:00
|
|
|
* @iclass
|
2013-02-18 07:33:35 +00:00
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
void gadc_lld_start_timerI(uint32_t freq);
|
2013-02-18 07:33:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Stop the periodic timer for high frequency conversions.
|
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @note This will only be called if the timer is currently running and all timer jobs
|
|
|
|
* have been completed/aborted.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
|
|
|
* @api
|
2014-03-24 00:08:15 +00:00
|
|
|
* @iclass
|
2013-02-18 07:33:35 +00:00
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
void gadc_lld_stop_timerI(void);
|
2013-02-18 07:33:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-03-24 00:08:15 +00:00
|
|
|
* @brief Start a set of high frequency conversions.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @note This will only be called if the timer is currently running and the ADC should be ready for
|
|
|
|
* a new job.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2014-03-30 04:59:17 +00:00
|
|
|
* @param[in] pjob The job to be started.
|
2014-03-28 19:18:03 +00:00
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @api
|
2013-02-18 07:33:35 +00:00
|
|
|
* @iclass
|
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
void gadc_lld_timerjobI(GadcTimerJob *pjob);
|
2013-02-18 07:33:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-03-24 00:08:15 +00:00
|
|
|
* @brief Start a non-timer conversion.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @note This will only be called if the ADC should be ready for a new job.
|
2013-02-18 07:33:35 +00:00
|
|
|
*
|
2014-03-30 04:59:17 +00:00
|
|
|
* @param[in] pjob The job to be started
|
2014-03-28 19:18:03 +00:00
|
|
|
*
|
2014-03-24 00:08:15 +00:00
|
|
|
* @api
|
2013-02-18 07:33:35 +00:00
|
|
|
* @iclass
|
|
|
|
*/
|
2014-03-24 00:08:15 +00:00
|
|
|
void gadc_lld_nontimerjobI(GadcNonTimerJob *pjob);
|
2013-02-18 07:33:35 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* GFX_USE_GADC */
|
|
|
|
|
|
|
|
#endif /* _GADC_LLD_H */
|
|
|
|
/** @} */
|