test

Dependencies:   mbed Watchdog

Dependents:   STM32-MC_node

Revision:
0:d383e2dee0f7
Child:
4:f6e22dd39313
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AS5045/AS5045.h	Mon Jul 06 17:18:59 2020 +0530
@@ -0,0 +1,24 @@
+#ifndef AS5045_H
+#define AS5045_H
+
+#include "mbed.h"
+
+// Class which implements AS5045 encoder interface
+class AS5045
+{
+public:
+  AS5045(PinName cs);								// Constructor
+
+  int getPosition();									// Read tick amount from encoder (position)
+  float getRotation();								// Convert position of the encoder to degrees
+
+private:
+  SPI _spi;												// MBED SPI instance
+  DigitalOut _cs;										// MBED digital output pin
+
+  static const float MAX_VALUE = 4095;			// Maximum possible encoder position value (ticks for full rotation)
+  static const float RESOLUTION = 0.08789;	// Encoder resolution (0.08789 degrees per tick)
+  static const float SPI_FREQ = 500000;		// Frequency of the SPI bus
+};
+
+#endif	// AS5045_H