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
169#if (DAC_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
175#if (DAC_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
181#if defined(DAC_DRIVER_EXT_FIELDS)
182 DAC_DRIVER_EXT_FIELDS
209#define dacIsBufferComplete(dacp) ((bool)((dacp)->state == DAC_COMPLETE))
211#if (DAC_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
224#define _dac_wait_s(dacp) osalThreadSuspendS(&(dacp)->thread)
233#define _dac_reset_i(dacp) osalThreadResumeI(&(dacp)->thread, MSG_RESET)
242#define _dac_reset_s(dacp) osalThreadResumeS(&(dacp)->thread, MSG_RESET)
251#define _dac_wakeup_isr(dacp) { \
252 osalSysLockFromISR(); \
253 osalThreadResumeI(&(dacp)->thread, MSG_OK); \
254 osalSysUnlockFromISR(); \
264#define _dac_timeout_isr(dacp) { \
265 osalSysLockFromISR(); \
266 osalThreadResumeI(&(dacp)->thread, MSG_TIMEOUT); \
267 osalSysUnlockFromISR(); \
271#define _dac_wait_s(dacp)
272#define _dac_reset_i(dacp)
273#define _dac_reset_s(dacp)
274#define _dac_wakeup_isr(dacp)
275#define _dac_timeout_isr(dacp)
290#define _dac_isr_half_code(dacp) { \
291 if ((dacp)->grpp->end_cb != NULL) { \
292 (dacp)->grpp->end_cb(dacp); \
309#define _dac_isr_full_code(dacp) { \
310 if ((dacp)->grpp->end_cb) { \
311 (dacp)->state = DAC_COMPLETE; \
312 (dacp)->grpp->end_cb(dacp); \
313 if ((dacp)->state == DAC_COMPLETE) \
314 (dacp)->state = DAC_ACTIVE; \
316 _dac_wakeup_isr(dacp); \
334#define _dac_isr_error_code(dacp, err) { \
335 dac_lld_stop_conversion(dacp); \
336 if ((dacp)->grpp->error_cb != NULL) { \
337 (dacp)->state = DAC_ERROR; \
338 (dacp)->grpp->error_cb(dacp, err); \
339 if ((dacp)->state == DAC_ERROR) \
340 (dacp)->state = DAC_READY; \
342 (dacp)->grpp = NULL; \
343 _dac_timeout_isr(dacp); \
367#if DAC_USE_SYNCHRONIZATION
373#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.
int32_t msg_t
Type of a message.
uint32_t sysinterval_t
Type of system time interval.
void * thread_reference_t
Type of a thread reference.
uint32_t mutex_t
Type of a mutex.
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.