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"
67#define ANGLE5_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.mgh = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
73 cfg.mgl = MIKROBUS( mikrobus, MIKROBUS_INT )
80#define ANGLE5_RETVAL uint8_t
83#define ANGLE5_INIT_ERROR 0xFF
90#define ANGLE5_REG_ZERO_SETTING_LSB 0x00
91#define ANGLE5_REG_ZERO_SETTING_MSB 0x01
92#define ANGLE5_REG_BIAS_CURRENT_TRIMMING 0x02
93#define ANGLE5_REG_ENABLE_TRIMMING_XY 0x03
94#define ANGLE5_REG_CONFIG_1 0x04
95#define ANGLE5_REG_CONFIG_2 0x05
96#define ANGLE5_REG_MAGNETIC_FIELD_THR 0x06
97#define ANGLE5_REG_NUMBER_OF_POLE_PAIRS 0x07
98#define ANGLE5_REG_ROTATION_DIRECTION 0x09
99#define ANGLE5_REG_MG_H_L 0x1B
106#define ANGLE5_CMD_READ_ANGLE 0x00
107#define ANGLE5_CMD_READ 0x40
108#define ANGLE5_CMD_WRITE 0x80
#define ANGLE5_RETVAL
Definition angle5.h:80
void angle5_default_cfg(angle5_t *ctx)
Click Default Configuration function.
uint16_t angle5_read_raw_angle(angle5_t *ctx)
Reads Raw Angle data.
uint16_t angle5_read_register(angle5_t *ctx, uint8_t reg_addr, uint8_t *rsp)
Generic read function.
float angle5_calc_rpm(float old_angle, float new_angle)
Calculating angle data to RPM.
ANGLE5_RETVAL angle5_init(angle5_t *ctx, angle5_cfg_t *cfg)
Initialization function.
uint16_t angle5_write_register(angle5_t *ctx, uint8_t reg_addr, uint8_t tx_data, uint8_t *status)
Generic write function.
uint8_t angle5_get_mgh_pin_state(angle5_t *ctx)
Gets MGH (PWM) pin state.
void angle5_generic_transfer(angle5_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void angle5_cfg_setup(angle5_cfg_t *cfg)
Config Object Initialization function.
uint8_t angle5_get_mgl_pin_state(angle5_t *ctx)
Gets MGL (INT) pin state.
float angle5_read_angle_deg(angle5_t *ctx)
Reads Angle data in deg.
Click configuration structure definition.
Definition angle5.h:143
spi_master_chip_select_polarity_t cs_polarity
Definition angle5.h:160
pin_name_t sck
Definition angle5.h:148
spi_master_mode_t spi_mode
Definition angle5.h:159
pin_name_t mgl
Definition angle5.h:154
pin_name_t mosi
Definition angle5.h:147
uint32_t spi_speed
Definition angle5.h:158
pin_name_t mgh
Definition angle5.h:153
pin_name_t miso
Definition angle5.h:146
pin_name_t cs
Definition angle5.h:149
Click ctx object definition.
Definition angle5.h:122
digital_out_t cs
Definition angle5.h:125
spi_master_t spi
Definition angle5.h:134
digital_in_t mgh
Definition angle5.h:129
digital_in_t mgl
Definition angle5.h:130
pin_name_t chip_select
Definition angle5.h:135