A collection of Analog Devices drivers for the mbed platform
AD5270 Class Reference
Analog Devices AD5270 SPI Digital Rheostat class. More...
#include <AD5270.h>
Public Types | |
enum | AD5270Commands_t { NO_OP = 0x00, NO_OP_cmd = 0x0000, WRITE_RDAC = 0x04, READ_RDAC = 0x08, STORE_50TP = 0x0C, SW_RST = 0x10, READ_50TP_CONTENTS = 0x14, READ_50TP_ADDRESS = 0x18, WRITE_CTRL_REG = 0x1C, READ_CTRL_REG = 0x20, SW_SHUTDOWN = 0x24, HI_Zupper = 0x80, HI_Zlower = 0x01, HI_Z_Cmd = 0x8001 } |
AD5270 commands. More... | |
Public Member Functions | |
AD5270 (PinName CS=SPI_CS, float max_resistance=20000.0, PinName MOSI=SPI_MOSI, PinName MISO=SPI_MISO, PinName SCK=SPI_SCK) | |
AD5270 constructor, sets CS pin and SPI format. | |
void | frequency (int hz) |
Set AD5270 SPI frequency. | |
void | write_ctrl_reg (uint8_t data) |
Writes the control register. | |
uint8_t | read_ctrl_reg (void) |
Reads the control register. | |
void | change_mode (AD5270Modes_t mode) |
Changes the device mode, enabled or shutdown. | |
void | set_SDO_HiZ (void) |
Puts the AD5270 SDO line in to Hi-Z mode. | |
void | reset_RDAC (void) |
Resets the wiper register value to the data last written in the 50TP. | |
void | write_wiper_reg (uint16_t data) |
Writes the wiper register. | |
uint16_t | read_wiper_reg (void) |
Reads the wiper register value. | |
uint16_t | write_cmd (uint8_t command, uint16_t data=0x00, bool toggle_cs=true) |
Issues AD5270 a command. | |
uint16_t | write_reg (uint16_t data, bool toggle_cs=true) |
Writes 16bit data to the AD5270 SPI interface. | |
uint16_t | calc_RDAC (float resistance) |
Compute for the nearest RDAC value from given resistance. | |
float | write_RDAC (float resistance) |
sets a new value for the RDAC | |
float | read_RDAC (void) |
Reads the RDAC register. | |
float | get_max_resistance (void) |
Gets maximum resistance of the AD5270 digital rheostat. | |
void | enable_50TP_programming (void) |
Enables the 50TP memory programming. | |
void | store_50TP (void) |
Stores current RDAC content to the 50TP memory. | |
void | disable_50TP_programming (void) |
Disables the 50TP memory programming. | |
uint8_t | read_50TP_last_address (void) |
Reads the last programmed value of the 50TP memory. | |
uint16_t | read_50TP_memory (uint8_t address) |
Reads the content of a 50TP memory address. | |
Data Fields | |
SPI | ad5270 |
SPI instance of the AD5270. | |
DigitalOut | cs |
DigitalOut instance for the chip select of the AD5270. |
Detailed Description
Analog Devices AD5270 SPI Digital Rheostat class.
Definition at line 56 of file AD5270.h.
Member Enumeration Documentation
enum AD5270Commands_t |
AD5270 commands.
- Enumerator:
NO_OP No data.
NO_OP_cmd 16 bit no data
WRITE_RDAC Write to the RDAC Register.
READ_RDAC Read from the RDAC Register.
STORE_50TP Write from RDAC to memory.
SW_RST Software reset to last memory location.
READ_50TP_CONTENTS Read the last memory contents.
READ_50TP_ADDRESS Read the last memory address.
WRITE_CTRL_REG Write to the control Register.
READ_CTRL_REG Read from the control Register.
SW_SHUTDOWN Software shutdown (0) - Normal, (1) - Shutdown.
HI_Zupper Get the SDO line ready for High Z.
HI_Zlower Puts AD5270 into High Z mode.
HI_Z_Cmd Puts AD5270 into High Z mode*/.
Constructor & Destructor Documentation
AD5270 | ( | PinName | CS = SPI_CS , |
float | max_resistance = 20000.0 , |
||
PinName | MOSI = SPI_MOSI , |
||
PinName | MISO = SPI_MISO , |
||
PinName | SCK = SPI_SCK |
||
) |
AD5270 constructor, sets CS pin and SPI format.
- Parameters:
-
CS - (optional)chip select of the AD5270 max_resistance - (optional) nominal resistance of the AD5270 chip in ohms MOSI - (optional)pin of the SPI interface MISO - (optional)pin of the SPI interface SCK - (optional)pin of the SPI interface
Definition at line 60 of file AD5270.cpp.
Member Function Documentation
uint16_t calc_RDAC | ( | float | resistance ) |
Compute for the nearest RDAC value from given resistance.
- Parameters:
-
resistance - resistor
- Returns:
- RDAC value - closest possible to given resistance
Definition at line 72 of file AD5270.cpp.
void change_mode | ( | AD5270Modes_t | mode ) |
Changes the device mode, enabled or shutdown.
- Parameters:
-
mode - new mode of the device
Definition at line 277 of file AD5270.cpp.
void disable_50TP_programming | ( | void | ) |
Disables the 50TP memory programming.
Definition at line 156 of file AD5270.cpp.
void enable_50TP_programming | ( | void | ) |
Enables the 50TP memory programming.
Definition at line 138 of file AD5270.cpp.
void frequency | ( | int | hz ) |
Set AD5270 SPI frequency.
- Parameters:
-
hz - SPI bus frequency in hz
- Returns:
- none
Definition at line 117 of file AD5270.cpp.
float get_max_resistance | ( | void | ) |
Gets maximum resistance of the AD5270 digital rheostat.
- Returns:
- maximum resistance in ohms
Definition at line 184 of file AD5270.cpp.
uint8_t read_50TP_last_address | ( | void | ) |
Reads the last programmed value of the 50TP memory.
- Returns:
- last programmed value
Definition at line 220 of file AD5270.cpp.
uint16_t read_50TP_memory | ( | uint8_t | address ) |
Reads the content of a 50TP memory address.
- Parameters:
-
address memory to be read
- Returns:
- value stored in the 50TP address
Definition at line 234 of file AD5270.cpp.
uint8_t read_ctrl_reg | ( | void | ) |
Reads the control register.
- Returns:
- value of the control register
Definition at line 256 of file AD5270.cpp.
float read_RDAC | ( | void | ) |
uint16_t read_wiper_reg | ( | void | ) |
Reads the wiper register value.
- Returns:
- value of the wiper register
Definition at line 207 of file AD5270.cpp.
void reset_RDAC | ( | void | ) |
Resets the wiper register value to the data last written in the 50TP.
Definition at line 268 of file AD5270.cpp.
void set_SDO_HiZ | ( | void | ) |
void store_50TP | ( | void | ) |
Stores current RDAC content to the 50TP memory.
Definition at line 147 of file AD5270.cpp.
uint16_t write_cmd | ( | uint8_t | command, |
uint16_t | data = 0x00 , |
||
bool | toggle_cs = true |
||
) |
Issues AD5270 a command.
- Parameters:
-
command - command to be sent data - (optional)value for the requested command
- Returns:
- response form the AD5270
Definition at line 128 of file AD5270.cpp.
void write_ctrl_reg | ( | uint8_t | data ) |
Writes the control register.
- Parameters:
-
data to be written
Definition at line 247 of file AD5270.cpp.
float write_RDAC | ( | float | resistance ) |
sets a new value for the RDAC
- Parameters:
-
resistance new value for the resistance
- Returns:
- actual value of the resistance in the RDAC
Definition at line 82 of file AD5270.cpp.
uint16_t write_reg | ( | uint16_t | data, |
bool | toggle_cs = true |
||
) |
Writes 16bit data to the AD5270 SPI interface.
- Parameters:
-
data to be written
- Returns:
- data returned by the AD5270
Definition at line 167 of file AD5270.cpp.
void write_wiper_reg | ( | uint16_t | data ) |
Writes the wiper register.
This includes reading the control register, setting write protect off, writing the wiper, and reverting the settings to the control reg.
- Parameters:
-
data to be written
Definition at line 195 of file AD5270.cpp.
Field Documentation
Generated on Tue Jul 12 2022 17:59:52 by 1.7.2