Control functions for the MCP4x series of digitally controlled potentiometers. Relies on the spihelper.h module.
NOTE: These functions do NOT manipulate any SPI Slave Select pins. Application developers must ensure that the commands these functions transmit via the SPI peripheral reach the intended destination device.
NOTE: By default, these functions will use the asynchronous API of the SPI helper module (i.e. spihelper_request), unless that API has been disabled. To use the synchronous API (i.e. spihelper_exchange_bytes) regardless of whether the asynchronous API is available, define the macro MCP4X_SYNCHRONOUS.
mcp4x.h | Control functions for the MCP4x series of digitally controlled potentiometers. |
Macros | |
MCP4X_P0 | Numeric identifier of the P0 potentiometer in an MCP4x device. |
MCP4X_P1 | Numeric identifier of the P1 potentiometer in an MCP4x device. |
Functions | |
mcp4x_set_wiper | Updates potentiometer wiper settings in the selected MCP4x device. |
mcp4x_shutdown | Disables potentiometers in the selected MCP4x device. |
uint8_t mcp4x_set_wiper( uint8_t pot_bits, uint8_t pos )
Updates potentiometer wiper settings in the selected MCP4x device.
pot_bits | Identifier of the target potentiometer(s) in the destination device. Note that this is a bit mask, where the bit at position n is set in order to target potentiometer n (as identified by an MCP4X_P[n] constant). |
pos | The potentiometer wiper setting. |
A true value if and only if the operation was successfully initiated (in asynchronous mode) or completed (in synchronous mode).
uint8_t mcp4x_shutdown( uint8_t pot_bits )
Disables potentiometers in the selected MCP4x device.
pot_bits | Identifier of the target potentiometer(s) in the destination device. Note that this is a bit mask, where the bit at position n is set in order to target potentiometer n (as identified by an MCP4X_P[n] constant). |
A true value if and only if the operation was successfully initiated (in asynchronous mode) or completed (in synchronous mode).
Updates potentiometer wiper settings in the selected MCP4x device.
uint8_t mcp4x_set_wiper( uint8_t pot_bits, uint8_t pos )
Disables potentiometers in the selected MCP4x device.
uint8_t mcp4x_shutdown( uint8_t pot_bits )
Initiates an SPI request operation consisting of a transmit phase followed by a receive phase.
spi_state spihelper_request( uint8_t n_out, volatile const uint8_t * bfr_out, uint8_t n_in, uint8_t offset_in, volatile uint8_t * bfr_in )
Synchronously exchanges a single pair of bytes via the SPI peripheral.
uint8_t spihelper_exchange_bytes( uint8_t data_out )