ChibiOS/HAL 9.0.0
DAC Driver

Generic DAC Driver. More...

Detailed Description

Generic DAC Driver.

This module implements a generic DAC (Digital to Analog Converter) driver.

Precondition
In order to use the DAC driver the HAL_USE_DAC option must be enabled in halconf.h.
Collaboration diagram for DAC Driver:

DAC configuration options

#define DAC_USE_SYNCHRONIZATION   FALSE
 Support for thread synchronization API.
#define DAC_USE_MUTUAL_EXCLUSION   TRUE
 Enables the dacAcquireBus() and dacReleaseBus() APIs.

Low level driver helper macros

#define dacIsBufferComplete(dacp)
 Buffer state.
#define _dac_wait_s(dacp)
 Waits for operation completion.
#define _dac_reset_i(dacp)
 Resumes a thread waiting for a conversion completion.
#define _dac_reset_s(dacp)
 Resumes a thread waiting for a conversion completion.
#define _dac_wakeup_isr(dacp)
 Wakes up the waiting thread.
#define _dac_timeout_isr(dacp)
 Wakes up the waiting thread with a timeout message.
#define _dac_isr_half_code(dacp)
 Common ISR code, half buffer event.
#define _dac_isr_full_code(dacp)
 Common ISR code, full buffer event.
#define _dac_isr_error_code(dacp, err)
 Common ISR code, error event.

Configuration options

#define PLATFORM_DAC_USE_DAC1   FALSE
 DAC1 CH1 driver enable switch.

Data Structures

struct  hal_dac_conversion_group
 DAC Conversion group structure. More...
struct  hal_dac_config
 Driver configuration structure. More...
struct  hal_dac_driver
 Structure representing a DAC driver. More...

Macros

#define DAC_MAX_CHANNELS   2
 Maximum number of DAC channels per unit.
#define dac_lld_driver_fields
 Low level fields of the DAC driver structure.
#define dac_lld_config_fields
 Low level fields of the DAC configuration structure.
#define dac_lld_conversion_group_fields
 Low level fields of the DAC group configuration structure.

Typedefs

typedef struct hal_dac_driver DACDriver
 Type of a structure representing an DAC driver.
typedef struct hal_dac_config DACConfig
 Type of a structure representing an DAC driver configuration.
typedef struct hal_dac_conversion_group DACConversionGroup
 Type of a DAC conversion group.
typedef void(* daccallback_t) (DACDriver *dacp)
 DAC notification callback type.
typedef void(* dacerrorcallback_t) (DACDriver *dacp, dacerror_t err)
 DAC error callback type.
typedef uint32_t dacchannel_t
 Type of a DAC channel index.
typedef uint16_t dacsample_t
 Type representing a DAC sample.

Enumerations

enum  dacstate_t {
  DAC_UNINIT = 0 , DAC_STOP = 1 , DAC_READY = 2 , DAC_ACTIVE = 3 ,
  DAC_COMPLETE = 4 , DAC_ERROR = 5
}
 Driver state machine possible states. More...
enum  dacerror_t { DAC_ERR_DMAFAILURE = 0 , DAC_ERR_UNDERFLOW = 1 }
 Possible DAC failure causes. More...

Functions

void dacInit (void)
 DAC Driver initialization.
void dacObjectInit (DACDriver *dacp)
 Initializes the standard part of a DACDriver structure.
msg_t dacStart (DACDriver *dacp, const DACConfig *config)
 Configures and activates the DAC peripheral.
void dacStop (DACDriver *dacp)
 Deactivates the DAC peripheral.
msg_t dacPutChannelX (DACDriver *dacp, dacchannel_t channel, dacsample_t sample)
 Outputs a value directly on a DAC channel.
msg_t dacStartConversion (DACDriver *dacp, const DACConversionGroup *grpp, dacsample_t *samples, size_t depth)
 Starts a DAC conversion.
msg_t dacStartConversionI (DACDriver *dacp, const DACConversionGroup *grpp, dacsample_t *samples, size_t depth)
 Starts a DAC conversion.
void dacStopConversion (DACDriver *dacp)
 Stops an ongoing conversion.
void dacStopConversionI (DACDriver *dacp)
 Stops an ongoing conversion.
msg_t dacConvert (DACDriver *dacp, const DACConversionGroup *grpp, dacsample_t *samples, size_t depth)
 Performs a DAC conversion.
msg_t dacSynchronizeS (DACDriver *dacp, sysinterval_t timeout)
 Synchronize to a conversion completion.
msg_t dacSynchronize (DACDriver *dacp, sysinterval_t timeout)
 Synchronize to a conversion completion.
void dacAcquireBus (DACDriver *dacp)
 Gains exclusive access to the DAC bus.
void dacReleaseBus (DACDriver *dacp)
 Releases exclusive access to the DAC bus.
void dac_lld_init (void)
 Low level DAC driver initialization.
void dac_lld_start (DACDriver *dacp)
 Configures and activates the DAC peripheral.
void dac_lld_stop (DACDriver *dacp)
 Deactivates the DAC peripheral.
void dac_lld_put_channel (DACDriver *dacp, dacchannel_t channel, dacsample_t sample)
 Outputs a value directly on a DAC channel.
void dac_lld_start_conversion (DACDriver *dacp)
 Starts a DAC conversion.
void dac_lld_stop_conversion (DACDriver *dacp)
 Stops an ongoing conversion.

Variables

DACDriver DACD1
 DAC1 driver identifier.

Macro Definition Documentation

◆ DAC_USE_SYNCHRONIZATION

#define DAC_USE_SYNCHRONIZATION   FALSE

Support for thread synchronization API.

Definition at line 47 of file hal_dac.h.

◆ DAC_USE_MUTUAL_EXCLUSION

#define DAC_USE_MUTUAL_EXCLUSION   TRUE

Enables the dacAcquireBus() and dacReleaseBus() APIs.

Note
Disabling this option saves both code and data space.

Definition at line 58 of file hal_dac.h.

◆ dacIsBufferComplete

#define dacIsBufferComplete ( dacp)
Value:
((bool)((dacp)->state == DAC_COMPLETE))
@ DAC_COMPLETE
Definition hal_dac.h:78

Buffer state.

Note
This function is meant to be called from the DAC callback only.
Parameters
[in]dacppointer to the DACDriver object
Returns
The buffer state.
Return values
falseif the driver filled/sent the first half of the buffer.
trueif the driver filled/sent the second half of the buffer.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 209 of file hal_dac.h.

◆ _dac_wait_s

#define _dac_wait_s ( dacp)
Value:
osalThreadSuspendS(&(dacp)->thread)
msg_t osalThreadSuspendS(thread_reference_t *trp)
Sends the current thread sleeping and sets a reference variable.
Definition osal.c:183

Waits for operation completion.

This function waits for the driver to complete the current operation.

Precondition
An operation must be running while the function is invoked.
Note
No more than one thread can wait on a DAC driver using this function.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 224 of file hal_dac.h.

◆ _dac_reset_i

#define _dac_reset_i ( dacp)
Value:
osalThreadResumeI(&(dacp)->thread, MSG_RESET)
void osalThreadResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Definition osal.c:227
#define MSG_RESET
Definition osal.h:58

Resumes a thread waiting for a conversion completion.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 233 of file hal_dac.h.

Referenced by dacStopConversionI().

◆ _dac_reset_s

#define _dac_reset_s ( dacp)
Value:
osalThreadResumeS(&(dacp)->thread, MSG_RESET)
void osalThreadResumeS(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Definition osal.c:244

Resumes a thread waiting for a conversion completion.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 242 of file hal_dac.h.

Referenced by dacStopConversion().

◆ _dac_wakeup_isr

#define _dac_wakeup_isr ( dacp)
Value:
{ \
osalSysLockFromISR(); \
osalThreadResumeI(&(dacp)->thread, MSG_OK); \
osalSysUnlockFromISR(); \
}
#define MSG_OK
Definition osal.h:56

Wakes up the waiting thread.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 251 of file hal_dac.h.

◆ _dac_timeout_isr

#define _dac_timeout_isr ( dacp)
Value:
{ \
osalSysLockFromISR(); \
osalThreadResumeI(&(dacp)->thread, MSG_TIMEOUT); \
osalSysUnlockFromISR(); \
}
#define MSG_TIMEOUT
Definition osal.h:57

Wakes up the waiting thread with a timeout message.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 264 of file hal_dac.h.

◆ _dac_isr_half_code

#define _dac_isr_half_code ( dacp)
Value:
{ \
if ((dacp)->grpp->end_cb != NULL) { \
(dacp)->grpp->end_cb(dacp); \
} \
}

Common ISR code, half buffer event.

This code handles the portable part of the ISR code:

  • Callback invocation.
Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 290 of file hal_dac.h.

◆ _dac_isr_full_code

#define _dac_isr_full_code ( dacp)
Value:
{ \
if ((dacp)->grpp->end_cb) { \
(dacp)->state = DAC_COMPLETE; \
(dacp)->grpp->end_cb(dacp); \
if ((dacp)->state == DAC_COMPLETE) \
(dacp)->state = DAC_ACTIVE; \
} \
_dac_wakeup_isr(dacp); \
}
@ DAC_ACTIVE
Definition hal_dac.h:77

Common ISR code, full buffer event.

This code handles the portable part of the ISR code:

  • Callback invocation.
  • Driver state transitions.
Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 309 of file hal_dac.h.

◆ _dac_isr_error_code

#define _dac_isr_error_code ( dacp,
err )
Value:
{ \
dac_lld_stop_conversion(dacp); \
if ((dacp)->grpp->error_cb != NULL) { \
(dacp)->state = DAC_ERROR; \
(dacp)->grpp->error_cb(dacp, err); \
if ((dacp)->state == DAC_ERROR) \
(dacp)->state = DAC_READY; \
} \
(dacp)->grpp = NULL; \
_dac_timeout_isr(dacp); \
}
@ DAC_READY
Definition hal_dac.h:76
@ DAC_ERROR
Definition hal_dac.h:79

Common ISR code, error event.

This code handles the portable part of the ISR code:

  • Callback invocation.
  • Waiting thread timeout signalling, if any.
  • Driver state transitions.
Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]dacppointer to the DACDriver object
[in]errplatform dependent error code
Function Class:
Not an API, this function is for internal use only.

Definition at line 334 of file hal_dac.h.

◆ DAC_MAX_CHANNELS

#define DAC_MAX_CHANNELS   2

Maximum number of DAC channels per unit.

Definition at line 37 of file hal_dac_lld.h.

Referenced by dacPutChannelX().

◆ PLATFORM_DAC_USE_DAC1

#define PLATFORM_DAC_USE_DAC1   FALSE

DAC1 CH1 driver enable switch.

If set to TRUE the support for DAC1 channel 1 is included.

Note
The default is FALSE.

Definition at line 53 of file hal_dac_lld.h.

◆ dac_lld_driver_fields

#define dac_lld_driver_fields
Value:
/* Dummy field, it is not needed.*/ \
uint32_t dummy;

Low level fields of the DAC driver structure.

Definition at line 92 of file hal_dac_lld.h.

◆ dac_lld_config_fields

#define dac_lld_config_fields
Value:
/* Dummy configuration, it is not needed.*/ \
uint32_t dummy;

Low level fields of the DAC configuration structure.

Definition at line 99 of file hal_dac_lld.h.

◆ dac_lld_conversion_group_fields

#define dac_lld_conversion_group_fields
Value:
/* Dummy configuration, it is not needed.*/ \
uint32_t dummy;

Low level fields of the DAC group configuration structure.

Definition at line 106 of file hal_dac_lld.h.

Typedef Documentation

◆ DACDriver

typedef struct hal_dac_driver DACDriver

Type of a structure representing an DAC driver.

Definition at line 85 of file hal_dac.h.

◆ DACConfig

typedef struct hal_dac_config DACConfig

Type of a structure representing an DAC driver configuration.

Definition at line 90 of file hal_dac.h.

◆ DACConversionGroup

Type of a DAC conversion group.

Definition at line 95 of file hal_dac.h.

◆ daccallback_t

typedef void(* daccallback_t) (DACDriver *dacp)

DAC notification callback type.

Parameters
[in]dacppointer to the DACDriver object triggering the

Definition at line 106 of file hal_dac.h.

◆ dacerrorcallback_t

typedef void(* dacerrorcallback_t) (DACDriver *dacp, dacerror_t err)

DAC error callback type.

Parameters
[in]dacppointer to the DACDriver object triggering the callback
[in]errDAC error code

Definition at line 115 of file hal_dac.h.

◆ dacchannel_t

typedef uint32_t dacchannel_t

Type of a DAC channel index.

Definition at line 68 of file hal_dac_lld.h.

◆ dacsample_t

typedef uint16_t dacsample_t

Type representing a DAC sample.

Definition at line 73 of file hal_dac_lld.h.

Enumeration Type Documentation

◆ dacstate_t

enum dacstate_t

Driver state machine possible states.

Enumerator
DAC_UNINIT 

Not initialized.

DAC_STOP 

Stopped.

DAC_READY 

Ready.

DAC_ACTIVE 

Exchanging data.

DAC_COMPLETE 

Asynchronous operation complete.

DAC_ERROR 

Error.

Definition at line 73 of file hal_dac.h.

◆ dacerror_t

enum dacerror_t

Possible DAC failure causes.

Note
Error codes are architecture dependent and should not relied upon.
Enumerator
DAC_ERR_DMAFAILURE 

DMA operations failure.

DAC_ERR_UNDERFLOW 

DAC overflow condition.

Definition at line 80 of file hal_dac_lld.h.

Function Documentation

◆ dacInit()

void dacInit ( void )

DAC Driver initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:
Object or module nitializer function.

Definition at line 56 of file hal_dac.c.

References dac_lld_init().

Referenced by halInit().

Here is the call graph for this function:

◆ dacObjectInit()

void dacObjectInit ( DACDriver * dacp)

Initializes the standard part of a DACDriver structure.

Parameters
[out]dacppointer to the DACDriver object
Function Class:
Object or module nitializer function.

Definition at line 68 of file hal_dac.c.

References hal_dac_driver::config, DAC_STOP, hal_dac_driver::mutex, osalMutexObjectInit(), hal_dac_driver::state, and hal_dac_driver::thread.

Referenced by dac_lld_init().

Here is the call graph for this function:

◆ dacStart()

msg_t dacStart ( DACDriver * dacp,
const DACConfig * config )

Configures and activates the DAC peripheral.

Parameters
[in]dacppointer to the DACDriver object
[in]configpointer to the DACConfig object, it can be NULL if the low level driver implementation supports a default configuration
Returns
The operation status.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 95 of file hal_dac.c.

References hal_dac_driver::config, dac_lld_start(), DAC_READY, DAC_STOP, HAL_RET_SUCCESS, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and hal_dac_driver::state.

Here is the call graph for this function:

◆ dacStop()

void dacStop ( DACDriver * dacp)

Deactivates the DAC peripheral.

Note
Deactivating the peripheral also enforces a release of the slave select line.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 135 of file hal_dac.c.

References hal_dac_driver::config, dac_lld_stop(), DAC_READY, DAC_STOP, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and hal_dac_driver::state.

Here is the call graph for this function:

◆ dacPutChannelX()

msg_t dacPutChannelX ( DACDriver * dacp,
dacchannel_t channel,
dacsample_t sample )

Outputs a value directly on a DAC channel.

Parameters
[in]dacppointer to the DACDriver object
[in]channelDAC channel number
[in]samplevalue to be output
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 160 of file hal_dac.c.

References DAC_ACTIVE, DAC_COMPLETE, dac_lld_put_channel(), DAC_MAX_CHANNELS, DAC_READY, HAL_RET_SUCCESS, osalDbgAssert, osalDbgCheck, and hal_dac_driver::state.

Here is the call graph for this function:

◆ dacStartConversion()

msg_t dacStartConversion ( DACDriver * dacp,
const DACConversionGroup * grpp,
dacsample_t * samples,
size_t depth )

Starts a DAC conversion.

Starts an asynchronous conversion operation.

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.
Parameters
[in]dacppointer to the DACDriver object
[in]grpppointer to a DACConversionGroup object
[in]samplespointer to the samples buffer
[in]depthbuffer depth (matrix rows number). The buffer depth must be one or an even number.
Returns
The operation status.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 194 of file hal_dac.c.

References dacStartConversionI(), HAL_RET_SUCCESS, osalSysLock(), and osalSysUnlock().

Here is the call graph for this function:

◆ dacStartConversionI()

msg_t dacStartConversionI ( DACDriver * dacp,
const DACConversionGroup * grpp,
dacsample_t * samples,
size_t depth )

Starts a DAC conversion.

Starts an asynchronous conversion operation.

Postcondition
The callbacks associated to the conversion group will be invoked on buffer complete and error events.
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 organised in the buffer with no gaps.
Parameters
[in]dacppointer to the DACDriver object
[in]grpppointer to a DACConversionGroup object
[in]samplespointer to the samples buffer
[in]depthbuffer depth (matrix rows number). The buffer depth must be one or an even number.
Returns
The operation status.
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 230 of file hal_dac.c.

References DAC_ACTIVE, DAC_COMPLETE, DAC_ERROR, dac_lld_start_conversion(), DAC_READY, hal_dac_driver::depth, hal_dac_driver::grpp, HAL_RET_SUCCESS, osalDbgAssert, osalDbgCheck, osalDbgCheckClassI, hal_dac_driver::samples, and hal_dac_driver::state.

Referenced by dacConvert(), and dacStartConversion().

Here is the call graph for this function:

◆ dacStopConversion()

void dacStopConversion ( DACDriver * dacp)

Stops an ongoing conversion.

This function stops the currently ongoing conversion and returns the driver in the DAC_READY state. If there was no conversion being processed then the function does nothing.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 274 of file hal_dac.c.

References _dac_reset_s, DAC_ACTIVE, dac_lld_stop_conversion(), DAC_READY, hal_dac_driver::grpp, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and hal_dac_driver::state.

Here is the call graph for this function:

◆ dacStopConversionI()

void dacStopConversionI ( DACDriver * dacp)

Stops an ongoing conversion.

This function stops the currently ongoing conversion and returns the driver in the DAC_READY state. If there was no conversion being processed then the function does nothing.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 304 of file hal_dac.c.

References _dac_reset_i, DAC_ACTIVE, DAC_COMPLETE, dac_lld_stop_conversion(), DAC_READY, hal_dac_driver::grpp, osalDbgAssert, osalDbgCheck, osalDbgCheckClassI, and hal_dac_driver::state.

Here is the call graph for this function:

◆ dacConvert()

msg_t dacConvert ( DACDriver * dacp,
const DACConversionGroup * grpp,
dacsample_t * samples,
size_t depth )

Performs a DAC conversion.

Performs a synchronous conversion operation.

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 organised in the buffer with no gaps.
Parameters
[in]dacppointer to the DACDriver object
[in]grpppointer to a DACConversionGroup object
[in]samplespointer to the samples buffer
[in]depthbuffer depth (matrix rows number). The buffer depth must be one or an even number.
Returns
The operation result.
Return values
MSG_OKConversion finished.
MSG_RESETThe conversion has been stopped using dacStopConversion() or dacStopConversionI().
MSG_TIMEOUTThe conversion has been stopped because an hardware error.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 345 of file hal_dac.c.

References dacStartConversionI(), HAL_RET_SUCCESS, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), and hal_dac_driver::thread.

Here is the call graph for this function:

◆ dacSynchronizeS()

msg_t dacSynchronizeS ( DACDriver * dacp,
sysinterval_t timeout )

Synchronize to a conversion completion.

Note
This function can only be called by a single thread at time.
Parameters
[in]dacppointer to the DACDriver object
[in]timeoutwait timeout
Returns
The wait result.
Return values
MSG_OKif operation completed without errors.
MSG_TIMEOUTif synchronization request timed out.
MSG_RESETif the conversion has been stopped.
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 378 of file hal_dac.c.

References DAC_ACTIVE, DAC_READY, MSG_OK, osalDbgAssert, osalDbgCheck, osalDbgCheckClassS, osalThreadSuspendTimeoutS(), hal_dac_driver::state, and hal_dac_driver::thread.

Referenced by dacSynchronize().

Here is the call graph for this function:

◆ dacSynchronize()

msg_t dacSynchronize ( DACDriver * dacp,
sysinterval_t timeout )

Synchronize to a conversion completion.

Note
This function can only be called by a single thread at time.
Parameters
[in]dacppointer to the DACDriver object
[in]timeoutwait timeout
Returns
The wait result.
Return values
MSG_OKif operation completed without errors.
MSG_TIMEOUTif synchronization request timed out.
MSG_RESETif the conversion has been stopped.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 410 of file hal_dac.c.

References dacSynchronizeS(), osalSysLock(), and osalSysUnlock().

Here is the call graph for this function:

◆ dacAcquireBus()

void dacAcquireBus ( DACDriver * dacp)

Gains exclusive access to the DAC bus.

This function tries to gain ownership to the DAC bus, if the bus is already being used then the invoking thread is queued.

Precondition
In order to use this function the option DAC_USE_MUTUAL_EXCLUSION must be enabled.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 433 of file hal_dac.c.

References hal_dac_driver::mutex, osalDbgCheck, and osalMutexLock().

Here is the call graph for this function:

◆ dacReleaseBus()

void dacReleaseBus ( DACDriver * dacp)

Releases exclusive access to the DAC bus.

Precondition
In order to use this function the option DAC_USE_MUTUAL_EXCLUSION must be enabled.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 449 of file hal_dac.c.

References hal_dac_driver::mutex, osalDbgCheck, and osalMutexUnlock().

Here is the call graph for this function:

◆ dac_lld_init()

void dac_lld_init ( void )

Low level DAC driver initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 63 of file hal_dac_lld.c.

References DACD1, and dacObjectInit().

Referenced by dacInit().

Here is the call graph for this function:

◆ dac_lld_start()

void dac_lld_start ( DACDriver * dacp)

Configures and activates the DAC peripheral.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 77 of file hal_dac_lld.c.

References DAC_STOP, DACD1, and hal_dac_driver::state.

Referenced by dacStart().

◆ dac_lld_stop()

void dac_lld_stop ( DACDriver * dacp)

Deactivates the DAC peripheral.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 98 of file hal_dac_lld.c.

References DAC_READY, DACD1, and hal_dac_driver::state.

Referenced by dacStop().

◆ dac_lld_put_channel()

void dac_lld_put_channel ( DACDriver * dacp,
dacchannel_t channel,
dacsample_t sample )

Outputs a value directly on a DAC channel.

Parameters
[in]dacppointer to the DACDriver object
[in]channelDAC channel number
[in]samplevalue to be output
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 120 of file hal_dac_lld.c.

Referenced by dacPutChannelX().

◆ dac_lld_start_conversion()

void dac_lld_start_conversion ( DACDriver * dacp)

Starts a DAC conversion.

Starts an asynchronous conversion operation.

Note
In DAC_DHRM_8BIT_RIGHT mode the parameters passed to the callback are wrong because two samples are packed in a single dacsample_t element. This will not be corrected, do not rely on those parameters.
In DAC_DHRM_8BIT_RIGHT_DUAL mode two samples are treated as a single 16 bits sample and packed into a single dacsample_t element. The num_channels must be set to one in the group conversion configuration structure.
Parameters
[in]dacppointer to the DACDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 145 of file hal_dac_lld.c.

Referenced by dacStartConversionI().

◆ dac_lld_stop_conversion()

void dac_lld_stop_conversion ( DACDriver * dacp)

Stops an ongoing conversion.

This function stops the currently ongoing conversion and returns the driver in the DAC_READY state. If there was no conversion being processed then the function does nothing.

Parameters
[in]dacppointer to the DACDriver object
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 160 of file hal_dac_lld.c.

Referenced by dacStopConversion(), and dacStopConversionI().

Variable Documentation

◆ DACD1

DACDriver DACD1

DAC1 driver identifier.

Definition at line 39 of file hal_dac_lld.c.

Referenced by dac_lld_init(), dac_lld_start(), and dac_lld_stop().