28#ifndef MAGNETICROTARY2_H
29#define MAGNETICROTARY2_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_spi_master.h"
74#define MAGNETICROTARY2_REG_CUST_RES_0 0x00
75#define MAGNETICROTARY2_REG_CUST_RES_1 0x01
76#define MAGNETICROTARY2_REG_CUST_RES_2 0x02
77#define MAGNETICROTARY2_REG_CUST_RES_3 0x03
78#define MAGNETICROTARY2_REG_CUST_RES_4 0x04
79#define MAGNETICROTARY2_REG_CUST_RES_5 0x05
80#define MAGNETICROTARY2_REG_CUST_RES_6 0x06
81#define MAGNETICROTARY2_REG_CUST_CONFIG_0_MSB 0x07
82#define MAGNETICROTARY2_REG_CUST_CONFIG_0_LSB 0x08
83#define MAGNETICROTARY2_REG_CUST_CONFIG_1_MSB 0x09
84#define MAGNETICROTARY2_REG_CUST_CONFIG_1_LSB 0x0A
85#define MAGNETICROTARY2_REG_CUST_CONFIG_2 0x0B
86#define MAGNETICROTARY2_REG_ZERO_RESET_2 0x0C
87#define MAGNETICROTARY2_REG_ZERO_RESET_1 0x0D
88#define MAGNETICROTARY2_REG_ZERO_RESET_0 0x0E
89#define MAGNETICROTARY2_REG_UNLOCK 0x10
90#define MAGNETICROTARY2_REG_PROGRAM 0x11
91#define MAGNETICROTARY2_REG_CALIBRATION 0x12
92#define MAGNETICROTARY2_REG_ERROR_BITS 0x21
93#define MAGNETICROTARY2_REG_CALIBRATION_STAT 0x22
94#define MAGNETICROTARY2_REG_POSITION 0x3F
112#define MAGNETICROTARY2_UNLOCK_VALUE 0xAB
113#define MAGNETICROTARY2_LOCK_VALUE 0xFF
114#define MAGNETICROTARY2_PROGRAM_VALUE 0xA1
120#define MAGNETICROTARY2_ODD_PARITY 0x01
126#define MAGNETICROTARY2_MSEL1_READ_BIT 0x40
127#define MAGNETICROTARY2_MSEL0_WRITE_BIT 0x80
133#define MAGNETICROTARY2_CC0_MSB_HW_ST_ZERO_EN 0x80
134#define MAGNETICROTARY2_CC0_MSB_HW_ACC_CALIB_EN 0x40
135#define MAGNETICROTARY2_CC0_MSB_AXIS_MODE_OFF 0x20
136#define MAGNETICROTARY2_CC0_MSB_IWIDTH_90 0x00
137#define MAGNETICROTARY2_CC0_MSB_IWIDTH_180 0x04
138#define MAGNETICROTARY2_CC0_MSB_IWIDTH_270 0x08
139#define MAGNETICROTARY2_CC0_MSB_IWIDTH_360 0x0C
140#define MAGNETICROTARY2_CC0_MSB_IPHASE_90 0x00
141#define MAGNETICROTARY2_CC0_MSB_IPHASE_180 0x01
142#define MAGNETICROTARY2_CC0_MSB_IPHASE_270 0x02
143#define MAGNETICROTARY2_CC0_MSB_IPHASE_360 0x03
144#define MAGNETICROTARY2_CC0_LSB_HYST_0_00 0x00
145#define MAGNETICROTARY2_CC0_LSB_HYST_0_01 0x20
146#define MAGNETICROTARY2_CC0_LSB_HYST_0_02 0x40
147#define MAGNETICROTARY2_CC0_LSB_HYST_0_04 0x60
148#define MAGNETICROTARY2_CC0_LSB_HYST_0_08 0x80
149#define MAGNETICROTARY2_CC0_LSB_HYST_0_17 0xA0
150#define MAGNETICROTARY2_CC0_LSB_HYST_0_35 0xC0
151#define MAGNETICROTARY2_CC0_LSB_HYST_0_70 0xE0
152#define MAGNETICROTARY2_CC0_LSB_DIR_CCW 0x10
153#define MAGNETICROTARY2_CC0_LSB_ABS_RES_18BIT 0x00
154#define MAGNETICROTARY2_CC0_LSB_ABS_RES_17BIT 0x01
155#define MAGNETICROTARY2_CC0_LSB_ABS_RES_16BIT 0x02
156#define MAGNETICROTARY2_CC0_LSB_ABS_RES_15BIT 0x03
157#define MAGNETICROTARY2_CC0_LSB_ABS_RES_14BIT 0x04
158#define MAGNETICROTARY2_CC0_LSB_ABS_RES_13BIT 0x05
159#define MAGNETICROTARY2_CC0_LSB_ABS_RES_12BIT 0x06
160#define MAGNETICROTARY2_CC0_LSB_ABS_RES_11BIT 0x07
161#define MAGNETICROTARY2_CC0_LSB_ABS_RES_10BIT 0x08
162#define MAGNETICROTARY2_CC0_LSB_ABS_RES_MASK 0x0F
172#define MAGNETICROTARY2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
173#define MAGNETICROTARY2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
202#define MAGNETICROTARY2_MAP_MIKROBUS( cfg, mikrobus ) \
203 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
204 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
205 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
206 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
magneticrotary2_msel_t
Magnetic Rotary 2 Click driver selector.
Definition magneticrotary2.h:192
@ MAGNETICROTARY2_MSEL_1
Definition magneticrotary2.h:194
@ MAGNETICROTARY2_MSEL_0
Definition magneticrotary2.h:193
err_t magneticrotary2_unlock_eeprom(magneticrotary2_t *ctx)
Magnetic Rotary 2 unlock eeprom function.
err_t magneticrotary2_lock_eeprom(magneticrotary2_t *ctx)
Magnetic Rotary 2 lock eeprom function.
err_t magneticrotary2_write_register(magneticrotary2_t *ctx, uint8_t reg, uint8_t data_in)
Magnetic Rotary 2 write register function.
err_t magneticrotary2_init(magneticrotary2_t *ctx, magneticrotary2_cfg_t *cfg)
Magnetic Rotary 2 initialization function.
err_t magneticrotary2_read_register(magneticrotary2_t *ctx, uint8_t reg, uint8_t *data_out)
Magnetic Rotary 2 read register function.
err_t magneticrotary2_program_eeprom(magneticrotary2_t *ctx)
Magnetic Rotary 2 program eeprom function.
err_t magneticrotary2_get_angle(magneticrotary2_t *ctx, float *angle)
Magnetic Rotary 2 get angle function.
err_t magneticrotary2_default_cfg(magneticrotary2_t *ctx)
Magnetic Rotary 2 default configuration function.
void magneticrotary2_msel_pin_selection(magneticrotary2_cfg_t *cfg, magneticrotary2_msel_t msel)
Magnetic Rotary 2 MSEL pin selection function.
err_t magneticrotary2_get_raw_data(magneticrotary2_t *ctx, uint32_t *data_out)
Magnetic Rotary 2 get raw data function.
void magneticrotary2_cfg_setup(magneticrotary2_cfg_t *cfg)
Magnetic Rotary 2 configuration object setup function.
magneticrotary2_return_value_t
Magnetic Rotary 2 Click return value data.
Definition magneticrotary2.h:253
@ MAGNETICROTARY2_ERROR
Definition magneticrotary2.h:255
@ MAGNETICROTARY2_OK
Definition magneticrotary2.h:254
This file contains SPI specific macros, functions, etc.
Magnetic Rotary 2 Click configuration object.
Definition magneticrotary2.h:233
magneticrotary2_msel_t msel
Definition magneticrotary2.h:244
spi_master_chip_select_polarity_t cs_polarity
Definition magneticrotary2.h:243
pin_name_t sck
Definition magneticrotary2.h:237
spi_master_mode_t spi_mode
Definition magneticrotary2.h:242
pin_name_t mosi
Definition magneticrotary2.h:236
uint32_t spi_speed
Definition magneticrotary2.h:241
pin_name_t miso
Definition magneticrotary2.h:235
pin_name_t cs
Definition magneticrotary2.h:238
Magnetic Rotary 2 Click context object.
Definition magneticrotary2.h:216
digital_out_t ssi_sel
Definition magneticrotary2.h:218
spi_master_t spi
Definition magneticrotary2.h:220
uint8_t abs_res
Definition magneticrotary2.h:224
magneticrotary2_msel_t msel
Definition magneticrotary2.h:223
pin_name_t chip_select
Definition magneticrotary2.h:222