XBee Firmware Library  1.6.0
Functions
Analog Digital Converter (ADC)

Functions

int adc_ch_enable (xpin_t pin, bool_t enable)
 Enables or disables the ADC channel running in the specified XBee pin. More...
 
uint16_t adc_ch_read (xpin_t pin)
 Reads the value of the ADC channel running in the specified XBee pin. More...
 
int adc_config (uint8_t config)
 Configures the ADC interface settings (all the ADC channels will share the same settings.) More...
 

Detailed Description

Platform-specific layer provides a consistent ADC API to upper layers of the driver.

XBee ADC API Overview

This API contains the functions to configure and control the ADC channels 
of the programmable XBee modules.

The 12-bit analog to digital converter (ADC12) is a successive approximation ADC designer for operation within an integrated microcontroller system-on-chip.

@note       The bandgap channel cannot be converted in low power run mode
            or low power wait mode

- ADC configuration functions:
    - adc_config()
    - adc_ch_enable()

- ADC functions to read values:
    - adc_ch_read()

Platform-specific layer provides a consistent MACROS API to upper layers of the driver.

ADC Macros

The adc_config() function needs as parameter a byte containing the configuration masks for the ADC channels. These masks are defined with macros and they are the following:

 - Macros to configure the \b optimization of the ADC channels:
         - \b ADC_CFG_OPTIMIZE_FOR_SPEED         : Optimizes the ADC channels for
                                                                                   speed.
         - \b ADC_CFG_OPTIMIZE_FOR_POWER         : Optimizes the ADC channels for
                                                                                   power saving.

 - Macros to select the \b mode of the ADC channels:
         - \b ADC_CFG_MODE_8BIT                          : Enables the 8-bits conversion.
         - \b ADC_CFG_MODE_10BIT                         : Enables the 10-bits conversion.
         - \b ADC_CFG_MODE_12BIT                         : Enables the 12-bits conversion.

 - Macros to enable the \b mode \b bit-mask:
         - \b ADC_CFG_MODE_BIT_MASK                      : Enables the bit mask mode.

Usage example:

adc_config(ADC_CFG_OPTIMIZE_FOR_SPEED | ADC_CFG_MODE_8BIT);
Warning
It is recommended not to use these macros, they are used by the XBee Project Smart Editor of the XBee extensions.

Function Documentation

int adc_ch_enable ( xpin_t  pin,
bool_t  enable 
)

Enables or disables the ADC channel running in the specified XBee pin.

Parameters
[in]pinXBee pin configured as ADC channel.
[in]enable1 to enable the ADC channel, 0 to disable it.
Return values
0on success
ERANGEout of range
uint16_t adc_ch_read ( xpin_t  pin)

Reads the value of the ADC channel running in the specified XBee pin.

Parameters
[in]pinXBee pin configured as ADC channel to read data from.
Return values
uint16_tthe value read from the ADC channel.
0xffffif the XBee pin is not configured as ADC channel or there was a timeout error.
int adc_config ( uint8_t  config)

Configures the ADC interface settings (all the ADC channels will share the same settings.)

Parameters
[in]configa byte containing the configuration masks for the ADC channels. See the ADC Macros for more information.
Return values
0on success