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: PositionSensor/PositionSensor.cpp
- Revision:
- 36:d88fd41f60a6
- Parent:
- 35:69b24894c11d
- Child:
- 37:c0f352d6e8e3
--- a/PositionSensor/PositionSensor.cpp Sat Nov 18 18:41:42 2017 +0000
+++ b/PositionSensor/PositionSensor.cpp Fri Mar 02 15:24:00 2018 +0000
@@ -11,7 +11,7 @@
ElecOffset = offset;
rotations = 0;
spi = new SPI(PC_12, PC_11, PC_10);
- spi->format(8, 1); // mbed v>127 breaks 16-bit spi, so transaction is broken into 2 8-bit words
+ spi->format(16, 1); // mbed v>127 breaks 16-bit spi, so transaction is broken into 2 8-bit words
spi->frequency(25000000);
cs = new DigitalOut(PA_15);
cs->write(1);
@@ -25,10 +25,7 @@
void PositionSensorAM5147::Sample(){
cs->write(0);
- int raw1 = spi->write(0xFF);
- int raw2 = spi->write(0xFF);
- raw = (raw1<<8)|raw2;
- //raw = spi->write(readAngleCmd);
+ raw = spi->write(readAngleCmd);
raw &= 0x3FFF; //Extract last 14 bits
cs->write(1);
int off_1 = offset_lut[raw>>7];