28#if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
45#if !defined(DAC_USE_SYNCHRONIZATION) || defined(__DOXYGEN__)
46#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
47#define DAC_USE_SYNCHRONIZATION FALSE
49#define DAC_USE_SYNCHRONIZATION DAC_USE_WAIT
57#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
58#define DAC_USE_MUTUAL_EXCLUSION TRUE
174#if (DAC_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
180#if (DAC_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
186#if defined(DAC_DRIVER_EXT_FIELDS)
187 DAC_DRIVER_EXT_FIELDS
216#define dacIsBufferComplete(dacp) ((bool)((dacp)->state == DAC_COMPLETE))
218#if (DAC_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
231#define _dac_wait_s(dacp) osalThreadSuspendS(&(dacp)->thread)
240#define _dac_reset_i(dacp) osalThreadResumeI(&(dacp)->thread, MSG_RESET)
249#define _dac_reset_s(dacp) osalThreadResumeS(&(dacp)->thread, MSG_RESET)
258#define _dac_wakeup_isr(dacp) { \
259 osalSysLockFromISR(); \
260 osalThreadResumeI(&(dacp)->thread, MSG_OK); \
261 osalSysUnlockFromISR(); \
271#define _dac_timeout_isr(dacp) { \
272 osalSysLockFromISR(); \
273 osalThreadResumeI(&(dacp)->thread, MSG_TIMEOUT); \
274 osalSysUnlockFromISR(); \
278#define _dac_wait_s(dacp)
279#define _dac_reset_i(dacp)
280#define _dac_reset_s(dacp)
281#define _dac_wakeup_isr(dacp)
282#define _dac_timeout_isr(dacp)
297#define _dac_isr_half_code(dacp) { \
298 if ((dacp)->grpp->end_cb != NULL) { \
299 (dacp)->grpp->end_cb(dacp); \
317#define _dac_isr_full_code(dacp) { \
318 if ((dacp)->grpp->end_cb) { \
319 (dacp)->state = DAC_COMPLETE; \
320 (dacp)->grpp->end_cb(dacp); \
321 if ((dacp)->state == DAC_COMPLETE) \
322 (dacp)->state = DAC_ACTIVE; \
324 _dac_wakeup_isr(dacp); \
342#define _dac_isr_error_code(dacp, err) { \
343 dac_lld_stop_conversion(dacp); \
344 if ((dacp)->grpp->error_cb != NULL) { \
345 (dacp)->state = DAC_ERROR; \
346 (dacp)->grpp->error_cb(dacp, err); \
347 if ((dacp)->state == DAC_ERROR) \
348 (dacp)->state = DAC_READY; \
350 (dacp)->grpp = NULL; \
351 _dac_timeout_isr(dacp); \
375#if DAC_USE_SYNCHRONIZATION
381#if DAC_USE_MUTUAL_EXCLUSION
void(* daccallback_t)(DACDriver *dacp)
DAC notification callback type.
msg_t dacSynchronizeS(DACDriver *dacp, sysinterval_t timeout)
Synchronize to a conversion completion.
#define dac_lld_conversion_group_fields
Low level fields of the DAC group configuration structure.
uint16_t dacsample_t
Type representing a DAC sample.
struct hal_dac_driver DACDriver
Type of a structure representing an DAC driver.
void dacStop(DACDriver *dacp)
Deactivates the DAC peripheral.
uint32_t dacchannel_t
Type of a DAC channel index.
msg_t dacStartConversionI(DACDriver *dacp, const DACConversionGroup *grpp, dacsample_t *samples, size_t depth)
Starts a DAC conversion.
void dacReleaseBus(DACDriver *dacp)
Releases exclusive access to the DAC bus.
void dacStopConversion(DACDriver *dacp)
Stops an ongoing conversion.
void dacAcquireBus(DACDriver *dacp)
Gains exclusive access to the DAC bus.
void dacObjectInit(DACDriver *dacp)
Initializes the standard part of a DACDriver structure.
msg_t dacStartConversion(DACDriver *dacp, const DACConversionGroup *grpp, dacsample_t *samples, size_t depth)
Starts a DAC conversion.
void dacInit(void)
DAC Driver initialization.
void(* dacerrorcallback_t)(DACDriver *dacp, dacerror_t err)
DAC error callback type.
void dacStopConversionI(DACDriver *dacp)
Stops an ongoing conversion.
dacerror_t
Possible DAC failure causes.
msg_t dacSynchronize(DACDriver *dacp, sysinterval_t timeout)
Synchronize to a conversion completion.
struct hal_dac_config DACConfig
Type of a structure representing an DAC driver configuration.
msg_t dacStart(DACDriver *dacp, const DACConfig *config)
Configures and activates the DAC peripheral.
dacstate_t
Driver state machine possible states.
msg_t dacPutChannelX(DACDriver *dacp, dacchannel_t channel, dacsample_t sample)
Outputs a value directly on a DAC channel.
#define dac_lld_config_fields
Low level fields of the DAC configuration structure.
#define dac_lld_driver_fields
Low level fields of the DAC driver structure.
struct hal_dac_conversion_group DACConversionGroup
Type of a DAC conversion group.
msg_t dacConvert(DACDriver *dacp, const DACConversionGroup *grpp, dacsample_t *samples, size_t depth)
Performs a DAC conversion.
struct ch_mutex mutex_t
Type of a mutex structure.
thread_t * thread_reference_t
Type of a thread reference.
uint64_t sysinterval_t
Type of time interval.
PLATFORM DAC subsystem low level driver header.
Driver configuration structure.
DAC Conversion group structure.
uint32_t num_channels
Number of DAC channels.
dacerrorcallback_t error_cb
Error handling callback or NULL.
daccallback_t end_cb
Operation complete callback or NULL.
Structure representing a DAC driver.
const DACConversionGroup * grpp
Conversion group.
size_t depth
Samples buffer size.
dacsample_t * samples
Samples buffer pointer.
thread_reference_t thread
Waiting thread.
const DACConfig * config
Current configuration data.
dacstate_t state
Driver state.
mutex_t mutex
Mutex protecting the bus.