Steen Jørgensen / MCP4261

Fork of MCP4261 by TeamElectronics

Embed: (wiki syntax)

« Back to documentation index

MCP4261 Class Reference

MCP4261 Class Reference

Interface to the 7/8-Bit Single/Dual SPI Digital POT with Non-Volatile Memory. More...

#include <MCP4261.h>

Public Member Functions

 MCP4261 (SPI &spi, PinName nCs, PinName nWP, PinName nSHDN)
 Create an instance of the MCP4261 connected via specfied SPI instance.
 MCP4261 (SPI &spi, PinName nCs, PinName nWP)
 Create an instance of the MCP4261 connected via specfied SPI instance (use wthen SHDN is linked to Global reset).
int read (char address)
 Read an Address.
void write (char address, int data)
 Write to Address.
void inc (bool number)
 Increment wiper.
void dec (bool number)
 Decrement wiper.
int status ()
 Read the Status register.
int tcon ()
 Read the tcon register.
void tcon (int data)
 write to tcon register.
int wiper (bool number)
 Read the Volatile Wiper.
void wiper (bool number, int data)
 write to Volatile Wiper.
int nvwiper (bool number)
 Read the non-volatile wiper (Power On Reset start value).
void nvwiper (bool number, int data)
 write to non-volatile wiper (Power On Reset start value).
void shdn (bool act)
 HARDWARE SHUTDOWN PIN (SHDN)
void wp (bool act)
 HARDWARE WRITE PROTECT PIN (WP)

Detailed Description

Interface to the 7/8-Bit Single/Dual SPI Digital POT with Non-Volatile Memory.

Using the driver:

  • remenber to setup SPI in main routine or use pins instance.

Defaults in this driver on start up:

  • as default is HARDWARE WRITE PROTECT PIN "Off".
  • as default is HARDWARE SHUTDOWN PIN "Off".

Definition at line 64 of file MCP4261.h.


Constructor & Destructor Documentation

MCP4261 ( SPI &  spi,
PinName  nCs,
PinName  nWP,
PinName  nSHDN 
)

Create an instance of the MCP4261 connected via specfied SPI instance.

Parameters:
spiThe mbed SPI instance (make in main routine)
nWPThe Hardware Write Protect Control pin.
nSHDNThe Shutdown pin.
nCsThe SPI chip select pin.

Definition at line 30 of file MCP4261.cpp.

MCP4261 ( SPI &  spi,
PinName  nCs,
PinName  nWP 
)

Create an instance of the MCP4261 connected via specfied SPI instance (use wthen SHDN is linked to Global reset).

Parameters:
spiThe mbed SPI instance (make in main routine)
nWPThe Hardware Write Protect Control pin.
nCsThe SPI chip select pin.

Definition at line 35 of file MCP4261.cpp.


Member Function Documentation

void dec ( bool  number )

Decrement wiper.

Parameters:
numberThe selected wiper to decrement.

Definition at line 69 of file MCP4261.cpp.

void inc ( bool  number )

Increment wiper.

Parameters:
numberThe selected wiper to increment.

Definition at line 51 of file MCP4261.cpp.

int nvwiper ( bool  number )

Read the non-volatile wiper (Power On Reset start value).

Parameters:
numberThe wiper number = '0' or '1'
Returns:
The 16 bits read.

Definition at line 133 of file MCP4261.cpp.

void nvwiper ( bool  number,
int  data 
)

write to non-volatile wiper (Power On Reset start value).

Parameters:
numberThe wiper number = '0' or '1'
dataThe 16 bits to write to the register

Definition at line 146 of file MCP4261.cpp.

int read ( char  address )

Read an Address.

Parameters:
addressThe selected register to read from.
Returns:
The 16 bits read.

Definition at line 40 of file MCP4261.cpp.

void shdn ( bool  act )

HARDWARE SHUTDOWN PIN (SHDN)

Parameters:
actSHDN is Active = true and Inactive = false

Definition at line 159 of file MCP4261.cpp.

int status (  )

Read the Status register.

Returns:
The 16 bits read.

Definition at line 88 of file MCP4261.cpp.

int tcon (  )

Read the tcon register.

Returns:
The 16 bits read.

Definition at line 94 of file MCP4261.cpp.

void tcon ( int  data )

write to tcon register.

Parameters:
dataThe 16 bits to write to the register

Definition at line 100 of file MCP4261.cpp.

void wiper ( bool  number,
int  data 
)

write to Volatile Wiper.

Parameters:
numberThe wiper number = '0' or '1'
dataThe 16 bits to write to the register

Definition at line 120 of file MCP4261.cpp.

int wiper ( bool  number )

Read the Volatile Wiper.

Parameters:
numberThe wiper number = '0' or '1'
Returns:
The 16 bits read.

Definition at line 106 of file MCP4261.cpp.

void wp ( bool  act )

HARDWARE WRITE PROTECT PIN (WP)

Parameters:
actWP is Active = true and Inactive = false

Definition at line 165 of file MCP4261.cpp.

void write ( char  address,
int  data 
)

Write to Address.

Parameters:
addressThe selected register to write to.
dataThe 16 bits to write to the register

Definition at line 46 of file MCP4261.cpp.