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.
Dependencies: mbed Watchdog stm32-sensor-base2
Diff: AS5045/AS5045.cpp
- Revision:
- 12:406f75196a12
- Parent:
- 5:97117a837d2c
- Child:
- 18:025d9a617769
--- a/AS5045/AS5045.cpp Wed Aug 26 14:26:27 2020 +0530 +++ b/AS5045/AS5045.cpp Sun Dec 06 11:05:19 2020 +0000 @@ -15,10 +15,10 @@ _cs(CS) // Digital output pin init { // Set SPI bitwidth9 - _spi.format(9, 2); + _spi.format(8, 1); // Set SPI frequency - _spi.frequency(500000);//SPI_FREQ); + _spi.frequency(SPI_FREQ);//SPI_FREQ); // Set the digital output high _cs = 1; } @@ -64,7 +64,7 @@ //upper &=~ 0xF0;//mask out the first 4 bits // EncoderByteData = upper << 8; //shift MSB to correct EncoderByteData in EncoderByteData message // EncoderByteData += lower; // add LSB to EncoderByteData message to complete message - return ((upper << 3)+(lower >> 6)); + return ((upper << 2)|(lower >> 6)); //return EncoderByteData; } @@ -73,7 +73,7 @@ * @note * Tick amount is recieved internally */ -float AS5045::getRotation() +float AS5045::getAngle() { // Get data from the encoder float value = (float)getPosition();