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 COUNTER_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.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
74 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
81#define COUNTER_RETVAL uint8_t
83#define COUNTER_OK 0x00
84#define COUNTER_INIT_ERROR 0xFF
91#define COUNTER_CMD_CLR 0x00
92#define COUNTER_CMD_WR 0x80
93#define COUNTER_CMD_LOAD 0xC0
94#define COUNTER_CMD_RD 0X40
101#define COUNTER_MDR0 0x08
102#define COUNTER_MDR1 0x10
103#define COUNTER_DTR 0x18
104#define COUNTER_CNTR 0x20
105#define COUNTER_OTR 0x28
106#define COUNTER_STR 0x30
113#define COUNTER_NON_QUAD 0x00
114#define COUNTER_1X_QUAD 0x01
115#define COUNTER_2X_QUAD 0x02
116#define COUNTER_4X_QUAD 0x03
123#define COUNTER_FREE_RUN 0x00
124#define COUNTER_SINGLE_COUNT 0x04
125#define COUNTER_RANGE_LIMIT 0x08
126#define COUNTER_N_MODULE 0x0C
133#define COUNTER_INDEX_DISABLED 0x00
134#define COUNTER_INDEX_LOAD_CNTR 0x10
135#define COUNTER_INDEX_RESET_CNTR 0x20
136#define COUNTER_INDEX_LOAD_OTR 0x30
143#define COUNTER_INDEX_NEG 0x00
144#define COUNTER_INDEX_POS 0x40
150#define COUNTER_FILTER_CLOCK_DIV1 0x00
151#define COUNTER_FILTER_CLOCK_DIV2 0x80
158#define COUNTER_MODE_32 0x00
159#define COUNTER_MODE_24 0x01
160#define COUNTER_MODE_16 0x02
161#define COUNTER_MODE_8 0x03
168#define COUNTER_ENABLE 0x00
169#define COUNTER_DISABLE 0x04
177#define COUNTER_FLAG_DISABLE 0x00
178#define COUNTER_FLAG_IDX 0x10
179#define COUNTER_FLAG_CMP 0x20
180#define COUNTER_FLAG_BW 0x40
181#define COUNTER_FLAG_FY 0x80
#define COUNTER_RETVAL
Definition counter.h:81
void counter_default_cfg(counter_t *ctx)
Click Default Configuration function.
uint8_t get_int_state(counter_t *ctx)
Function for get int-pin state.
void counter_clear_cntr(counter_t *ctx)
Clears CNTR.
void counter_load_cntr(counter_t *ctx)
Loads CNTR from DTR.
void counter_load_otr(counter_t *ctx)
Loads OTR from CNTR.
uint8_t counter_read_mdr1(counter_t *ctx)
Reads MDR1.
uint8_t counter_read_mdr0(counter_t *ctx)
Reads MDR0.
void counter_clead_mrd1(counter_t *ctx)
Clears MDR1.
void counter_clear_str(counter_t *ctx)
Clears STR.
void counter_clear_mrd0(counter_t *ctx)
Clears MDR0.
void counter_generic_transfer(counter_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void counter_write_mdr0(counter_t *ctx, uint8_t settings)
Writes data into MDR0.
void counter_enable(counter_t *ctx)
Enables counting ( Software mode )
int32_t counter_read_otr(counter_t *ctx)
Reads OTR.
void counter_cfg_setup(counter_cfg_t *cfg)
Config Object Initialization function.
uint8_t counter_read_str(counter_t *ctx)
Reads STR.
int32_t counter_read_cntr(counter_t *ctx)
Reads CNTR.
int32_t counter_read_dtr(counter_t *ctx)
Reads DTR.
void counter_write_mdr1(counter_t *ctx, uint8_t settings)
Writes data into MDR1.
void counter_chip_enable(counter_t *ctx)
Enables counting ( Hardware mode )
void counter_disable(counter_t *ctx)
Disables counting ( Software mode )
void counter_chip_disable(counter_t *ctx)
Disables counting ( Hardware mode )
void counter_initialisation(counter_t *ctx)
Initialisation of click board with default settings.
COUNTER_RETVAL counter_init(counter_t *ctx, counter_cfg_t *cfg)
Initialization function.
void counter_init_advanced(counter_t *ctx, uint8_t mdr0_set, uint8_t mdr1_set)
Initialisation of click board with specific settings.
void counter_write_dtr(counter_t *ctx, uint8_t *buffer)
Writes data into DTR.
Click configuration structure definition.
Definition counter.h:220
spi_master_chip_select_polarity_t cs_polarity
Definition counter.h:237
pin_name_t sck
Definition counter.h:225
spi_master_mode_t spi_mode
Definition counter.h:236
pin_name_t mosi
Definition counter.h:224
uint32_t spi_speed
Definition counter.h:235
pin_name_t en
Definition counter.h:230
pin_name_t int_pin
Definition counter.h:231
pin_name_t miso
Definition counter.h:223
pin_name_t cs
Definition counter.h:226
Click ctx object definition.
Definition counter.h:195
digital_out_t cs
Definition counter.h:199
spi_master_t spi
Definition counter.h:207
digital_in_t int_pin
Definition counter.h:203
uint8_t buffer_size
Definition counter.h:212
digital_out_t en
Definition counter.h:198
pin_name_t chip_select
Definition counter.h:208