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 MCP73213_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 )
79#define MCP73213_RETVAL uint8_t
81#define MCP73213_OK 0x00
82#define MCP73213_INIT_ERROR 0xFF
89#define MCP73213_SPI_CMD_READ 0x0C
90#define MCP73213_SPI_CMD_WRITE 0x00
97#define MCP73213_VOLATILE_WIPER_0 0x00
98#define MCP73213_VOLATILE_WIPER_1 0x01
99#define MCP73213_NON_VOLATILE_WIPER_0 0x02
100#define MCP73213_NON_VOLATILE_WIPER_1 0x03
101#define MCP73213_VOLATILE_TCON_REGISTER 0x04
102#define MCP73213_STATUS_REGISTER 0x05
103#define MCP73213_DATA_EEPROM_6 0x06
104#define MCP73213_DATA_EEPROM_7 0x07
105#define MCP73213_DATA_EEPROM_8 0x08
106#define MCP73213_DATA_EEPROM_9 0x09
107#define MCP73213_DATA_EEPROM_A 0x0A
108#define MCP73213_DATA_EEPROM_B 0x0B
109#define MCP73213_DATA_EEPROM_C 0x0C
110#define MCP73213_DATA_EEPROM_D 0x0D
111#define MCP73213_DATA_EEPROM_E 0x0E
112#define MCP73213_DATA_EEPROM_F 0x0F
120#define P73213_VREF_3V3 3.30
121#define P73213_VREF_5V 5.00
128#define MCP73213_OUTPUT_130_mA 0x00
129#define MCP73213_OUTPUT_250_mA 0x82
130#define MCP73213_OUTPUT_550_mA 0xCC
131#define MCP73213_OUTPUT_1100_mA 0xE9
#define MCP73213_RETVAL
Definition mcp73213.h:79
void mcp73213_cfg_setup(mcp73213_cfg_t *cfg)
Config Object Initialization function.
uint8_t mcp73213_get_status(mcp73213_t *ctx)
Get the status register data function.
void mcp73213_generic_transfer(mcp73213_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void mcp73213_write_data(mcp73213_t *ctx, uint8_t command, uint8_t write_data)
Generic write 8-bit data function.
void mcp73213_set_current_output(mcp73213_t *ctx, uint8_t out_data)
Set values for output current function.
uint8_t mcp73213_read_data(mcp73213_t *ctx, uint8_t command)
Generic read 8-bit data function.
MCP73213_RETVAL mcp73213_init(mcp73213_t *ctx, mcp73213_cfg_t *cfg)
Initialization function.
float mcp73213_convert_output(uint8_t value_adc, float v_ref)
Convert ADC value to volatage.
Click configuration structure definition.
Definition mcp73213.h:159
spi_master_chip_select_polarity_t cs_polarity
Definition mcp73213.h:171
pin_name_t sck
Definition mcp73213.h:164
spi_master_mode_t spi_mode
Definition mcp73213.h:170
pin_name_t mosi
Definition mcp73213.h:163
uint32_t spi_speed
Definition mcp73213.h:169
pin_name_t miso
Definition mcp73213.h:162
pin_name_t cs
Definition mcp73213.h:165
Click ctx object definition.
Definition mcp73213.h:145
digital_out_t cs
Definition mcp73213.h:146
spi_master_t spi
Definition mcp73213.h:150
pin_name_t chip_select
Definition mcp73213.h:151