Infineon One Point Calibration Library  1.0.1
onecalib.h
Go to the documentation of this file.
1 /*
2  *****************************************************************************
3  * Copyright (C) 2017 Infineon Technologies AG. All rights reserved.
4  *
5  * Infineon Technologies AG (INFINEON) is supplying this file for use
6  * exclusively with Infineon's products. This file can be freely
7  * distributed within development tools and software supporting such microcontroller
8  * products.
9  *
10  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
11  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
13  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR DIRECT, INDIRECT, INCIDENTAL,
14  * ASPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
15  *
16  ******************************************************************************
17  */
18 
19 /* onecalib.h */
20 
21 
22 
23 #ifndef ONECALIB_H
24 #define ONECALIB_H
25 
26 #include <stdint.h>
27 #include <stdbool.h>
28 #include <math.h>
29 
30 #define RAD2DEGFACTOR (180.00 / M_PI)
31 #define DEG2RADFACTOR (M_PI / 180.00)
32 #define ANGLE_TOLERANCE 0.25
33 #define ANGLE_TOLERANCE_RAD (ANGLE_TOLERANCE * DEG2RADFACTOR)
34 #define ANGLE180_RAD (180.00 * DEG2RADFACTOR)
36 #define ANGLE45 45.00
37 #define ANGLE135 135.00
38 #define ANGLE225 -135.00
39 #define ANGLE315 -45.00
41 #define ANGLE45_H ((ANGLE45 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
42 #define ANGLE45_L ((ANGLE45 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
43 #define ANGLE135_H ((ANGLE135 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
44 #define ANGLE135_L ((ANGLE135 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
45 #define ANGLE225_H ((ANGLE225 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
46 #define ANGLE225_L ((ANGLE225 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
47 #define ANGLE315_H ((ANGLE315 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
48 #define ANGLE315_L ((ANGLE315 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
50 typedef double float64_t;
51 
52 typedef struct ANALOG_SENSOR_DATA {
53  uint32_t cosP_LSB;
54  uint32_t cosN_LSB;
55  uint32_t sinP_LSB;
56  uint32_t sinN_LSB;
58  int32_t diff_X;
59  int32_t diff_Y;
64 
65 typedef struct ROTATION_DATA_STORE {
70 
72 
73  int32_t maxCos;
74  int32_t minCos;
75  int32_t maxSin;
76  int32_t minSin;
102 
103 typedef struct CALIB_DATA {
106 
117 
118 } CALIB_DATA_t;
119 
120 void ONECALIB_InitSensorData(uint32_t cosP_in_LSB, uint32_t cosN_in_LSB, uint32_t sinP_in_LSB, uint32_t sinN_in_LSB);
121 void ONECALIB_InitCalibData(CALIB_DATA_t *param_store);
122 float64_t ONECALIB_GetAngle(const CALIB_DATA_t *calib_param);
124 float64_t ONECALIB_GetCalibAngle(const CALIB_DATA_t *calib_param);
125 void ONECALIB_CalibrationFindParam(CALIB_DATA_t *param_store, bool rotate_CW, bool rotate_CCW);
126 
127 
128 
129 /*=========================================================================*/
130 
131 #endif /* ONECALIB_H */
float64_t X135
Definition: onecalib.h:79
float64_t X45
Definition: onecalib.h:78
float64_t ONECALIB_GetAngle(const CALIB_DATA_t *calib_param)
Calculates the calibrated angle if calibration has been performed, else the uncalibrated angle...
Definition: onecalib.c:372
float64_t Y135_corr
Definition: onecalib.h:88
double float64_t
Definition: onecalib.h:50
struct ROTATION_DATA_STORE ROTATION_DATA_STORE_t
int32_t diff_X
Definition: onecalib.h:58
uint32_t sinP_LSB
Definition: onecalib.h:55
float64_t mean_offsetX
Definition: onecalib.h:110
float64_t Y45
Definition: onecalib.h:81
float64_t sin_ortho
Definition: onecalib.h:113
void ONECALIB_InitCalibData(CALIB_DATA_t *param_store)
Function used for CALIB_DATA_t data initialization. The pointer of type CALIB_DATA_t will be used to ...
Definition: onecalib.c:301
uint32_t cosP_LSB
Definition: onecalib.h:53
void ONECALIB_CalibrationFindParam(CALIB_DATA_t *param_store, bool rotate_CW, bool rotate_CCW)
This function is used to extract the calibration parameters. It should called until calib_param...
Definition: onecalib.c:468
uint32_t sinN_LSB
Definition: onecalib.h:56
float64_t Y45_corr
Definition: onecalib.h:87
struct CALIB_DATA CALIB_DATA_t
ROTATION_DATA_STORE_t rotation_data_CCW
Definition: onecalib.h:105
void ONECALIB_InitSensorData(uint32_t cosP_in_LSB, uint32_t cosN_in_LSB, uint32_t sinP_in_LSB, uint32_t sinN_in_LSB)
Function used for ANALOG_SENSOR_DATA_t data assignment.
Definition: onecalib.c:242
float64_t amplitudeY
Definition: onecalib.h:91
float64_t magnitude135
Definition: onecalib.h:97
float64_t mean_amplitudeY
Definition: onecalib.h:108
float64_t offsetY
Definition: onecalib.h:94
float64_t Y135
Definition: onecalib.h:82
int32_t diff_Y
Definition: onecalib.h:59
float64_t X45_corr
Definition: onecalib.h:84
float64_t ONECALIB_GetCalibAngle(const CALIB_DATA_t *calib_param)
Calculates the calibrated angle.
Definition: onecalib.c:414
float64_t mean_offsetY
Definition: onecalib.h:111
struct ANALOG_SENSOR_DATA ANALOG_SENSOR_DATA_t
float64_t offsetX
Definition: onecalib.h:93
float64_t X135_corr
Definition: onecalib.h:85
float64_t magnitude45
Definition: onecalib.h:96
float64_t cos_ortho
Definition: onecalib.h:114
ROTATION_DATA_STORE_t rotation_data_CW
Definition: onecalib.h:104
float64_t mean_amplitudeX
Definition: onecalib.h:107
float64_t amplitudeX
Definition: onecalib.h:90
bool full_calibration_performed
Definition: onecalib.h:116
float64_t uncalibratedAngle
Definition: onecalib.h:61
uint32_t cosN_LSB
Definition: onecalib.h:54
float64_t ortho_one_dir
Definition: onecalib.h:99
float64_t ONECALIB_GetUncalibAngle(void)
Calculates the uncalibrated angle.
Definition: onecalib.c:397