Interface: moteiv.tos.sensorboards.invent.AD524X

interface AD524X

The AD524X interface provides commands for using the Analog Devices AD524X family of potentiometers.

The lower 2 bits (AD1 and AD0) must be provided as the address. The full address may be provided as well, but all other bits will be stripped (addr = addr & 0x03)

Author:
Joe Polastre, Moteiv Corporation <info@moteiv.com>

Commands
command bool getOutput(uint8_t addr, bool output, ad524x_type_t type) Get the value of an output pin.
command result_t getPot(uint8_t addr, bool rdac, ad524x_type_t type) Get the value of an RDAC
command result_t setOutput(uint8_t addr, bool output, bool high, ad524x_type_t type) Set the value of one of the output pins.
command result_t setPot(uint8_t addr, bool rdac, uint8_t value, ad524x_type_t type) Set the value of an RDAC
command result_t start(uint8_t addr, ad524x_type_t type) Start the AD5242 device.
command result_t stop(uint8_t addr, ad524x_type_t type) Stop the AD5242 device.

Events
event void getPotDone(uint8_t addr, bool rdac, uint8_t value, result_t result, ad524x_type_t type) Result of the get operation with the value of the RDAC potentiometer.
event void setOutputDone(uint8_t addr, bool output, result_t result, ad524x_type_t type) Notification that the state of an output pin may have changed.
event void setPotDone(uint8_t addr, bool rdac, result_t result, ad524x_type_t type) Notification that RDAC may be set to a new value
event void startDone(uint8_t addr, result_t result, ad524x_type_t type) Notification that there was an attempt to set the SD bit.
event void stopDone(uint8_t addr, result_t result, ad524x_type_t type) Notification that there was an attempt to clear the SD bit.

Commands - Details

getOutput

command bool getOutput(uint8_t addr, bool output, ad524x_type_t type)

Get the value of an output pin.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
output - FALSE for O1, TRUE for 02
type - of device -- only some AD524X devices have outputs
Returns:
TRUE if the bit is set, FALSE otherwise

getPot

command result_t getPot(uint8_t addr, bool rdac, ad524x_type_t type)

Get the value of an RDAC

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
rdac - FALSE for RDAC1, TRUE for RDAC2
type - The device type
Returns:
SUCCESS if the request was accepted

setOutput

command result_t setOutput(uint8_t addr, bool output, bool high, ad524x_type_t type)

Set the value of one of the output pins.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
high - TRUE if O should be set, FALSE if it should be cleared
output - FALSE if O1 should be used, TRUE for 02
Type - of device -- only some AD524X devices have outputs
Returns:
SUCCESS if the request was accepted

setPot

command result_t setPot(uint8_t addr, bool rdac, uint8_t value, ad524x_type_t type)

Set the value of an RDAC

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
rdac - FALSE for RDAC1, TRUE for RDAC2 if exits parameter ignored if type != AD5242
value - A 256-bit value corresponding to the wiper position For 128-bit pots, the value must be *left* justified (the LSB will be discarded)
Returns:
SUCCESS if the request was accepted

start

command result_t start(uint8_t addr, ad524x_type_t type)

Start the AD5242 device. This sets the SD bit to enable the device via the I2C bus. This command does not alter the physical shutdown pin of the device. The StdControl interface is responsible for the physical shutdown of the device.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
type - Type of address -- only some AD524X devices can be started
Returns:
SUCCESS if the request was accepted

stop

command result_t stop(uint8_t addr, ad524x_type_t type)

Stop the AD5242 device. This clears the SD bit to enable the device via the I2C bus. This command does not alter the physical shutdown pin of the device. The StdControl interface is responsible for the physical shutdown of the device.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
type - Type of address -- only some AD524X devices can be stopped
Returns:
SUCCESS if the request was accepted

Events - Details

getPotDone

event void getPotDone(uint8_t addr, bool rdac, uint8_t value, result_t result, ad524x_type_t type)

Result of the get operation with the value of the RDAC potentiometer.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
rdac - The potentiometer that qas requested
value - A 256-bit value corresponding to the wiper position For 128-bit potentiometers, value is left-justified (shifted left by 1 bit)
result - SUCCESS if the value was correctly obtained from the device. If FAIL is returned, the value is not valid.
type - The type of the device

setOutputDone

event void setOutputDone(uint8_t addr, bool output, result_t result, ad524x_type_t type)

Notification that the state of an output pin may have changed.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
output - FALSE for O1, TRUE for O2
result - SUCCESS if the output O was successfully changed
Type - of device -- only some AD524X devices have outputs

setPotDone

event void setPotDone(uint8_t addr, bool rdac, result_t result, ad524x_type_t type)

Notification that RDAC may be set to a new value

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
SUCCESS - if the value of RDAC was changed

startDone

event void startDone(uint8_t addr, result_t result, ad524x_type_t type)

Notification that there was an attempt to set the SD bit.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
result - SUCCESS if the bit was actually set, FAIL if the device could not be reached or the operation failed
type - Type of device

stopDone

event void stopDone(uint8_t addr, result_t result, ad524x_type_t type)

Notification that there was an attempt to clear the SD bit.

Parameters:
addr - Lower 2 bits (AD1,AD0) of the device I2C address
result - SUCCESS if the bit was actually cleared, FAIL if the device could not be reached or the operation failed
type - Type of device