TLE5012B  3.1.0
The TLE5012B is a pre-calibrated 360° angle sensor that detects the orientation of a magnetic field. The raw signals (sine and cosine) are digitally processed internally to calculate the angle orientation of the magnetic field (magnet).
tle5012b_util.hpp
Go to the documentation of this file.
1 
21 #ifndef TLE5012B_UTIL_HPP
22 #define TLE5012B_UTIL_HPP
23 
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include "TLE5012b.hpp"
27 
34 // Common macros
35 #define TRIGGER_DELAY 5
36 
37 // Sensor registers
38 #define READ_SENSOR 0x8000
39 #define WRITE_SENSOR 0x5000
40 #define READ_BLOCK_CRC 0x8088
41 
42 // Bitmasks for several read and write functions
43 #define SYSTEM_ERROR_MASK 0x4000
44 #define INTERFACE_ERROR_MASK 0x2000
45 #define INV_ANGLE_ERROR_MASK 0x1000
46 
47 #define CRC_POLYNOMIAL 0x1D
48 #define CRC_SEED 0xFF
49 #define CRC_NUM_REGISTERS 0x0008
50 #define MAX_REGISTER_MEM 0x0030
51 #define MAX_NUM_REG 0x16
52 
53 #define DELETE_BIT_15 0x7FFF
54 #define CHANGE_UINT_TO_INT_15 0x8000
55 #define CHECK_BIT_14 0x4000
56 #define GET_BIT_14_4 0x7FF0
57 
58 #define DELETE_7BITS 0x01FF
59 #define CHANGE_UNIT_TO_INT_9 0x0200
60 #define CHECK_BIT_9 0x0100
61 
62 #define POW_2_15 32768.0
63 #define POW_2_7 128.0
64 #define ANGLE_360_VAL 360.0
65 
66 #define TEMP_OFFSET 152.0
67 #define TEMP_DIV 2.776
68 
73 {
74  NO_ERROR = 0x00,
75  SYSTEM_ERROR = 0x01,
79  CRC_ERROR = 0xFF
80 };
81 
84 {
85  UPD_low = 0x0000,
86  UPD_high = 0x0400,
87 };
88 
91 {
92  SAFE_low = 0x0000,
93  SAFE_high = 0x0001,
94 };
99 #endif /* TLE5012B_UTIL_HPP */
errorTypes
Error types from safety word.
Definition: tle5012b_util.hpp:73
updTypes
Definition: tle5012b_util.hpp:84
safetyTypes
Definition: tle5012b_util.hpp:91
@ ANGLE_SPEED_ERROR
ANGLE_SPEED_ERROR = combined error, angular speed calculation wrong.
Definition: tle5012b_util.hpp:78
@ CRC_ERROR
CRC_ERROR = Cyclic Redundancy Check (CRC), which includes the STAT and RESP bits wrong.
Definition: tle5012b_util.hpp:79
@ INTERFACE_ACCESS_ERROR
INTERFACE_ACCESS_ERROR = wrong address or wrong lock.
Definition: tle5012b_util.hpp:76
@ SYSTEM_ERROR
SYSTEM_ERROR = over/under voltage, VDD negative, GND off, ROM defect.
Definition: tle5012b_util.hpp:75
@ INVALID_ANGLE_ERROR
INVALID_ANGLE_ERROR = NO_GMR_A = 1 or NO_GMR_XY = 1.
Definition: tle5012b_util.hpp:77
@ NO_ERROR
NO_ERROR = Safety word was OK.
Definition: tle5012b_util.hpp:74
@ UPD_high
read update buffer registers
Definition: tle5012b_util.hpp:86
@ UPD_low
read normal registers
Definition: tle5012b_util.hpp:85
@ SAFE_low
switch of safety word generation
Definition: tle5012b_util.hpp:92
@ SAFE_high
switch on safety word generation
Definition: tle5012b_util.hpp:93