Skip to content

Commit 8cab7cd

Browse files
committed
and the example
1 parent a8fee49 commit 8cab7cd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <SimpleFOC.h>
2+
3+
// MagneticSensorSPI(int cs, float _cpr, int _angle_register)
4+
// config - SPI config
5+
// cs - SPI chip select pin
6+
MagneticSensorSPI sensor = MagneticSensorSPI(AS5147_SPI, PA15);
7+
8+
// these are valid pins (mosi, miso, sclk) for 2nd SPI bus on storm32 board (stm32f107rc)
9+
SPIClass SPI_2(PB15, PB14, PB13);
10+
11+
void setup() {
12+
// monitoring port
13+
Serial.begin(115200);
14+
15+
// initialise magnetic sensor hardware
16+
sensor.init(&SPI_2);
17+
18+
Serial.println("Sensor ready");
19+
_delay(1000);
20+
}
21+
22+
void loop() {
23+
// display the angle and the angular velocity to the terminal
24+
Serial.print(sensor.getAngle());
25+
Serial.print("\t");
26+
Serial.println(sensor.getVelocity());
27+
}

0 commit comments

Comments
 (0)