ethan
2023-04-08 f5e277c240b9211a1f047b88788f34f3dd5a97c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef AS5601_H
#define AS5061_H
 
typedef struct AS5601_Magnet
{
    unsigned char magnet_status;
    unsigned char AGC;
    unsigned char MAGNITUDE_H4;
    unsigned char MAGNITUDE_L8;
} AS5601_Magnet_t;
 
typedef struct AS5601
{
    unsigned char id;
    unsigned char status;
    AS5601_Magnet_t magnet;
    unsigned short zero_pos;
    unsigned short angle;
    unsigned short raw_angle;
} AS5601_t;
 
typedef union AS5601_CONF
{
    unsigned short conf;
    struct
    {
        unsigned char sf : 2;
        unsigned char FTH : 3;
        unsigned char WD : 1;
        unsigned char reserved1 : 2;
        unsigned char PM : 2;
        unsigned char HYST : 2;
        unsigned char reserved2 : 4;
    } bit;
} AS5601_CONF_t;
 
typedef struct AS5601_Config
{
    unsigned short zero_pos;
    AS5601_CONF_t CONF;
    unsigned char ABN;
    unsigned char PUSHTHR;
} AS5601_Config_t;
 
typedef enum AS5601PowerMode
{
    NOM = 0x0,
    LPM1 = 1,
    LPM2 = 2,
    LPM3 = 3
} AS5601PowerMode_t;
 
typedef enum AS5601Hysteresis
{
    OFF = 0x0,
    LSB1 = 0x1,
    LSB2 = 0x2,
    LSB3 = 0x3
} AS5601Hysteresis_t;
 
typedef enum AS5601SlowFilter
{
    SlowFilter_16x = 0x0,
    SlowFilter_8x = 0x1,
    SlowFilter_4x = 0x2,
    SlowFilter_2x = 0x3
} AS5601SlowFilter_t;
 
typedef enum AS5601FastFilter
{
    FastFilter_slow = 0x0,
    FastFilter_6LSB = 0x1,
    FastFilter_7LSB = 0x2,
    FastFilter_9LSB = 0x3,
    FastFilter_18LSB = 0x4,
    FastFilter_21LSB = 0x5,
    FastFilter_24LSB = 0x6,
    FastFilter_10LSB = 0x7
} AS5601FastFilter_t;
typedef enum AS5601ABN
{
    ABN_61Hz = 0x0,
    ABN_122Hz = 0x1,
    ABN_244Hz = 0x2,
    ABN_488Hz = 0x3,
    ABN_976Hz = 0x4,
    ABN_1k9Hz = 0x5,
    ABN_3k9Hz = 0x6,
    ABN_7k8Hz = 0x7,
    ABN_15k6Hz = 0x8
} AS5601ABN_t;
 
extern uint16_t Hal_GetHallSensorRawValue(uint8_t channel);
#endif