42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
68#define MCP16331INV_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
74 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
81#define MCP16331INV_RETVAL uint8_t
83#define MCP16331INV_OK 0x00
84#define MCP16331INV_INIT_ERROR 0xFF
92#define MCP16331INV_ENABLE_VIN_PULL_UP 1
93#define MCP16331INV_DISABLE_VIN_PULL_UP 0
100#define MCP16331INV_GAIN_1X_VREF 1
101#define MCP16331INV_GAIN_2X_VREF 0
108#define MCP16331INV_ACTIVE_MODE 1
109#define MCP16331INV_SHUTDOWN_MODE 0
116#define MCP16331INV_MIN_2715_MV_1X_GAIN 0x0000
117#define MCP16331INV_2900_MV_1X_GAIN 0x00F5
118#define MCP16331INV_3000_MV_1X_GAIN 0x017A
119#define MCP16331INV_3100_MV_1X_GAIN 0x01FE
120#define MCP16331INV_3300_MV_1X_GAIN 0x02FE
121#define MCP16331INV_3500_MV_1X_GAIN 0x03FF
122#define MCP16331INV_3700_MV_1X_GAIN 0x04FF
123#define MCP16331INV_3900_MV_1X_GAIN 0x05FF
124#define MCP16331INV_4000_MV_1X_GAIN 0x0690
125#define MCP16331INV_4300_MV_1X_GAIN 0x0810
126#define MCP16331INV_5000_MV_1X_GAIN 0x0BAE
127#define MCP16331INV_5200_MV_1X_GAIN 0x0CAF
128#define MCP16331INV_5300_MV_1X_GAIN 0x0D3F
129#define MCP16331INV_MAX_5400_MV_1X_GAIN 0x0FFF
136#define MCP16331INV_MIN_2715_MV_2X_GAIN 0x0000
137#define MCP16331INV_3000_MV_2X_GAIN 0x00B8
138#define MCP16331INV_3500_MV_2X_GAIN 0x01FF
139#define MCP16331INV_3900_MV_2X_GAIN 0x02FF
140#define MCP16331INV_4400_MV_2X_GAIN 0x044F
141#define MCP16331INV_4800_MV_2X_GAIN 0x0558
142#define MCP16331INV_4900_MV_2X_GAIN 0x0590
143#define MCP16331INV_5000_MV_2X_GAIN 0x05D0
144#define MCP16331INV_5300_MV_2X_GAIN 0x0690
145#define MCP16331INV_MAX_5400_MV_2X_GAIN 0x0FFF
#define MCP16331INV_RETVAL
Definition mcp16331inv.h:81
MCP16331INV_RETVAL mcp16331inv_init(mcp16331inv_t *ctx, mcp16331inv_cfg_t *cfg)
Initialization function.
void mcp16331inv_enable_vin(mcp16331inv_t *ctx, uint8_t state)
VIN Pull Up enable function.
void mcp16331inv_set_dac_vout(mcp16331inv_t *ctx, uint16_t dac_value, uint8_t gain_value, uint8_t mode)
DAC output voltage set function.
void mcp16331inv_generic_transfer(mcp16331inv_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void mcp16331inv_cfg_setup(mcp16331inv_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition mcp16331inv.h:179
uint8_t spi_mode
Definition mcp16331inv.h:195
spi_master_chip_select_polarity_t cs_polarity
Definition mcp16331inv.h:196
pin_name_t sck
Definition mcp16331inv.h:184
pin_name_t mosi
Definition mcp16331inv.h:183
uint32_t spi_speed
Definition mcp16331inv.h:194
pin_name_t miso
Definition mcp16331inv.h:182
pin_name_t rst
Definition mcp16331inv.h:190
pin_name_t an
Definition mcp16331inv.h:189
pin_name_t cs
Definition mcp16331inv.h:185
Click ctx object definition.
Definition mcp16331inv.h:158
digital_out_t cs
Definition mcp16331inv.h:162
spi_master_t spi
Definition mcp16331inv.h:170
digital_in_t an
Definition mcp16331inv.h:166
digital_out_t rst
Definition mcp16331inv.h:161
pin_name_t chip_select
Definition mcp16331inv.h:171