5 SPI Digipot MCP41HV51 Driver
Driver library for the MCP41HV51 Digital Potentiometer using the SPI protocol
5.1 Introduction
The MPLAB® Code Configurator Melody SPI Digi POT MCP41HV51 driver allows quick and easy configuration and code generation to enable microcontrollers to interface with the MCP41HV51 Digital Potentiometer using the SPI protocol.
5.2 Supported Device Families
PIC16F | PIC18F | tiny AVR | AVR |
5.3 Required Header Files:
#include "mcc_generated_files/mcp41hv51-digipot/mcp41hv51.h"
5.4 Module Documentation
5.4.1 SPI Digi POT MCP41HV51
This file provides APIs declarations for the SPI Digi POT MCP41HV51 driver.
5.4.1.1 Module description
This file provides APIs declarations for the SPI Digi POT MCP41HV51 driver.
5.4.1.1.1 Enumerations
enum mcp41hv51_cmd { WRITE_DATA, INCREMENT_WIPER, DECREMENT_WIPER, READ_DATA }
SPI Digi POT MCP41HV51 Commands:
5.4.1.1.2 Functions
void MCP41HV51_Initialize (void)
Initializes the SPI Digi POT MCP41HV51.
void MCP41HV51_Wiper0Write (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 Wiper0 register.
uint8_t MCP41HV51_Wiper0Read (void)
Reads from the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_Wiper0Increment (void)
Increments the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_Wiper0Decrement (void)
Decrements the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_TconRegWrite (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 TCON register.
uint8_t MCP41HV51_TconRegRead (void)
Reads from the SPI Digi POT MCP41HV51 TCON register.
void MCP41HV51_Enable (void)
Enables the SPI Digi POT MCP41HV51.
void MCP41HV51_Disable (void)
Disables the SPI Digi POT MCP41HV51.
void MCP41HV51_HardwareShutdownEnable (void)
Forces the SPI Digi POT MCP41HV51 into Hardware Shutdown mode.
void MCP41HV51_HardwareShutdownDisable (void)
Removes the SPI Digi POT MCP41HV51 from Hardware Shutdown mode.
void MCP41HV51_Write (uint8_t *buffer, uint8_t bufferSize)
Writes to the SPI Digi POT MCP41HV51.
void MCP41HV51_Read (uint8_t *buffer, uint8_t bufferSize)
Reads from the SPI Digi POT MCP41HV51.
5.4.1.2 Function Documentation
5.4.1.2.1 MCP41HV51_Disable()
void MCP41HV51_Disable (void )
Disables the SPI Digi POT MCP41HV51.
An SPI Host driver is generated. |
|
None. |
5.4.1.2.2 MCP41HV51_Enable()
void MCP41HV51_Enable (void )
Enables the SPI Digi POT MCP41HV51.
An SPI Host driver is generated. |
|
None. |
5.4.1.2.3 MCP41HV51_HardwareShutdownDisable()
void MCP41HV51_HardwareShutdownDisable (void )
Removes the SPI Digi POT MCP41HV51 from Hardware Shutdown mode.
An SPI Host driver is generated. |
|
None. |
5.4.1.2.4 MCP41HV51_HardwareShutdownEnable()
void MCP41HV51_HardwareShutdownEnable (void )
Forces the SPI Digi POT MCP41HV51 into Hardware Shutdown mode.
An SPI Host driver is generated. |
|
None. |
5.4.1.2.5 MCP41HV51_Initialize()
void MCP41HV51_Initialize (void )
Initializes the SPI Digi POT MCP41HV51.
An SPI Host driver is generated. |
|
None. |
5.4.1.2.6 MCP41HV51_Read()
void MCP41HV51_Read (uint8_t * buffer, uint8_t bufferSize)
Reads from the SPI Digi POT MCP41HV51.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
None. |
5.4.1.2.7 MCP41HV51_TconRegRead()
uint8_t MCP41HV51_TconRegRead (void )
Reads from the SPI Digi POT MCP41HV51 TCON register.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
uint8_t TCON register data. |
5.4.1.2.8 MCP41HV51_TconRegWrite()
void MCP41HV51_TconRegWrite (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 TCON register.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
None. |
5.4.1.2.9 MCP41HV51_Wiper0Decrement()
void MCP41HV51_Wiper0Decrement (void )
Decrements the SPI Digi POT MCP41HV51 Wiper0 register.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
None. |
5.4.1.2.10 MCP41HV51_Wiper0Increment()
void MCP41HV51_Wiper0Increment (void )
Increments the SPI Digi POT MCP41HV51 Wiper0 register.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
None. |
5.4.1.2.11 MCP41HV51_Wiper0Read()
uint8_t MCP41HV51_Wiper0Read (void )
Reads from the SPI Digi POT MCP41HV51 Wiper0 register.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
uint8_t Wiper0 data. |
5.4.1.2.12 MCP41HV51_Wiper0Write()
void MCP41HV51_Wiper0Write (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 Wiper0 register.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
None. |
5.4.1.2.13 MCP41HV51_Write()
void MCP41HV51_Write (uint8_t * buffer, uint8_t bufferSize)
Writes to the SPI Digi POT MCP41HV51.
An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized. |
|
None. |
5.4.1.3 Enumeration Type Documentation
5.4.1.3.1 mcp41hv51_cmd
enum mcp41hv51_cmd
SPI Digi POT MCP41HV51 Commands:
WRITE_DATA | |
INCREMENT_WIPER | |
DECREMENT_WIPER | |
READ_DATA |
5.5 File Documentation
5.5.1 source/mcp41hv51.h File Reference
#include <stdint.h>
5.5.1.1 Functions
void MCP41HV51_Initialize (void)
Initializes the SPI Digi POT MCP41HV51.
void MCP41HV51_Wiper0Write (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 Wiper0 register.
uint8_t MCP41HV51_Wiper0Read (void)
Reads from the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_Wiper0Increment (void)
Increments the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_Wiper0Decrement (void)
Decrements the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_TconRegWrite (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 TCON register.
uint8_t MCP41HV51_TconRegRead (void)
Reads from the SPI Digi POT MCP41HV51 TCON register.
void MCP41HV51_Enable (void)
Enables the SPI Digi POT MCP41HV51.
void MCP41HV51_Disable (void)
Disables the SPI Digi POT MCP41HV51.
void MCP41HV51_HardwareShutdownEnable (void)
Forces the SPI Digi POT MCP41HV51 into Hardware Shutdown mode.
void MCP41HV51_HardwareShutdownDisable (void)
Removes the SPI Digi POT MCP41HV51 from Hardware Shutdown mode.
5.5.1.2 Detailed Description
SPI Digi POT MCP41HV51 Generated Driver Header File
5.5.2 source/mcp41hv51_config.h File Reference
This file provides configuration constants for the SPI Digi POT MCP41HV51 driver.
5.5.2.1 Macros
5.5.2.1.1 Register Setting Macros
SPI Digi POT MCP41HV51 register settings' addresses, bit masks and values:
#define MCP41HV51_ADDR_MASK 0xF0
#define MCP41HV51_CMD_MASK 0x0C
#define MCP41HV51_R0HW_MASK 0x08
#define MCP41HV51_TCON_ADDRESS 0x04
#define MCP41HV51_TCON_POR 0xFF
#define MCP41HV51_WIP0_ADDRESS 0x00
#define MCP41HV51_WIP0_POR 0x7F
#define MCP41HV51_SHUTDOWN_ENABLED 1
#define MCP41HV51_SHUTDOWN_DISABLED 1
5.5.2.2 Enumerations
enum mcp41hv51_cmd { WRITE_DATA, INCREMENT_WIPER, DECREMENT_WIPER, READ_DATA }
SPI Digi POT MCP41HV51 Commands:
5.5.2.3 Detailed Description
This file provides configuration constants for the SPI Digi POT MCP41HV51 driver.
SPI Digi POT MCP41HV51 Generated Driver Config Header File
5.5.2.4 Macro Definition Documentation
5.5.2.4.1 MCP41HV51_ADDR_MASK
#define MCP41HV51_ADDR_MASK 0xF0
5.5.2.4.2 MCP41HV51_CMD_MASK
#define MCP41HV51_CMD_MASK 0x0C
5.5.2.4.3 MCP41HV51_R0HW_MASK
#define MCP41HV51_R0HW_MASK 0x08
5.5.2.4.4 MCP41HV51_SHUTDOWN_DISABLED
#define MCP41HV51_SHUTDOWN_DISABLED 1
5.5.2.4.5 MCP41HV51_SHUTDOWN_ENABLED
#define MCP41HV51_SHUTDOWN_ENABLED 1
5.5.2.4.6 MCP41HV51_TCON_ADDRESS
#define MCP41HV51_TCON_ADDRESS 0x04
5.5.2.4.7 MCP41HV51_TCON_POR
#define MCP41HV51_TCON_POR 0xFF
5.5.2.4.8 MCP41HV51_WIP0_ADDRESS
#define MCP41HV51_WIP0_ADDRESS 0x00
5.5.2.4.9 MCP41HV51_WIP0_POR
#define MCP41HV51_WIP0_POR 0x7F
5.5.3 source/src/mcp41hv51.c File Reference
This file provides APIs definitions for the SPI Digi POT MCP41HV51 driver.
#include "../../mcp41hv51-digipot/mcp41hv51.h" #include "../../mcp41hv51-digipot/mcp41hv51_config.h" #include "../../system/pins.h" #include "../../spi/spi1.h"
5.5.3.1 Functions
void MCP41HV51_Write (uint8_t *buffer, uint8_t bufferSize)
Writes to the SPI Digi POT MCP41HV51.
void MCP41HV51_Read (uint8_t *buffer, uint8_t bufferSize)
Reads from the SPI Digi POT MCP41HV51.
void MCP41HV51_Initialize (void)
Initializes the SPI Digi POT MCP41HV51.
void MCP41HV51_Wiper0Write (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 Wiper0 register.
uint8_t MCP41HV51_Wiper0Read (void)
Reads from the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_Wiper0Increment (void)
Increments the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_Wiper0Decrement (void)
Decrements the SPI Digi POT MCP41HV51 Wiper0 register.
void MCP41HV51_TconRegWrite (uint8_t data)
Writes to the SPI Digi POT MCP41HV51 TCON register.
uint8_t MCP41HV51_TconRegRead (void)
Reads from the SPI Digi POT MCP41HV51 TCON register.
void MCP41HV51_Enable (void)
Enables the SPI Digi POT MCP41HV51.
void MCP41HV51_Disable (void)
Disables the SPI Digi POT MCP41HV51.
void MCP41HV51_HardwareShutdownEnable (void)
Forces the SPI Digi POT MCP41HV51 into Hardware Shutdown mode.
void MCP41HV51_HardwareShutdownDisable (void)
Removes the SPI Digi POT MCP41HV51 from Hardware Shutdown mode.
5.5.3.2 Variables
uint8_t tconReg = MCP41HV51_TCON_POR
uint8_t wip0Reg = MCP41HV51_WIP0_POR
uint8_t cmdByte = 0x00
5.5.3.3 Detailed Description
This file provides APIs definitions for the SPI Digi POT MCP41HV51 driver.
SPI Digi POT MCP41HV51 Generated Driver Source File
5.5.3.4 Variable Documentation
5.5.3.4.1 cmdByte
uint8_t cmdByte = 0x00
5.5.3.4.2 tconReg
uint8_t tconReg = MCP41HV51_TCON_POR
Include Headers
5.5.3.4.3 wip0Reg
uint8_t wip0Reg = MCP41HV51_WIP0_POR