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"
55#include "drv_analog_in.h"
68#define GAINAMP2_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.vout = MIKROBUS( mikrobus, MIKROBUS_AN )
80#define GAINAMP2_RETVAL uint8_t
86#define GAINAMP2_OK 0x00
87#define GAINAMP2_INIT_ERROR 0xFF
94#define GAINAMP2_NOP_INS 0x00
95#define GAINAMP2_SHUTDOWN_INS 0x20
96#define GAINAMP2_WRITE_INS 0x40
103#define GAINAMP2_CH 0x01
104#define GAINAMP2_GAIN 0x00
111#define GAINAMP2_GAIN_1X 0x00
112#define GAINAMP2_GAIN_2X 0x01
113#define GAINAMP2_GAIN_4X 0x02
114#define GAINAMP2_GAIN_5X 0x03
115#define GAINAMP2_GAIN_8X 0x04
116#define GAINAMP2_GAIN_10X 0x05
117#define GAINAMP2_GAIN_16X 0x06
118#define GAINAMP2_GAIN_32X 0x07
125#define GAINAMP2_CH0 0x00
126#define GAINAMP2_CH1 0x01
127#define GAINAMP2_CH2 0x02
128#define GAINAMP2_CH3 0x03
129#define GAINAMP2_CH4 0x04
130#define GAINAMP2_CH5 0x05
#define GAINAMP2_RETVAL
Definition gainamp2.h:80
GAINAMP2_RETVAL gainamp2_init(gainamp2_t *ctx, gainamp2_cfg_t *cfg)
Initialization function.
void gainamp2_set_channel_gain(gainamp2_t *ctx, uint8_t channel, uint8_t gain)
Set the channel gain.
float gainamp2_get_voltage(gainamp2_t *ctx)
Return voltage measured from OUT pin.
void gainamp2_cfg_setup(gainamp2_cfg_t *cfg)
Config Object Initialization function.
void gainamp2_write_command(gainamp2_t *ctx, uint8_t instruction, uint8_t input)
Send Command.
void gainamp2_generic_transfer(gainamp2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
Click configuration structure definition.
Definition gainamp2.h:163
analog_in_resolution_t resolution
Definition gainamp2.h:177
float vref
Definition gainamp2.h:178
spi_master_chip_select_polarity_t cs_polarity
Definition gainamp2.h:181
pin_name_t sck
Definition gainamp2.h:168
spi_master_mode_t spi_mode
Definition gainamp2.h:180
pin_name_t mosi
Definition gainamp2.h:167
uint32_t spi_speed
Definition gainamp2.h:179
pin_name_t vout
Definition gainamp2.h:173
pin_name_t miso
Definition gainamp2.h:166
pin_name_t cs
Definition gainamp2.h:169
Click ctx object definition.
Definition gainamp2.h:144
digital_out_t cs
Definition gainamp2.h:147
spi_master_t spi
Definition gainamp2.h:151
float vref
Definition gainamp2.h:155
pin_name_t chip_select
Definition gainamp2.h:152
analog_in_t adc
Definition gainamp2.h:153