41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_out.h"
52#include "drv_digital_in.h"
53#include "drv_spi_master.h"
67#define ANGLE3_ERROR -1
74#define ANGLE3_REG_ANG 0x00
75#define ANGLE3_REG_MAG 0x01
76#define ANGLE3_REG_CHMD 0x02
77#define ANGLE3_REG_ERRMON 0x03
78#define ANGLE3_REG_ZP 0x06
79#define ANGLE3_REG_RDABZ 0x07
80#define ANGLE3_REG_MLK 0x08
81#define ANGLE3_REG_EBDIS 0x09
82#define ANGLE3_REG_UVW 0x0A
89#define ANGLE3_EEPROM_ID1 0x04
90#define ANGLE3_EEPROM_ID2 0x05
91#define ANGLE3_EEPROM_ZP 0x06
92#define ANGLE3_EEPROM_RDABZ 0x07
93#define ANGLE3_EEPROM_MLK 0x08
94#define ANGLE3_EEPROM_EBDIS 0x09
95#define ANGLE3_EEPROM_UVW 0x0A
102#define ANGLE3_OPCODE_LOCK_EEPROM 0x00
103#define ANGLE3_OPCODE_WRITE_EEPROM 0x01
104#define ANGLE3_OPCODE_READ_EEPROM 0x02
105#define ANGLE3_OPCODE_WRITE_REG 0x03
106#define ANGLE3_OPCODE_READ_REG 0x04
107#define ANGLE3_OPCODE_CHANGE_MODE 0x05
108#define ANGLE3_OPCODE_ANGLE_DATA_RENEW 0x08
109#define ANGLE3_OPCODE_READ_ANGLE 0x09
116#define ANGLE3_NORMAL_MODE 0x0000
117#define ANGLE3_USER_MODE 0x050F
128#define ANGLE3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
129#define ANGLE3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
136#define ANGLE3_MAP_MIKROBUS( cfg, mikrobus ) \
137 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
138 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
139 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
140 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
141 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t angle3_read_error(angle3_t *ctx)
Read state of Error INT Pin.
void angle3_set_user_mode(angle3_t *ctx)
Set user mode function.
uint16_t angle3_read_eeprom(angle3_t *ctx, uint8_t reg_addr)
Read EEPROM function.
void angle3_set_mode(angle3_t *ctx, uint16_t set_mode)
Set mode function.
uint16_t angle3_read_data(angle3_t *ctx, uint8_t opcode, uint8_t reg)
Generic read function.
void angle3_write_register(angle3_t *ctx, uint8_t reg_addr, uint16_t write_data)
Write register function.
void angle3_write_eeprom(angle3_t *ctx, uint8_t reg_addr, uint16_t write_data)
Write EEPROM function.
float angle3_calculate_degrees(angle3_t *ctx, uint16_t angle)
Degrees Calculation function.
uint16_t angle3_read_angle_data(angle3_t *ctx)
Read angle data function.
void angle3_set_normal_mode(angle3_t *ctx)
Set normal mode function.
void angle3_cfg_setup(angle3_cfg_t *cfg)
Config Object Initialization function.
void angle3_default_cfg(angle3_t *ctx)
Default Config Object Initialization function.
err_t angle3_init(angle3_t *ctx, angle3_cfg_t *cfg)
Initialization function.
uint16_t angle3_read_register(angle3_t *ctx, uint8_t reg_addr)
Read register function.
void angle3_write_data(angle3_t *ctx, uint8_t opcode, uint8_t reg, uint16_t write_data)
Generic write function.
void angle3_lock_eeprom(angle3_t *ctx)
EEPROM lock function.
This file contains SPI specific macros, functions, etc.
Click configuration structure definition.
Definition angle3.h:168
spi_master_chip_select_polarity_t cs_polarity
Definition angle3.h:181
pin_name_t sck
Definition angle3.h:172
spi_master_mode_t spi_mode
Definition angle3.h:180
pin_name_t mosi
Definition angle3.h:171
uint32_t spi_speed
Definition angle3.h:179
pin_name_t int_pin
Definition angle3.h:176
pin_name_t miso
Definition angle3.h:170
pin_name_t cs
Definition angle3.h:173
Click ctx object definition.
Definition angle3.h:154
spi_master_t spi
Definition angle3.h:159
digital_in_t int_pin
Definition angle3.h:156
pin_name_t chip_select
Definition angle3.h:160