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:
- 3:a8ad32e439d4
- Parent:
- 2:2958500883e0
- Child:
- 4:06b89a41109e
--- a/as5048spi.h Thu Dec 04 10:00:42 2014 +0000
+++ b/as5048spi.h Tue Mar 17 14:46:45 2015 +0000
@@ -6,7 +6,7 @@
typedef enum {
AS_CMD_NOP = 0x0000,
- AS_CMD_ERROR = 0x0001 | AS_FLAG_READ, // Reads error ireguster and clear error flags
+ AS_CMD_ERROR = 0x0001 | AS_FLAG_READ, // Reads error register of sensor and clear error flags
AS_CMD_DIAGNOSTICS = 0x3FFD | AS_FLAG_READ, // Reads automatic gain control and diagnostics info
AS_CMD_MAGNITUDE = 0x3FFE | AS_FLAG_READ,
@@ -29,8 +29,18 @@
~As5048Spi();
bool error(int device = -1);
+
+ /// Sets the SPI clock frequency in Hz. Maximum tested frequency is 10MHz.
void frequency(int frequency = 1000000);
+
+ /// Sends a read command to the sensor.
const int* read(As5048Command command);
+
+ /// Sends a read command to the sensor.
+ /// A call to this function will not directly return the requested value. The
+ /// requested value will be returned in a next read_sequential call.
+ /// Use this function to read sensor values with minimum speed impact on SPI-bus
+ /// and microcontroller.
const int* read_sequential(As5048Command command);
/// Performs a single angle measurement on all sensors
@@ -49,11 +59,19 @@
/// Returns lowest 14-bits
static int mask(int sensor_result);
+
+ /// Applies the mask to the first n bytes in the read buffer (for daisychained sensors).
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);
+
+ /// Returns an angle from 0 to 36000 (degrees times 100).
+ /// @param sensor_result is one of the values returned by read_angle or read_angle_sequential
static int degrees(int sensor_result);
+
+ /// Returns an angle from 0 to 2*PI*100
+ /// @param sensor_result is one of the values returned by read_angle or read_angle_sequential
static int radian(int sensor_result);