28#ifndef MAGNETICROTARY5_H
29#define MAGNETICROTARY5_H
39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
73#define MAGNETICROTARY5_CMD_WRITE_CONFIG 0x17
74#define MAGNETICROTARY5_CMD_SET_MT_COUNTER 0x14
75#define MAGNETICROTARY5_CMD_EN_PROG 0x10
76#define MAGNETICROTARY5_CMD_RD_MT_COUNTER 0x04
77#define MAGNETICROTARY5_CMD_RD_ANGLE 0x00
78#define MAGNETICROTARY5_CMD_WRITE_OTP 0x1F
79#define MAGNETICROTARY5_CMD_PROG_OTP 0x19
80#define MAGNETICROTARY5_CMD_READ_OTP 0x0F
81#define MAGNETICROTARY5_CMD_READ_ANA 0x09
99#define MAGNETICROTARY5_MASK_AGC_BITS 0x3F
100#define MAGNETICROTARY5_MASK_ANGLE_MSB 0x01
101#define MAGNETICROTARY5_MASK_MT_CNT_MSB 0x01FE
102#define MAGNETICROTARY5_MASK_MT_CNT_LSB 0x01
103#define MAGNETICROTARY5_MASK_5_LSB 0x1F
104#define MAGNETICROTARY5_MASK_3_LSB 0x07
105#define MAGNETICROTARY5_MAX_DATA_LEN 8
106#define MAGNETICROTARY5_MIN_DATA_LEN 1
107#define MAGNETICROTARY5_MAX_MT_CNT 255
108#define MAGNETICROTARY5_MIN_MT_CNT (-256)
109#define MAGNETICROTARY5_DEFAULT_MT_CNT 0
115#define MAGNETICROTARY5_VREF_3V3 3.3
116#define MAGNETICROTARY5_VREF_5V 5.0
134#define MAGNETICROTARY5_MAP_MIKROBUS( cfg, mikrobus ) \
135 cfg.dio = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
136 cfg.ddclk = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
137 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
138 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN );
err_t magneticrotary5_set_mt_cnt(magneticrotary5_t *ctx, int16_t mt_cnt)
Magnetic Rotary 5 set multi turn counter function.
err_t magneticrotary5_read_raw_adc(magneticrotary5_t *ctx, uint16_t *raw_adc)
Magnetic Rotary 5 read raw ADC value function.
err_t magneticrotary5_read_angle(magneticrotary5_t *ctx, uint8_t *agc, uint16_t *angle)
Magnetic Rotary 5 read angle function.
err_t magneticrotary5_init(magneticrotary5_t *ctx, magneticrotary5_cfg_t *cfg)
Magnetic Rotary 5 initialization function.
err_t magneticrotary5_read_cmd(magneticrotary5_t *ctx, uint8_t cmd, uint8_t *data_out, uint8_t len)
Magnetic Rotary 5 read cmd function.
err_t magneticrotary5_read_mt_cnt(magneticrotary5_t *ctx, int16_t *mt_cnt)
Magnetic Rotary 5 read multi turn counter function.
err_t magneticrotary5_default_cfg(magneticrotary5_t *ctx)
Magnetic Rotary 5 default configuration function.
err_t magneticrotary5_set_vref(magneticrotary5_t *ctx, float vref)
Magnetic Rotary 5 set vref function.
void magneticrotary5_cfg_setup(magneticrotary5_cfg_t *cfg)
Magnetic Rotary 5 configuration object setup function.
err_t magneticrotary5_read_voltage(magneticrotary5_t *ctx, float *voltage)
Magnetic Rotary 5 read voltage level function.
err_t magneticrotary5_write_cmd(magneticrotary5_t *ctx, uint8_t cmd, uint8_t *data_in, uint8_t len)
Magnetic Rotary 5 write cmd function.
magneticrotary5_return_value_t
Magnetic Rotary 5 Click return value data.
Definition magneticrotary5.h:178
@ MAGNETICROTARY5_OK
Definition magneticrotary5.h:179
@ MAGNETICROTARY5_ERROR
Definition magneticrotary5.h:180
Magnetic Rotary 5 Click configuration object.
Definition magneticrotary5.h:162
analog_in_resolution_t resolution
Definition magneticrotary5.h:168
float vref
Definition magneticrotary5.h:169
pin_name_t dio
Definition magneticrotary5.h:165
pin_name_t an
Definition magneticrotary5.h:166
pin_name_t cs
Definition magneticrotary5.h:164
pin_name_t ddclk
Definition magneticrotary5.h:163
Magnetic Rotary 5 Click context object.
Definition magneticrotary5.h:148
digital_out_t cs
Definition magneticrotary5.h:150
digital_out_t ddclk
Definition magneticrotary5.h:149
pin_name_t dio
Definition magneticrotary5.h:151
analog_in_t adc
Definition magneticrotary5.h:153