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 MAGNETO14_REG_ZERO_0 0x00
75#define MAGNETO14_REG_ZERO_1 0x01
76#define MAGNETO14_REG_BCT 0x02
77#define MAGNETO14_REG_ET_YX 0x03
78#define MAGNETO14_REG_PPT_ILIP 0x04
79#define MAGNETO14_REG_PPT 0x05
80#define MAGNETO14_REG_MG_LT_HT_MG 0x06
81#define MAGNETO14_REG_RD 0x09
82#define MAGNETO14_REG_FW 0x0E
83#define MAGNETO14_REG_HYS 0x10
84#define MAGNETO14_REG_M_GH_GL 0x1B
97#define MAGNETO14_CMD_READ_ANGLE 0x00
98#define MAGNETO14_CMD_READ_REGISTER 0x02
99#define MAGNETO14_CMD_WRITE_REGISTER 0x04
100#define MAGNETO14_CMD_RESTORE_ALL_NVM 0x05
101#define MAGNETO14_CMD_STORE_ALL_NVM 0x06
102#define MAGNETO14_CMD_STORE_SINGLE_NVM 0x07
120#define MAGNETO14_CMD_BIT_MASK 0x07
121#define MAGNETO14_REG_BIT_MASK 0x1F
127#define MAGNETO14_TRIMMING_X_DIS 0x00
128#define MAGNETO14_TRIMMING_X_EN 0x01
129#define MAGNETO14_TRIMMING_Y_DIS 0x00
130#define MAGNETO14_TRIMMING_Y_EN 0x02
136#define MAGNETO14_MG_LT_LVL_0 0x00
137#define MAGNETO14_MG_LT_LVL_1 0x20
138#define MAGNETO14_MG_LT_LVL_2 0x40
139#define MAGNETO14_MG_LT_LVL_3 0x60
140#define MAGNETO14_MG_LT_LVL_4 0x80
141#define MAGNETO14_MG_LT_LVL_5 0xA0
142#define MAGNETO14_MG_LT_LVL_6 0xC0
143#define MAGNETO14_MG_LT_LVL_7 0xE0
144#define MAGNETO14_MG_HT_LVL_0 0x00
145#define MAGNETO14_MG_HT_LVL_1 0x04
146#define MAGNETO14_MG_HT_LVL_2 0x08
147#define MAGNETO14_MG_HT_LVL_3 0x0C
148#define MAGNETO14_MG_HT_LVL_4 0x10
149#define MAGNETO14_MG_HT_LVL_5 0x14
150#define MAGNETO14_MG_HT_LVL_6 0x18
151#define MAGNETO14_MG_HT_LVL_7 0x1C
152#define MAGNETO14_MG_BIT_MASK 0xFC
158#define MAGNETO14_MGH_ST_OK 0x00
159#define MAGNETO14_FLD_ST_OK 0x00
160#define MAGNETO14_FLD_ST_MGL 0x01
161#define MAGNETO14_FLD_ST_MGH 0x02
162#define MAGNETO14_FLD_ST_BIT_MASK 0x03
172#define MAGNETO14_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
173#define MAGNETO14_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
191#define MAGNETO14_MAP_MIKROBUS( cfg, mikrobus ) \
192 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
193 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
194 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
195 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
196 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
197 cfg.mgh = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t magneto14_get_mgh(magneto14_t *ctx)
Magneto 14 gets the MGH function.
err_t magneto14_get_field_strength(magneto14_t *ctx, uint8_t *field_strength)
Magneto 14 gets the magnetic field strength function.
err_t magneto14_init(magneto14_t *ctx, magneto14_cfg_t *cfg)
Magneto 14 initialization function.
err_t magneto14_set_mag_field_thd(magneto14_t *ctx, uint8_t mglt, uint8_t mght)
Magneto 14 sets the magnetic field threshold function.
err_t magneto14_default_cfg(magneto14_t *ctx)
Magneto 14 default configuration function.
err_t magneto14_write_reg(magneto14_t *ctx, uint8_t cmd, uint8_t reg, uint8_t data_in)
Magneto 14 data writing function.
err_t magneto14_get_angle_raw_data(magneto14_t *ctx, uint16_t *raw_data)
Magneto 14 gets the angle raw data function.
void magneto14_set_pwm_pin(magneto14_t *ctx, uint8_t pwm_state)
Magneto 14 set PWM pin function.
err_t magneto14_get_angle(magneto14_t *ctx, float *angle)
Magneto 14 gets the angular position function.
void magneto14_cfg_setup(magneto14_cfg_t *cfg)
Magneto 14 configuration object setup function.
err_t magneto14_read_reg(magneto14_t *ctx, uint8_t cmd, uint8_t reg, uint8_t *data_out)
Magneto 14 data reading function.
magneto14_return_value_t
Magneto 14 Click return value data.
Definition magneto14.h:249
@ MAGNETO14_OK
Definition magneto14.h:250
@ MAGNETO14_ERROR
Definition magneto14.h:251
This file contains SPI specific macros, functions, etc.
Magneto 14 Click configuration object.
Definition magneto14.h:226
spi_master_chip_select_polarity_t cs_polarity
Definition magneto14.h:240
pin_name_t sck
Definition magneto14.h:230
spi_master_mode_t spi_mode
Definition magneto14.h:239
pin_name_t mosi
Definition magneto14.h:229
uint32_t spi_speed
Definition magneto14.h:238
pin_name_t mgh
Definition magneto14.h:235
pin_name_t pwm
Definition magneto14.h:234
pin_name_t miso
Definition magneto14.h:228
pin_name_t cs
Definition magneto14.h:231
Magneto 14 Click context object.
Definition magneto14.h:207
spi_master_t spi
Definition magneto14.h:215
digital_out_t pwm
Definition magneto14.h:209
digital_in_t mgh
Definition magneto14.h:212
pin_name_t chip_select
Definition magneto14.h:217