Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_spi_master.h"
64 #define GMRANGLE_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
66 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
67 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
68 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.ifa = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.css = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.ifc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
72 cfg.ifb = MIKROBUS( mikrobus, MIKROBUS_INT )
80 #define GMRANGLE_ERROR -1
87 #define GMRANGLE_REG_STAT 0x00
88 #define GMRANGLE_REG_ACSTAT 0x01
89 #define GMRANGLE_REG_AVAL 0x02
90 #define GMRANGLE_REG_ASPD 0x03
91 #define GMRANGLE_REG_AREV 0x04
92 #define GMRANGLE_REG_FSYNC 0x05
93 #define GMRANGLE_REG_MOD_1 0x06
94 #define GMRANGLE_REG_SIL 0x07
95 #define GMRANGLE_REG_MOD_2 0x08
96 #define GMRANGLE_REG_MOD_3 0x09
97 #define GMRANGLE_REG_OFFX 0x0A
98 #define GMRANGLE_REG_OFFY 0x0B
99 #define GMRANGLE_REG_SYNCH 0x0C
100 #define GMRANGLE_REG_IFAB 0x0D
101 #define GMRANGLE_REG_MOD_4 0x0E
102 #define GMRANGLE_REG_TCO_Y 0x0F
103 #define GMRANGLE_REG_ADC_X 0x10
104 #define GMRANGLE_REG_ADC_Y 0x11
111 #define GMRANGLE_READ_SENSOR 0x80
112 #define GMRANGLE_GET_BIT_5_4 0x30
113 #define GMRANGLE_GET_BIT_3_0 0x0F
120 #define GMRANGLE_SYSTEM_ERROR_MASK 0x4000
121 #define GMRANGLE_INTERFACE_ERROR_MASK 0x2000
122 #define GMRANGLE_INV_ANGLE_ERROR_MASK 0x1000
123 #define GMRANGLE_CRC_POLYNOMIAL 0x1D00
124 #define GMRANGLE_CRC_SEED 0xFF00
125 #define GMRANGLE_CRC_NUM_REGISTERS 0x0008
126 #define GMRANGLE_MAX_REGISTER_MEM 0x0030
127 #define GMRANGLE_DELETE_BIT_15 0x7FFF
128 #define GMRANGLE_CHANGE_UINT_TO_INT_16 0xFFFF
129 #define GMRANGLE_CHANGE_UINT_TO_INT_15 0x8000
130 #define GMRANGLE_MAX_BIT_14 0x3FFF
131 #define GMRANGLE_CHECK_BIT_14 0x4000
132 #define GMRANGLE_GET_BIT_14_4 0x7FF0
133 #define GMRANGLE_DELETE_7BITS 0x01FF
134 #define GMRANGLE_CHANGE_UNIT_TO_INT_9 0x0200
135 #define GMRANGLE_CHECK_BIT_9 0x0100
136 #define GMRANGLE_CHECK_BIT_15 0x8000
143 #define GMRANGLE_POW_2_15 32768.0f
144 #define GMRANGLE_POW_2_7 128.0f
145 #define GMRANGLE_ANGLE_360_VAL 360.0f
146 #define GMRANGLE_TEMP_OFFSET 152.0f
147 #define GMRANGLE_TEMP_DIV 2.776f
148 #define GMRANGLE_DATA_RESOLUTION 0x7FFF
159 #define GMRANGLE_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
160 #define GMRANGLE_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
445 #endif // _GMRANGLE_H_
pin_name_t sck
Definition: gmrangle.h:197
spi_master_chip_select_polarity_t cs_polarity
Definition: gmrangle.h:209
uint32_t spi_speed
Definition: gmrangle.h:207
uint16_t gmrangle_get_angle_value(gmrangle_t *ctx)
Get the angle value function.
This file contains SPI specific macros, functions, etc.
spi_master_mode_t spi_mode
Definition: gmrangle.h:208
void gmrangle_write_data(gmrangle_t *ctx, uint8_t reg, uint16_t tx_data)
Generic write 16-bit data function.
pin_name_t miso
Definition: gmrangle.h:195
void gmrangle_set_act_status(gmrangle_t *ctx, uint16_t a_data)
Set activation status register function.
pin_name_t mosi
Definition: gmrangle.h:196
pin_name_t ifc
Definition: gmrangle.h:203
int16_t gmrangle_get_num_revolutions(gmrangle_t *ctx)
Get the number of revolutions function.
uint16_t gmrangle_read_data(gmrangle_t *ctx, uint8_t reg)
Generic read 16-bit data function.
digital_out_t cs
Definition: gmrangle.h:175
int16_t gmrangle_get_angle_speed_value(gmrangle_t *ctx)
Get the angle speed value function.
digital_out_t css
Definition: gmrangle.h:176
digital_in_t ifa
Definition: gmrangle.h:179
digital_in_t ifc
Definition: gmrangle.h:181
spi_master_t spi
Definition: gmrangle.h:184
pin_name_t cs
Definition: gmrangle.h:198
err_t gmrangle_init(gmrangle_t *ctx, gmrangle_cfg_t *cfg)
Initialization function.
pin_name_t ifa
Definition: gmrangle.h:201
pin_name_t chip_select
Definition: gmrangle.h:185
float gmrangle_get_angle_range(gmrangle_t *ctx)
Get the angle range function.
uint16_t gmrangle_get_status(gmrangle_t *ctx)
Get the status data function.
void gmrangle_cfg_setup(gmrangle_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition: gmrangle.h:193
digital_in_t ifb
Definition: gmrangle.h:180
void gmrangle_get_angle_speed(gmrangle_t *ctx, float *final_angle_speed, int16_t *angle_speed_val)
Get the angle speed function.
pin_name_t css
Definition: gmrangle.h:202
Click ctx object definition.
Definition: gmrangle.h:173
pin_name_t ifb
Definition: gmrangle.h:204
float gmrangle_calculate_angle(gmrangle_t *ctx)
Calculate angle function.