Changing the delays is simple. Use millis() an micros().
I think that Arduino uses 'boolean' instead of 'bool'.
You can change the printf into sending strings to the serial port.
But the SPI calls are the hardest to translate.
You have to rewrite every line that use low level SPI. I don't understand very well how the STM32F105 uses SPI, so I can't tell how to translate it.
Peter_n:
I think that Arduino uses ‘boolean’ instead of ‘bool’.
bool and boolean are both valid data types in C++. The Arduino can be programmed with C++, so it can use either data type.
Here’s a little sketch that shows the difference between bool and boolean
bool b;
boolean bn;
void setup() {
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
Serial.println("Setting b to 5. Setting bn to 5");
b = 5;
bn = 5;
Serial.print("b (bool) = ");
Serial.println(b);
b = !b;
Serial.print("!b (bool) = ");
Serial.println(b);
Serial.print("bn (boolean) = ");
Serial.println(bn);
bn = !bn;
Serial.print("!bn (boolean) = ");
Serial.println(bn);
Serial.println("-----------");
Serial.println("\nThe following truth table is for values of -2, 0, and +2");
Serial.println();
for (int i = -2; i < 3; i += 2) {
b = i;
bn = i;
Serial.print(b);
if (b) {
Serial.println(" b is true");
}
else {
Serial.println(" b is false");
}
Serial.print(bn);
if (bn) {
Serial.println(" bn is true");
}
else {
Serial.println(" bn is false");
}
Serial.println();
}
}
void loop() {
}
Thanks, I didn't know that.
So a 'boolean' is a byte of any value. A value of non-zero is true.
And a 'bool' is converted on the fly to 0 (false) or 1 (true).
The Arduino reference shows only 'boolean'.
And the description is : "A boolean holds one of two values, true or false". That description is more suitable for the 'bool'.