42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_spi_master.h"
66#define AMMETER_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
77#define AMMETER_RETVAL uint8_t
79#define AMMETER_OK 0x00
80#define AMMETER_INIT_ERROR 0xFF
87#define AMMETER_SAMPLE_NUM 10
88#define AMMETER_FILTER_USEFULL_DATA 0x1FFE
89#define AMMETER_CALC_COEF 1024.0
90#define AMMETER_STABULISATION_COEF 2.0
#define AMMETER_RETVAL
Definition ammeter.h:77
float ammeter_get_avg_data(ammeter_t *ctx)
Get average average data function.
float ammeter_amperage(ammeter_t *ctx)
Get amperage function.
uint16_t ammeter_get_raw_data(ammeter_t *ctx)
Get raw data function.
uint16_t ammeter_data_read(ammeter_t *ctx)
Data read function.
void ammeter_cfg_setup(ammeter_cfg_t *cfg)
Config Object Initialization function.
AMMETER_RETVAL ammeter_init(ammeter_t *ctx, ammeter_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition ammeter.h:118
spi_master_chip_select_polarity_t cs_polarity
Definition ammeter.h:130
pin_name_t sck
Definition ammeter.h:123
spi_master_mode_t spi_mode
Definition ammeter.h:129
pin_name_t mosi
Definition ammeter.h:122
uint32_t spi_speed
Definition ammeter.h:128
pin_name_t miso
Definition ammeter.h:121
pin_name_t cs
Definition ammeter.h:124
Click ctx object definition.
Definition ammeter.h:104
digital_out_t cs
Definition ammeter.h:105
spi_master_t spi
Definition ammeter.h:109
pin_name_t chip_select
Definition ammeter.h:110