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)
command result_t getPot(uint8_t addr, bool rdac, ad524x_type_t type)
command result_t setOutput(uint8_t addr, bool output, bool high, ad524x_type_t type)
command result_t setPot(uint8_t addr, bool rdac, uint8_t value, ad524x_type_t type)
command result_t start(uint8_t addr, ad524x_type_t type)
command result_t stop(uint8_t addr, ad524x_type_t type)
Events
event void getPotDone(uint8_t addr, bool rdac, uint8_t value, result_t result, ad524x_type_t type)
event void setOutputDone(uint8_t addr, bool output, result_t result, ad524x_type_t type)
event void setPotDone(uint8_t addr, bool rdac, result_t result, ad524x_type_t type)
event void startDone(uint8_t addr, result_t result, ad524x_type_t type)
event void stopDone(uint8_t addr, result_t result, ad524x_type_t type)
Commands - Details
getOutput
command bool getOutput(uint8_t addr, bool output, ad524x_type_t type)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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