28#ifndef MAGNETICROTARY4_H
29#define MAGNETICROTARY4_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 MAGNETICROTARY4_REG_NOP 0x0000
75#define MAGNETICROTARY4_REG_ERRFL 0x0001
76#define MAGNETICROTARY4_REG_PROG 0x0003
77#define MAGNETICROTARY4_REG_DIAAGC 0x3FFC
78#define MAGNETICROTARY4_REG_MAG 0x3FFD
79#define MAGNETICROTARY4_REG_ANGLEUNC 0x3FFE
80#define MAGNETICROTARY4_REG_ANGLECOM 0x3FFF
86#define MAGNETICROTARY4_REG_ZPOSM 0x0016
87#define MAGNETICROTARY4_REG_ZPOSL 0x0017
88#define MAGNETICROTARY4_REG_SETTINGS1 0x0018
89#define MAGNETICROTARY4_REG_SETTINGS2 0x0019
107#define MAGNETICROTARY4_DATA_RESOLUTION 0x3FFF
108#define MAGNETICROTARY4_FULL_CIRCLE 360
114#define MAGNETICROTARY4_ODD_PARITY 0x01
120#define MAGNETICROTARY4_DIRECTION_CW 0
121#define MAGNETICROTARY4_DIRECTION_CCW 1
131#define MAGNETICROTARY4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
132#define MAGNETICROTARY4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
150#define MAGNETICROTARY4_MAP_MIKROBUS( cfg, mikrobus ) \
151 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
152 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
153 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
154 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
err_t magneticrotary4_read_register(magneticrotary4_t *ctx, uint16_t reg, uint16_t *data_out)
Magnetic Rotary 4 read register function.
err_t magneticrotary4_get_angle(magneticrotary4_t *ctx, float *angle)
Magnetic Rotary 4 get angle function.
void magneticrotary4_cfg_setup(magneticrotary4_cfg_t *cfg)
Magnetic Rotary 4 configuration object setup function.
err_t magneticrotary4_set_rotation_direction(magneticrotary4_t *ctx, uint8_t direction)
Magnetic Rotary 4 set rotation direction function.
err_t magneticrotary4_init(magneticrotary4_t *ctx, magneticrotary4_cfg_t *cfg)
Magnetic Rotary 4 initialization function.
err_t magneticrotary4_write_register(magneticrotary4_t *ctx, uint16_t reg, uint16_t data_in)
Magnetic Rotary 4 write register function.
err_t magneticrotary4_calibrate_zero_position(magneticrotary4_t *ctx)
Magnetic Rotary 4 calibrate zero position function.
magneticrotary4_return_value_t
Magnetic Rotary 4 Click return value data.
Definition magneticrotary4.h:196
@ MAGNETICROTARY4_ERROR
Definition magneticrotary4.h:198
@ MAGNETICROTARY4_OK
Definition magneticrotary4.h:197
This file contains SPI specific macros, functions, etc.
Magnetic Rotary 4 Click configuration object.
Definition magneticrotary4.h:177
spi_master_chip_select_polarity_t cs_polarity
Definition magneticrotary4.h:187
pin_name_t sck
Definition magneticrotary4.h:181
spi_master_mode_t spi_mode
Definition magneticrotary4.h:186
pin_name_t mosi
Definition magneticrotary4.h:180
uint32_t spi_speed
Definition magneticrotary4.h:185
pin_name_t miso
Definition magneticrotary4.h:179
pin_name_t cs
Definition magneticrotary4.h:182
Magnetic Rotary 4 Click context object.
Definition magneticrotary4.h:164
spi_master_t spi
Definition magneticrotary4.h:166
pin_name_t chip_select
Definition magneticrotary4.h:168