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

Table 5-1. 
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.

Version: SPI Digi POT MCP41HV51 Driver Version 1.0.0
5.4.1.1.2 Functions

5.4.1.2 Function Documentation

5.4.1.2.1 MCP41HV51_Disable()

void MCP41HV51_Disable (void )

Disables the SPI Digi POT MCP41HV51.

Precondition:

An SPI Host driver is generated.

Parameters:
None.
Returns:

None.

5.4.1.2.2 MCP41HV51_Enable()

void MCP41HV51_Enable (void )

Enables the SPI Digi POT MCP41HV51.

Precondition:

An SPI Host driver is generated.

Parameters:
None.
Returns:

None.

5.4.1.2.3 MCP41HV51_HardwareShutdownDisable()

void MCP41HV51_HardwareShutdownDisable (void )

Removes the SPI Digi POT MCP41HV51 from Hardware Shutdown mode.

Precondition:

An SPI Host driver is generated.

Parameters:
None.
Returns:

None.

5.4.1.2.4 MCP41HV51_HardwareShutdownEnable()

void MCP41HV51_HardwareShutdownEnable (void )

Forces the SPI Digi POT MCP41HV51 into Hardware Shutdown mode.

Precondition:

An SPI Host driver is generated.

Parameters:
None.
Returns:

None.

5.4.1.2.5 MCP41HV51_Initialize()

void MCP41HV51_Initialize (void )

Initializes the SPI Digi POT MCP41HV51.

Precondition:

An SPI Host driver is generated.

Parameters:
None.
Returns:

None.

5.4.1.2.6 MCP41HV51_Read()

void MCP41HV51_Read (uint8_t * buffer, uint8_t bufferSize)

Reads from the SPI Digi POT MCP41HV51.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
uint8_t

*buffer - Pointer to a user-defined buffer that will contain the data bytes received.

uint8_t

bufferSize - Number of data bytes to be received.

Returns:

None.

5.4.1.2.7 MCP41HV51_TconRegRead()

uint8_t MCP41HV51_TconRegRead (void )

Reads from the SPI Digi POT MCP41HV51 TCON register.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
None.
Returns:

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.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
uint8_t

data - Data to be written to the TCON register.

Returns:

None.

5.4.1.2.9 MCP41HV51_Wiper0Decrement()

void MCP41HV51_Wiper0Decrement (void )

Decrements the SPI Digi POT MCP41HV51 Wiper0 register.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
None.
Returns:

None.

5.4.1.2.10 MCP41HV51_Wiper0Increment()

void MCP41HV51_Wiper0Increment (void )

Increments the SPI Digi POT MCP41HV51 Wiper0 register.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
None.
Returns:

None.

5.4.1.2.11 MCP41HV51_Wiper0Read()

uint8_t MCP41HV51_Wiper0Read (void )

Reads from the SPI Digi POT MCP41HV51 Wiper0 register.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
None.
Returns:

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.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
uint8_t

data - Data to be written to the Wiper0 register.

Returns:

None.

5.4.1.2.13 MCP41HV51_Write()

void MCP41HV51_Write (uint8_t * buffer, uint8_t bufferSize)

Writes to the SPI Digi POT MCP41HV51.

Precondition:

An SPI Host driver is generated, and SPI Digi POT MCP41HV51 is initialized.

Parameters:
uint8_t

*buffer

uint8_t

bufferSize

Returns:

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

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.3 Detailed Description

This file provides configuration constants for the SPI Digi POT MCP41HV51 driver.

SPI Digi POT MCP41HV51 Generated Driver Config Header File

Version: SPI Digi POT MCP41HV51 Driver Version 1.0.0

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

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

Version: SPI Digi POT MCP41HV51 Driver Version 1.0.0

5.5.3.4 Variable Documentation

5.5.3.4.1 cmdByte

uint8_t cmdByte = 0x00