-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAMS_5601.h
77 lines (62 loc) · 2.64 KB
/
AMS_5601.h
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
/****************************************************
/* AMS 5601 class for Arduino
/* Author: Tom Denton
/* Edit from 5600 to 5601: David Criado
/* Date: 13 Mar 2017
/* File: AMS_5601.cpp
/* Version 2.00
/* www.ams.com
/*
/* Description: This class has been designed to
/* access the AMS AS5601 sensor.
/*
/***************************************************/
#ifndef _AMS_5601_H_
#define _AMS_5601_H_
#include <Arduino.h>
class AMS_5601
{
public:
AMS_5601(void);
int getAddress(); // get AMS5601 address, set and fixed to 0x36
word setZeroPosition(word zeroAngle = -1); // set zero position to the angle determined
word getZeroPosition(); // get value of zero position
word setABN(word inputResolution = -1); // set update rate and resolution of measurement
word getABN(); // get such values
word getRawAngle(); // get angle without zero position
word getScaledAngle(); // get angle referred to zero position
int detectMagnet(); // looks for MD/ML/MH in the status register
int getMagnetStrength(); // checks if magnet too weak/strong/just right
int getAgc(); // indicates the gain
word getMagnitude(); // indicates the internal CORDIC output
int getBurnCount(); // retrieves number of burns from zmco
int burnAngle(); // MOD from 5600 burnAngle burns zero Angle
int burnConfig(); // MOD from 5600 burnMaxAngleAndConfig burns settings
private:
int _ams5601_Address; // chip i2c address
word _resolution; // ABN mapping (0x09)
word _updateRate; // ABN mapping (0x09)
word _rawStartAngle; //
word _zPosition; // zero position
/* Registers */
int _zmco;
int _zpos_hi; // zpos[11:8] high nibble START POSITION
int _zpos_lo; // zpos[7:0]
int _conf_hi;
int _conf_lo;
int _raw_ang_hi;
int _raw_ang_lo;
int _ang_hi;
int _ang_lo;
int _stat;
int _agc;
int _mag_hi;
int _mag_lo;
int _burn;
int _abn;
int _pushthr;
int readOneByte (int in_adr);
word readTwoBytes(int in_adr_hi, int in_adr_lo);
void writeOneByte(int adr_in, int dat_in);
};
#endif