You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/CS5530.h
+12-7Lines changed: 12 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@
11
11
#ifndef CS5530_H
12
12
#defineCS5530_H
13
13
14
+
#include<SPI.h>
15
+
14
16
15
17
#defineSYSTEM_OFFSET3
16
18
#defineSYSTEM_GAIN4
@@ -48,7 +50,7 @@ typedef enum {
48
50
* @note This enumeration is based on the Tic Stepper Motor Controller User's Guide, available at
49
51
*
50
52
*/
51
-
enumclassCommand : uint8_t
53
+
typedefenum
52
54
{
53
55
OffsetRead = 0x09, ///< Read the offset value.
54
56
OffsetWrite = 0x01, ///< Write the offset value.
@@ -63,7 +65,7 @@ enum class Command : uint8_t
63
65
Sync1 = 0xFF, ///< Part of the serial port re-initialization sequence.
64
66
Sync0 = 0xFE, ///< End of the serial port re-initialization sequence.
65
67
Null = 0x00///< Clear a port flag and keep the converter in continuous conversion mode.
66
-
};
68
+
} Command;
67
69
68
70
typedefenum
69
71
{
@@ -150,10 +152,10 @@ class CS5530
150
152
floatgetWeight(bool allowNegativeWeights = false, uint8_t samplesToTake = 8); //Once you've set zero offset and cal factor, you can ask the library to do the calculations for you.
151
153
152
154
boolsetGain(uint8_t gainValue); // Set the gain. x1, 2, 4, 8, 16, 32, 64, 128 are available
153
-
boolsetSampleRate(uint8_t rate); // Set the readings per second. 10, 20, 40, 80, and 320 samples per second is available
155
+
boolsetSampleRate(uint32_t rate); // Set the readings per second. 10, 20, 40, 80, and 320 samples per second is available
154
156
155
-
uint8_tgetRegister(uint8_tregisterAddress); //Get contents of a register
156
-
boolsetRegister(uint8_tregisterAddress, uint32_t value); //Send a given value to be written to given address. Return true if successful
157
+
uint32_tgetRegister(uint8_tcommnad); //Get contents of a register
158
+
boolsetRegister(uint8_tcommand, uint32_t value); //Send a given value to be written to given address. Return true if successful
157
159
158
160
uint8_tconvert(uint8_t convertType, uint8_t regNo, int wordRate);
159
161
uint8_tcalibrate(uint8_t calibrateType, int cfgReg);
@@ -167,10 +169,13 @@ class CS5530
167
169
private:
168
170
SPISettings _spiSettings;
169
171
SPIClass* _spi;
170
-
int _ss;
172
+
int _chipSelectPin;
173
+
//y = mx+b
174
+
int32_t _zeroOffset; //This is b
175
+
float _calibrationFactor; //This is m. User provides this number so that we can output y when requested
0 commit comments