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 MAGNETO4_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.a = MIKROBUS( mikrobus, MIKROBUS_AN ); \
74 cfg.b = MIKROBUS( mikrobus, MIKROBUS_RST ); \
75 cfg.ind = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define MAGNETO4_RETVAL uint8_t
84#define MAGNETO4_OK 0x00
85#define MAGNETO4_INIT_ERROR 0xFF
92#define MAGNETO4_ENCODER_TO_ZERO_POSITION 0
99#define MAGNETO4_MAX_MAGNETIC_FIELD_VALUE 3000
#define MAGNETO4_RETVAL
Definition magneto4.h:82
void magneto4_cfg_setup(magneto4_cfg_t *cfg)
Config Object Initialization function.
uint8_t magneto4_get_out_b(magneto4_t *ctx)
Get B ( RST ) pin status.
uint8_t magneto4_get_out_a(magneto4_t *ctx)
Get A ( AN ) pin status.
uint8_t magneto4_get_index(magneto4_t *ctx)
Get IND ( interrupt ) pin status.
void magneto4_get_encoder_position(magneto4_t *ctx)
Encoder position.
void magneto4_set_start_position(magneto4_t *ctx, int32_t encoder_pos)
Set start encoder position.
MAGNETO4_RETVAL magneto4_init(magneto4_t *ctx, magneto4_cfg_t *cfg)
Initialization function.
void magneto4_generic_transfer(magneto4_t *ctx, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void magneto4_default_cfg(magneto4_t *ctx)
Click Default Configuration function.
uint32_t magneto4_start_measurement(magneto4_t *ctx)
Measurement function.
uint16_t magneto4_get_magnetic_field(magneto4_t *ctx)
Measurement Field.
uint8_t magneto4_get_magnetic_status(magneto4_t *ctx, mag_status_t *mag_status)
Get Magnetic measurement status.
uint8_t magneto4_get_encoder_direction(magneto4_t *ctx)
Encoder direction.
Click magnetic status structure definition.
Definition magneto4.h:169
uint8_t ocf_val
Definition magneto4.h:174
uint8_t inc_val
Definition magneto4.h:171
uint8_t cof_val
Definition magneto4.h:173
uint8_t dec_val
Definition magneto4.h:170
uint8_t lin_val
Definition magneto4.h:172
Click configuration structure definition.
Definition magneto4.h:142
uint8_t spi_mode
Definition magneto4.h:160
spi_master_chip_select_polarity_t cs_polarity
Definition magneto4.h:161
pin_name_t sck
Definition magneto4.h:147
pin_name_t b
Definition magneto4.h:153
pin_name_t a
Definition magneto4.h:152
pin_name_t mosi
Definition magneto4.h:146
uint32_t spi_speed
Definition magneto4.h:159
pin_name_t pwm
Definition magneto4.h:154
pin_name_t miso
Definition magneto4.h:145
pin_name_t ind
Definition magneto4.h:155
pin_name_t cs
Definition magneto4.h:148
Click ctx object definition.
Definition magneto4.h:113
digital_out_t cs
Definition magneto4.h:114
spi_master_t spi
Definition magneto4.h:125
digital_in_t b
Definition magneto4.h:119
uint8_t state_b
Definition magneto4.h:134
int32_t encoder_position
Definition magneto4.h:130
uint8_t state_a
Definition magneto4.h:133
digital_in_t pwm
Definition magneto4.h:120
uint8_t a_edge
Definition magneto4.h:131
digital_in_t ind
Definition magneto4.h:121
uint8_t b_edge
Definition magneto4.h:132
pin_name_t chip_select
Definition magneto4.h:126
digital_in_t a
Definition magneto4.h:118