Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
60 #define MAGNETO13_REG_ZERO_0 0x00
61 #define MAGNETO13_REG_ZERO_1 0x01
62 #define MAGNETO13_REG_BCT 0x02
63 #define MAGNETO13_REG_ET_YX 0x03
64 #define MAGNETO13_REG_MG_LT_HT_MG 0x06
65 #define MAGNETO13_REG_IRQM_RAR_HYST 0x07
66 #define MAGNETO13_REG_THR 0x08
67 #define MAGNETO13_REG_RD 0x09
68 #define MAGNETO13_REG_REF 0x0A
69 #define MAGNETO13_REG_TRISTATE_SPI_PULL 0x0D
70 #define MAGNETO13_REG_FW 0x0E
71 #define MAGNETO13_REG_ERR_PAR_MEM_NVM 0x1A
72 #define MAGNETO13_REG_M_GH_GL 0x1B
85 #define MAGNETO13_CMD_READ_ANGLE 0x00
86 #define MAGNETO13_CMD_CLEAR_ERR_FLAGS 0x01
87 #define MAGNETO13_CMD_READ_REGISTER 0x02
88 #define MAGNETO13_CMD_WRITE_REGISTER 0x04
89 #define MAGNETO13_CMD_RESTORE_ALL_NVM 0x05
90 #define MAGNETO13_CMD_STORE_ALL_NVM 0x06
91 #define MAGNETO13_CMD_STORE_SINGLE_NVM 0x07
109 #define MAGNETO13_CMD_BIT_MASK 0x07
110 #define MAGNETO13_REG_BIT_MASK 0x1F
116 #define MAGNETO13_TRIMMING_X_DIS 0x00
117 #define MAGNETO13_TRIMMING_X_EN 0x01
118 #define MAGNETO13_TRIMMING_Y_DIS 0x00
119 #define MAGNETO13_TRIMMING_Y_EN 0x02
125 #define MAGNETO13_MG_LT_LVL_0 0x00
126 #define MAGNETO13_MG_LT_LVL_1 0x40
127 #define MAGNETO13_MG_LT_LVL_2 0x80
128 #define MAGNETO13_MG_LT_LVL_3 0xC0
129 #define MAGNETO13_MG_HT_LVL_0 0x00
130 #define MAGNETO13_MG_HT_LVL_1 0x10
131 #define MAGNETO13_MG_HT_LVL_2 0x20
132 #define MAGNETO13_MG_HT_LVL_3 0x30
133 #define MAGNETO13_MG_BIT_MASK 0xF0
134 #define MAGNETO13_MG_FLD_THD_DIS 0x00
135 #define MAGNETO13_MG_FLD_THD_EN 0x01
141 #define MAGNETO13_FLD_ST_OK 0x00
142 #define MAGNETO13_FLD_ST_MGL 0x01
143 #define MAGNETO13_FLD_ST_MGH 0x02
144 #define MAGNETO13_FLD_ST_BIT_MASK 0x03
154 #define MAGNETO13_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
155 #define MAGNETO13_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
173 #define MAGNETO13_MAP_MIKROBUS( cfg, mikrobus ) \
174 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
175 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
176 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
177 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
178 cfg.err = MIKROBUS( mikrobus, MIKROBUS_AN ); \
179 cfg.nvm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
180 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
439 #endif // MAGNETO13_H
pin_name_t sck
Definition: magneto13.h:212
spi_master_chip_select_polarity_t cs_polarity
Definition: magneto13.h:223
Magneto 13 Click context object.
Definition: magneto13.h:190
uint32_t spi_speed
Definition: magneto13.h:221
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:222
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:199
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:194
err_t magneto13_init(magneto13_t *ctx, magneto13_cfg_t *cfg)
Magneto 13 initialization function.
pin_name_t nvm
Definition: magneto13.h:217
pin_name_t irq
Definition: magneto13.h:218
@ MAGNETO13_ERROR
Definition: magneto13.h:234
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:213
pin_name_t miso
Definition: magneto13.h:210
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:233
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:211
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:232
Magneto 13 Click configuration object.
Definition: magneto13.h:208
spi_master_t spi
Definition: magneto13.h:197
err_t magneto13_default_cfg(magneto13_t *ctx)
Magneto 13 default configuration function.
digital_in_t err
Definition: magneto13.h:192
uint8_t magneto13_get_error_flag(magneto13_t *ctx)
Magneto 13 gets the error flag function.
pin_name_t err
Definition: magneto13.h:216
digital_in_t nvm
Definition: magneto13.h:193
err_t magneto13_get_angle_raw_data(magneto13_t *ctx, uint16_t *raw_data)
Magneto 13 gets the angle raw data function.