Go to the documentation of this file.
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 MAGNETO13_REG_ZERO_0 0x00
75 #define MAGNETO13_REG_ZERO_1 0x01
76 #define MAGNETO13_REG_BCT 0x02
77 #define MAGNETO13_REG_ET_YX 0x03
78 #define MAGNETO13_REG_MG_LT_HT_MG 0x06
79 #define MAGNETO13_REG_IRQM_RAR_HYST 0x07
80 #define MAGNETO13_REG_THR 0x08
81 #define MAGNETO13_REG_RD 0x09
82 #define MAGNETO13_REG_REF 0x0A
83 #define MAGNETO13_REG_TRISTATE_SPI_PULL 0x0D
84 #define MAGNETO13_REG_FW 0x0E
85 #define MAGNETO13_REG_ERR_PAR_MEM_NVM 0x1A
86 #define MAGNETO13_REG_M_GH_GL 0x1B
99 #define MAGNETO13_CMD_READ_ANGLE 0x00
100 #define MAGNETO13_CMD_CLEAR_ERR_FLAGS 0x01
101 #define MAGNETO13_CMD_READ_REGISTER 0x02
102 #define MAGNETO13_CMD_WRITE_REGISTER 0x04
103 #define MAGNETO13_CMD_RESTORE_ALL_NVM 0x05
104 #define MAGNETO13_CMD_STORE_ALL_NVM 0x06
105 #define MAGNETO13_CMD_STORE_SINGLE_NVM 0x07
123 #define MAGNETO13_CMD_BIT_MASK 0x07
124 #define MAGNETO13_REG_BIT_MASK 0x1F
130 #define MAGNETO13_TRIMMING_X_DIS 0x00
131 #define MAGNETO13_TRIMMING_X_EN 0x01
132 #define MAGNETO13_TRIMMING_Y_DIS 0x00
133 #define MAGNETO13_TRIMMING_Y_EN 0x02
139 #define MAGNETO13_MG_LT_LVL_0 0x00
140 #define MAGNETO13_MG_LT_LVL_1 0x40
141 #define MAGNETO13_MG_LT_LVL_2 0x80
142 #define MAGNETO13_MG_LT_LVL_3 0xC0
143 #define MAGNETO13_MG_HT_LVL_0 0x00
144 #define MAGNETO13_MG_HT_LVL_1 0x10
145 #define MAGNETO13_MG_HT_LVL_2 0x20
146 #define MAGNETO13_MG_HT_LVL_3 0x30
147 #define MAGNETO13_MG_BIT_MASK 0xF0
148 #define MAGNETO13_MG_FLD_THD_DIS 0x00
149 #define MAGNETO13_MG_FLD_THD_EN 0x01
155 #define MAGNETO13_FLD_ST_OK 0x00
156 #define MAGNETO13_FLD_ST_MGL 0x01
157 #define MAGNETO13_FLD_ST_MGH 0x02
158 #define MAGNETO13_FLD_ST_BIT_MASK 0x03
168 #define MAGNETO13_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
169 #define MAGNETO13_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
187 #define MAGNETO13_MAP_MIKROBUS( cfg, mikrobus ) \
188 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
189 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
190 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
191 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
192 cfg.err = MIKROBUS( mikrobus, MIKROBUS_AN ); \
193 cfg.nvm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
194 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
453 #endif // MAGNETO13_H
pin_name_t sck
Definition: magneto13.h:226
spi_master_chip_select_polarity_t cs_polarity
Definition: magneto13.h:237
Magneto 13 Click context object.
Definition: magneto13.h:204
uint32_t spi_speed
Definition: magneto13.h:235
This file contains SPI specific macros, functions, etc.
err_t magneto13_write_reg(magneto13_t *ctx, uint8_t cmd, uint8_t reg, uint8_t data_in)
Magneto 13 data writing function.
spi_master_mode_t spi_mode
Definition: magneto13.h:236
uint8_t magneto13_get_interrupt(magneto13_t *ctx)
Magneto 13 gets the interrupt on the angle change state function.
pin_name_t chip_select
Definition: magneto13.h:213
err_t magneto13_enable_fld_thd_det(magneto13_t *ctx)
Magneto 13 enables the magnetic field threshold detection function.
digital_in_t irq
Definition: magneto13.h:208
err_t magneto13_init(magneto13_t *ctx, magneto13_cfg_t *cfg)
Magneto 13 initialization function.
pin_name_t nvm
Definition: magneto13.h:231
pin_name_t irq
Definition: magneto13.h:232
@ MAGNETO13_ERROR
Definition: magneto13.h:248
err_t magneto13_set_mag_field_thd(magneto13_t *ctx, uint8_t mglt, uint8_t mght)
Magneto 13 sets the magnetic field threshold function.
pin_name_t cs
Definition: magneto13.h:227
pin_name_t miso
Definition: magneto13.h:224
err_t magneto13_get_field_strength(magneto13_t *ctx, uint8_t *field_strength)
Magneto 13 gets the magnetic field strength function.
@ MAGNETO13_OK
Definition: magneto13.h:247
err_t magneto13_read_reg(magneto13_t *ctx, uint8_t cmd, uint8_t reg, uint8_t *data_out)
Magneto 13 data reading function.
uint8_t magneto13_get_nvm_access_state(magneto13_t *ctx)
Magneto 13 checks the access to the NVM function.
err_t magneto13_get_angle(magneto13_t *ctx, float *angle)
Magneto 13 gets the angular position function.
pin_name_t mosi
Definition: magneto13.h:225
void magneto13_cfg_setup(magneto13_cfg_t *cfg)
Magneto 13 configuration object setup function.
magneto13_return_value_t
Magneto 13 Click return value data.
Definition: magneto13.h:246
Magneto 13 Click configuration object.
Definition: magneto13.h:222
spi_master_t spi
Definition: magneto13.h:211
err_t magneto13_default_cfg(magneto13_t *ctx)
Magneto 13 default configuration function.
digital_in_t err
Definition: magneto13.h:206
uint8_t magneto13_get_error_flag(magneto13_t *ctx)
Magneto 13 gets the error flag function.
pin_name_t err
Definition: magneto13.h:230
digital_in_t nvm
Definition: magneto13.h:207
err_t magneto13_get_angle_raw_data(magneto13_t *ctx, uint16_t *raw_data)
Magneto 13 gets the angle raw data function.