35#ifndef MAGNETICROTARY_H
36#define MAGNETICROTARY_H
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"
63#define T_MAGNROTARY_P const uint8_t*
70#define MAGNETICROTARY_MAP_MIKROBUS( cfg, mikrobus ) \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
81#define MAGNETICROTARY_RETVAL uint8_t
83#define MAGNETICROTARY_OK 0x00
84#define MAGNETICROTARY_INIT_ERROR 0xFF
91#define MAGNROTARY_CHA_POS_GND_NEG 0x80
92#define MAGNROTARY_CHB_POS_GND_NEG 0xC0
93#define MAGNROTARY_CHA_POS_CHB_NEG 0x00
94#define MAGNROTARY_CHB_POS_CHA_NEG 0x40
101#define MAGNROTARY_MSB_LSB_ORDER 0x00
102#define MAGNROTARY_MSB_ZEROS_ORDER 0x20
109#define MAGNROTARY_VDD_3V3 3298
110#define MAGNROTARY_VDD_5V 4960
117#define MAGNROTARY_START_BYTE 0x01
118#define MAGNROTARY_DUMMY_BYTE 0x00
119#define MAGNROTARY_CMD_MASK 0xE0
120#define MAGNROTARY_ADC_RESOLUTION 4096
121#define MAGNROTARY_SIGN_BIT 0x0800
#define MAGNETICROTARY_RETVAL
Definition magneticrotary.h:81
uint16_t magnrotary_read_adc(magneticrotary_t *ctx, uint8_t cmnd_byte)
ADC Result Read function.
uint16_t magnrotary_out_volt_adc(magneticrotary_t *ctx, uint8_t cmd_byte, uint16_t pwr_volt)
ADC Output Voltage Get function.
void magneticrotary_cfg_setup(magneticrotary_cfg_t *cfg)
Config Object Initialization function.
void magneticrotary_generic_transfer(magneticrotary_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
double magnrotary_get_field_angle(magneticrotary_t *ctx, uint8_t cmd_byte)
Magnetic Field Angle Get function.
MAGNETICROTARY_RETVAL magneticrotary_init(magneticrotary_t *ctx, magneticrotary_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition magneticrotary.h:147
spi_master_chip_select_polarity_t cs_polarity
Definition magneticrotary.h:159
pin_name_t sck
Definition magneticrotary.h:152
spi_master_mode_t spi_mode
Definition magneticrotary.h:158
pin_name_t mosi
Definition magneticrotary.h:151
uint32_t spi_speed
Definition magneticrotary.h:157
pin_name_t miso
Definition magneticrotary.h:150
pin_name_t cs
Definition magneticrotary.h:153
Click ctx object definition.
Definition magneticrotary.h:134
digital_out_t cs
Definition magneticrotary.h:135
spi_master_t spi
Definition magneticrotary.h:138
pin_name_t chip_select
Definition magneticrotary.h:139