Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Analogout hal functions

Analogout hal functions
[Hal]

# Defined behaviour * The function analogout_init initializes the dac_t control structure * The function analogout_write sets the output voltage, specified as a percentage (float) in range [0.0 (GND), 1.0 (VCC)] * The function analogout_write_u16 sets the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)] * The function analogout_read reads the current voltage value on the pin and returns a floating-point value representing the current voltage in range [0.0 (GND), 1.0 (VCC)] * The function analogout_read_u16 reads the current voltage value on the pin and returns the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)] * The accuracy of the DAC is +/- 10% * The DAC operations analogout_write, analogout_write_u16, analogout_read, analogout_read_u16 take less than 20us to complete * The function analogout_free releases the analogout object More...

Modules

 Analogin hal tests
 

The Analogin HAL tests ensure driver conformance to defined behaviour.


Functions

void analogout_init_direct (dac_t *obj, const PinMap *pinmap)
 Initialize the analogout peripheral.
void analogout_init (dac_t *obj, PinName pin)
 Initialize the analogout peripheral.
void analogout_free (dac_t *obj)
 Release the analogout object.
void analogout_write (dac_t *obj, float value)
 Set the output voltage, specified as a percentage (float)
void analogout_write_u16 (dac_t *obj, uint16_t value)
 Set the output voltage, specified as unsigned 16-bit.
float analogout_read (dac_t *obj)
 Read the current voltage value on the pin.
uint16_t analogout_read_u16 (dac_t *obj)
 Read the current voltage value on the pin, as a normalized unsigned 16bit value.
const PinMap * analogout_pinmap (void)
 Get the pins that support analogout.

Detailed Description

# Defined behaviour * The function analogout_init initializes the dac_t control structure * The function analogout_write sets the output voltage, specified as a percentage (float) in range [0.0 (GND), 1.0 (VCC)] * The function analogout_write_u16 sets the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)] * The function analogout_read reads the current voltage value on the pin and returns a floating-point value representing the current voltage in range [0.0 (GND), 1.0 (VCC)] * The function analogout_read_u16 reads the current voltage value on the pin and returns the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)] * The accuracy of the DAC is +/- 10% * The DAC operations analogout_write, analogout_write_u16, analogout_read, analogout_read_u16 take less than 20us to complete * The function analogout_free releases the analogout object

# Undefined behaviour

* analogout_init is called with invalid pin (which does not support analog output function) * Calling other functions before analogout_init


Function Documentation

void analogout_free ( dac_t obj )

Release the analogout object.

Parameters:
objThe analogout object
void analogout_init ( dac_t obj,
PinName  pin 
)

Initialize the analogout peripheral.

Configures the pin used by analogout.

Parameters:
objThe analogout object to initialize
pinThe analogout pin name
void analogout_init_direct ( dac_t obj,
const PinMap *  pinmap 
)

Initialize the analogout peripheral.

Configures the pin used by analogout.

Parameters:
objThe analogout object to initialize
pinmappointer to structure which holds static pinmap

Definition at line 50 of file static_pinmap.cpp.

const PinMap* analogout_pinmap ( void   )

Get the pins that support analogout.

Return a PinMap array of pins that support analogout. The array is terminated with {NC, NC, 0}.

Returns:
PinMap array
float analogout_read ( dac_t obj )

Read the current voltage value on the pin.

Parameters:
objThe analogin object
Returns:
A floating-point value representing the current voltage on the pin, measured as a percentage
uint16_t analogout_read_u16 ( dac_t obj )

Read the current voltage value on the pin, as a normalized unsigned 16bit value.

Parameters:
objThe analogin object
Returns:
An unsigned 16-bit value representing the current voltage on the pin
void analogout_write ( dac_t obj,
float  value 
)

Set the output voltage, specified as a percentage (float)

Parameters:
objThe analogin object
valueThe floating-point output voltage to be set
void analogout_write_u16 ( dac_t obj,
uint16_t  value 
)

Set the output voltage, specified as unsigned 16-bit.

Parameters:
objThe analogin object
valueThe unsigned 16-bit output voltage to be set