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"
53#include "drv_analog_in.h"
75#define AMRANGLE2_REG_ADC_MODE_CONTROL 0x0000
76#define AMRANGLE2_REG_ADC_CONFIGURATION 0x8000
77#define AMRANGLE2_REG_UNIPOLAR 0x8800
78#define AMRANGLE2_REG_BIPOLAR 0x9000
79#define AMRANGLE2_REG_RANGE 0x9800
80#define AMRANGLE2_REG_CUSTOM_SCAN0 0xA000
81#define AMRANGLE2_REG_CUSTOM_SCAN1 0xA800
82#define AMRANGLE2_REG_SAMPLE_SET 0xB000
100#define AMRANGLE2_SCAN_UNCHANGED 0x0000
101#define AMRANGLE2_SCAN_MANUAL 0x0800
102#define AMRANGLE2_SCAN_REPEAT 0x1000
103#define AMRANGLE2_SCAN_STANDARD_INT 0x1800
104#define AMRANGLE2_SCAN_STANDARD_EXT 0x2000
105#define AMRANGLE2_SCAN_UPPER_INT 0x2800
106#define AMRANGLE2_SCAN_UPPER_EXT 0x3000
107#define AMRANGLE2_SCAN_CUSTOM_INT 0x3800
108#define AMRANGLE2_SCAN_CUSTOM_EXT 0x4000
109#define AMRANGLE2_SCAN_SAMPLE_SET 0x4800
110#define AMRANGLE2_CHSEL_AIN0 0x0000
111#define AMRANGLE2_CHSEL_AIN1 0x0080
112#define AMRANGLE2_CHSEL_AIN2 0x0100
113#define AMRANGLE2_CHSEL_AIN3 0x0180
114#define AMRANGLE2_RESET_FIFO 0x0020
115#define AMRANGLE2_RESET_ALL 0x0040
116#define AMRANGLE2_PM_NORMAL 0x0000
117#define AMRANGLE2_PM_AUTO_SHUTDOWN 0x0008
118#define AMRANGLE2_PM_AUTO_STANDBY 0x0010
119#define AMRANGLE2_CHAN_ID_ENABLE 0x0004
120#define AMRANGLE2_SWCNV_START 0x0002
126#define AMRANGLE2_REFSEL_EXT_DIFFERENTIAL 0x0400
127#define AMRANGLE2_AVGON 0x0200
128#define AMRANGLE2_NAVG_4 0x0000
129#define AMRANGLE2_NAVG_8 0x0080
130#define AMRANGLE2_NAVG_16 0x0100
131#define AMRANGLE2_NAVG_32 0x0180
132#define AMRANGLE2_NSCAN_4 0x0000
133#define AMRANGLE2_NSCAN_8 0x0020
134#define AMRANGLE2_NSCAN_12 0x0040
135#define AMRANGLE2_NSCAN_16 0x0060
136#define AMRANGLE2_SPM_NORMAL 0x0000
137#define AMRANGLE2_SPM_FULL_SHUTDOWN 0x0008
138#define AMRANGLE2_SPM_PARTIAL_SHUTDOWN 0x0010
139#define AMRANGLE2_ECHO_ON 0x0004
145#define AMRANGLE2_RANGE01_HALF_VREF 0x0000
146#define AMRANGLE2_RANGE01_FULL_VREF 0x0400
147#define AMRANGLE2_RANGE23_HALF_VREF 0x0000
148#define AMRANGLE2_RANGE23_FULL_VREF 0x0200
154#define AMRANGLE2_BCH01_UNIPOLAR 0x0000
155#define AMRANGLE2_BCH01_BIPOLAR_FULLY_DIFF 0x0400
156#define AMRANGLE2_BCH23_UNIPOLAR 0x0000
157#define AMRANGLE2_BCH23_BIPOLAR_FULLY_DIFF 0x0200
163#define AMRANGLE2_ADC_VREF 3.3
164#define AMRANGLE2_ADC_RESOLUTION 0x0FFF
170#define AMRANGLE2_RADIANS_TO_DEGREES 57.295779513
171#define AMRANGLE2_ANGLE_ZERO_OFFSET 90.0
177#define AMRANGLE2_TEMP_VDD 3.3
178#define AMRANGLE2_TEMP_TCAL 25.0
179#define AMRANGLE2_TEMP_TCO 0.003173
180#define AMRANGLE2_TEMP_NUM_CONVERSIONS 100
190#define AMRANGLE2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
191#define AMRANGLE2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
209#define AMRANGLE2_MAP_MIKROBUS( cfg, mikrobus ) \
210 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
211 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
212 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
213 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
214 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
215 cfg.cst = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
216 cfg.eoc = MIKROBUS( mikrobus, MIKROBUS_INT )
amrangle2_return_value_t
AMR Angle 2 Click return value data.
Definition amrangle2.h:274
@ AMRANGLE2_OK
Definition amrangle2.h:275
@ AMRANGLE2_ERROR
Definition amrangle2.h:276
err_t amrangle2_init(amrangle2_t *ctx, amrangle2_cfg_t *cfg)
AMR Angle 2 initialization function.
void amrangle2_cfg_setup(amrangle2_cfg_t *cfg)
AMR Angle 2 configuration object setup function.
void amrangle2_set_cst_pin(amrangle2_t *ctx, uint8_t state)
AMR Angle 2 set cst pin function.
uint8_t amrangle2_get_eoc_pin(amrangle2_t *ctx)
AMR Angle 2 get eoc pin function.
err_t amrangle2_read_angle(amrangle2_t *ctx, float *angle)
AMR Angle 2 read angle function.
err_t amrangle2_default_cfg(amrangle2_t *ctx)
AMR Angle 2 default configuration function.
err_t amrangle2_read_vsin_vcos(amrangle2_t *ctx, float *vsin, float *vcos)
AMR Angle 2 read vsin vcos function.
void amrangle2_start_conversion(amrangle2_t *ctx)
AMR Angle 2 start conversion function.
err_t amrangle2_calibrate_temperature(amrangle2_t *ctx)
AMR Angle 2 calibrate temperature function.
err_t amrangle2_read_temperature(amrangle2_t *ctx, float *temperature)
AMR Angle 2 read temperature function.
err_t amrangle2_spi_transfer(amrangle2_t *ctx, uint16_t data_in)
AMR Angle 2 spi transfer function.
err_t amrangle2_read_an_pin_voltage(amrangle2_t *ctx, float *data_out)
AMR Angle 2 read AN pin voltage level function.
err_t amrangle2_read_an_pin_value(amrangle2_t *ctx, uint16_t *data_out)
AMR Angle 2 read AN pin value function.
This file contains SPI specific macros, functions, etc.
AMR Angle 2 Click configuration object.
Definition amrangle2.h:247
pin_name_t cst
Definition amrangle2.h:256
analog_in_resolution_t resolution
Definition amrangle2.h:264
float vref
Definition amrangle2.h:265
pin_name_t eoc
Definition amrangle2.h:257
spi_master_chip_select_polarity_t cs_polarity
Definition amrangle2.h:262
pin_name_t sck
Definition amrangle2.h:251
spi_master_mode_t spi_mode
Definition amrangle2.h:261
pin_name_t mosi
Definition amrangle2.h:250
uint32_t spi_speed
Definition amrangle2.h:260
pin_name_t miso
Definition amrangle2.h:249
pin_name_t an
Definition amrangle2.h:253
pin_name_t cs
Definition amrangle2.h:252
AMR Angle 2 Click context object.
Definition amrangle2.h:226
spi_master_t spi
Definition amrangle2.h:234
float vcal
Definition amrangle2.h:238
digital_out_t cst
Definition amrangle2.h:228
digital_in_t eoc
Definition amrangle2.h:231
pin_name_t chip_select
Definition amrangle2.h:237
analog_in_t adc
Definition amrangle2.h:235