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 VOLTMETER_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 )
81#define VOLTMETER_ERROR -1
88#define VOLTMETER_DATA_RESOLUTION 0x0FFF
89#define VOLTMETER_VREF_ISOLATED_GND 17.05f
90#define VOLTMETER_VREF_SHARED_GND 8.525f
91#define VOLTMETER_NUM_ADC_CONVERSIONS 100
92#define VOLTMETER_DATA_OFFSET 15
93#define VOLTMETER_GND_ISO 1
94#define VOLTMETER_GND_SHARED 0
int16_t voltmeter_read_raw_data(voltmeter_t *ctx)
Read raw ADC value function.
err_t voltmeter_init(voltmeter_t *ctx, voltmeter_cfg_t *cfg)
Initialization function.
float voltmeter_calculate_voltage(voltmeter_t *ctx, int16_t raw_adc, uint8_t iso_gnd)
Voltage calculation function.
void voltmeter_cfg_setup(voltmeter_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition voltmeter.h:122
spi_master_chip_select_polarity_t cs_polarity
Definition voltmeter.h:135
pin_name_t sck
Definition voltmeter.h:126
spi_master_mode_t spi_mode
Definition voltmeter.h:134
pin_name_t mosi
Definition voltmeter.h:125
uint32_t spi_speed
Definition voltmeter.h:133
pin_name_t miso
Definition voltmeter.h:124
pin_name_t an
Definition voltmeter.h:130
pin_name_t cs
Definition voltmeter.h:127
Click ctx object definition.
Definition voltmeter.h:108
spi_master_t spi
Definition voltmeter.h:113
digital_in_t an
Definition voltmeter.h:110
pin_name_t chip_select
Definition voltmeter.h:114