Руслан Бредун / Mbed 2 deprecated stm32-sensor-base2

Dependencies:   mbed Watchdog

Dependents:   STM32-MC_node

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AS5045.h Source File

AS5045.h

00001 #ifndef AS5045_H
00002 #define AS5045_H
00003 
00004 #include "mbed.h"
00005 
00006 // Class which implements AS5045 encoder interface
00007 class AS5045
00008 {
00009 public:
00010   AS5045(PinName cs);                               // Constructor
00011 
00012   int getPosition();                                    // Read tick amount from encoder (position)
00013   float getAngle();                             // Convert position of the encoder to degrees
00014 
00015 private:
00016   SPI _spi;                                             // MBED SPI instance
00017   DigitalOut _cs;
00018   uint16_t EncoderByteData;                                     // MBED digital output pin
00019 
00020   static const float MAX_VALUE = 1024;          // Maximum possible encoder position value (ticks for full rotation)
00021   static const float RESOLUTION = 0.3515625;    // Encoder resolution (0.08789 degrees per tick)
00022   static const float SPI_FREQ = 500000;     // Frequency of the SPI bus
00023 };
00024 
00025 #endif  // AS5045_H