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 MAGNETO_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.out = MIKROBUS( mikrobus, MIKROBUS_INT )
79#define MAGNETO_RETVAL uint8_t
81#define MAGNETO_OK 0x00
82#define MAGNETO_INIT_ERROR 0xFF
89#define MAGNETO_REG_CLEAR_ERROR_FLAG 0x0001
90#define MAGNETO_REG_PROGRAMMING_CONTROL 0x0003
91#define MAGNETO_REG_OTP_ZERO_POS_HIGH 0x0016
92#define MAGNETO_REG_OTP_ZERO_POS_LOW 0x0017
93#define MAGNETO_REG_DIAG_AGC 0x3FFD
94#define MAGNETO_REG_MAGNITUDE 0x3FFF
95#define MAGNETO_REG_ANGLE 0x3FFF
102#define MAGNETO_CMD_RESET_VALUE 0x0000
103#define MAGNETO_CMD_SET_VALUE 0xFFFE
104#define MAGNETO_CMD_MAGNITUDE_VALUE 0x1FFE
105#define MAGNETO_CMD_PARITY_VALUE 0x000F
106#define MAGNETO_CMD_READ_COMMAND_BIT 0x4000
107#define MAGNETO_CMD_HIGH_BYTE 0xFF00
108#define MAGNETO_CMD_LOW_BYTE 0x00FF
115#define MAGNETO_FLAG_OK 0
116#define MAGNETO_FLAG_ERROR 1
177 // End constants group
186 // End variable group
#define MAGNETO_RETVAL
Definition magneto.h:79
void magneto_cfg_setup(magneto_cfg_t *cfg)
Config Object Initialization function.
void magneto_write_data(magneto_t *ctx, uint16_t address_command, uint16_t write_data)
16-bit command generic write function.
uint16_t magneto_read_data(magneto_t *ctx, uint16_t address_command)
16-bit command generic read function.
uint8_t magneto_check_state(magneto_t *ctx)
Check state function.
float magneto_get_angle(magneto_t *ctx)
Calculate angle function.
uint16_t magneto_get_state(magneto_t *ctx)
Get state function.
MAGNETO_RETVAL magneto_init(magneto_t *ctx, magneto_cfg_t *cfg)
Initialization function.
void magneto_generic_transfer(magneto_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
Click configuration structure definition.
Definition magneto.h:148
uint8_t spi_mode
Definition magneto.h:163
pin_name_t out
Definition magneto.h:158
spi_master_chip_select_polarity_t cs_polarity
Definition magneto.h:164
pin_name_t sck
Definition magneto.h:153
pin_name_t mosi
Definition magneto.h:152
uint32_t spi_speed
Definition magneto.h:162
pin_name_t miso
Definition magneto.h:151
pin_name_t cs
Definition magneto.h:154
Click ctx object definition.
Definition magneto.h:131
digital_out_t cs
Definition magneto.h:135
spi_master_t spi
Definition magneto.h:139
digital_out_t out
Definition magneto.h:134
pin_name_t chip_select
Definition magneto.h:140