Translate spi ready from Arduino top stm
Hi I wanted to translate the following Arduino code with hal stm:
uint32_t TMC5160_SPI::readRegister(uint8_t address)
{
// request the read for the address
_beginTransaction();
_spi->transfer(address);
_spi->transfer(0x00);
_spi->transfer(0x00);
_spi->transfer(0x00);
_spi->transfer(0x00);
_endTransaction();
//Delay for the minimum CSN high time (2tclk + 10ns -> 176ns with the default 12MHz clock)
#ifdef TEENSYDUINO
delayNanoseconds(2 * 1000000000 / _fclk + 10);
#else
delayMicroseconds(1);
#endif
// read it in the second cycle
_beginTransaction();
_spi->transfer(address);
uint32_t value = 0;
value |= (uint32_t)_spi->transfer(0x00) << 24;
value |= (uint32_t)_spi->transfer(0x00) << 16;
value |= (uint32_t)_spi->transfer(0x00) << 8;
value |= (uint32_t)_spi->transfer(0x00);
_endTransaction();
_lastRegisterReadSuccess = true; // In SPI mode there is no way to know if the TMC5130 is plugged...
return value;
}
Thanks
