libeasymcp2221 2.0.3
Classes | Macros | Functions
mcp2221_sram.h File Reference

Runtime SRAM configuration for GPIO, analog references, clock, and IOC. More...

#include <stdint.h>
#include "mcp2221.h"
Include dependency graph for mcp2221_sram.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mcp2221_sram_gp_config_t
 SRAM configuration for one MCP2221 GP pin. More...
 
struct  mcp2221_sram_int_config_t
 Interrupt-on-change SRAM configuration. More...
 
struct  mcp2221_sram_adc_config_t
 ADC voltage-reference SRAM configuration. More...
 
struct  mcp2221_sram_dac_ref_config_t
 DAC voltage-reference SRAM configuration. More...
 
struct  mcp2221_sram_dac_value_config_t
 DAC output-code SRAM configuration. More...
 
struct  mcp2221_sram_clock_config_t
 Clock-output SRAM configuration. More...
 
struct  mcp2221_sram_config_t
 Aggregated runtime SRAM configuration. More...
 

Macros

#define MCP2221_CONFIG_KEEP   (-1)
 Preserve the current value of an SRAM configuration field. More...
 

Functions

mcp2221_error_code_t mcp2221_sram_config (mcp2221_t *dev, const mcp2221_sram_config_t *cfg)
 Apply a runtime SRAM configuration. More...
 

Detailed Description

Runtime SRAM configuration for GPIO, analog references, clock, and IOC.

Definition in file mcp2221_sram.h.

Macro Definition Documentation

◆ MCP2221_CONFIG_KEEP

#define MCP2221_CONFIG_KEEP   (-1)

Preserve the current value of an SRAM configuration field.

Use this sentinel for fields in mcp2221_sram_config_t that should remain unchanged.

Note
This sentinel is specific to the SRAM configuration API. GPIO output updates use MCP2221_GPIO_KEEP instead.

Definition at line 24 of file mcp2221_sram.h.

Function Documentation

◆ mcp2221_sram_config()

mcp2221_error_code_t mcp2221_sram_config ( mcp2221_t dev,
const mcp2221_sram_config_t cfg 
)

Apply a runtime SRAM configuration.

The function validates all fields, reads the current device SRAM state, and applies the requested changes while preserving fields set to MCP2221_CONFIG_KEEP.

GPIO configuration is merged with the library's cached GPIO state when available so that output changes made through the GPIO API are preserved.

Parameters
[in]devOpen MCP2221 device handle.
[in]cfgSRAM configuration to apply. Must not be NULL.
Returns
MCP2221_ERR_OK on success, MCP2221_ERR_INVALID for an invalid argument or unsupported field value, MCP2221_ERR_PROTOCOL for malformed GET SRAM length metadata, or another mcp2221_error_code_t value on failure.
Note
This function changes runtime SRAM settings only. It does not modify persistent MCP2221 flash configuration.