Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: as5048spi.h
- Revision:
- 2:2958500883e0
- Parent:
- 0:3edcf58e51e7
- Child:
- 3:a8ad32e439d4
--- a/as5048spi.h Thu Sep 18 19:28:25 2014 +0000
+++ b/as5048spi.h Thu Dec 04 10:00:42 2014 +0000
@@ -13,6 +13,13 @@
AS_CMD_ANGLE = 0x3FFF| AS_FLAG_PARITY | AS_FLAG_READ,
} As5048Command;
+// Masks for bits in the result of the AS_CMD_DIAGNOSTICS command
+typedef enum {
+ AS_DIAG_CORDIC_OVERFLOW = 0x0200,
+ AS_DIAG_HIGH_MAGNETIC = 0x0400,
+ AS_DIAG_LOW_MAGNETIC = 0x0800,
+} As5048Diagnostics;
+
class As5048Spi
@@ -26,12 +33,25 @@
const int* read(As5048Command command);
const int* read_sequential(As5048Command command);
+ /// Performs a single angle measurement on all sensors
+ /// @return Array of raw angle data. To get the 14-bit value representing
+ /// the angle, apply the mask() to the result.
+ /// To get an angle in degrees divide 360 by the result of the call to mask().
const int* read_angle();
+
+ /// Performs sequential angle measurements on all sensors. The first time this
+ /// method is called the result is not usefull, the measurement data of the call
+ /// will be returned by the next call to this method.
+ /// @return Array of raw angle data. To get the 14-bit value representing
+ /// the angle, apply the mask() to the result.
+ /// To get an angle in degrees divide 360 by the result of the call to mask().
const int* read_angle_sequential();
-
+ /// Returns lowest 14-bits
static int mask(int sensor_result);
-
+ static void mask(int* sensor_results, int n);
+ /// Checks if the return value from the sensor has the right parity
+ /// @return true if ok
static bool parity_check(int sensor_result);
static int degrees(int sensor_result);
static int radian(int sensor_result);