Hi,
I have a Pixhawk 6X and I want to send custom SPI messages through its SPI port. I found the SPI.hpp file in the firmware but its SPI class expects some sort of device type and device handle. So, to me, this seems to be too high-level. I simply want to send baremetal SPI messages similar to how I can with UART (open(), read() and write() functions). Can anyone point me to the right drivers for my need?
Like this:
uint8_t MPU9250::RegisterRead(Register reg)
{
uint8_t cmd[2] {};
cmd[0] = static_cast<uint8_t>(reg) | DIR_READ;
set_frequency(SPI_SPEED); // low speed for regular registers
transfer(cmd, cmd, sizeof(cmd));
return cmd[1];
}
void MPU9250::RegisterWrite(Register reg, uint8_t value)
{
uint8_t cmd[2] { (uint8_t)reg, value };
set_frequency(SPI_SPEED); // low speed for regular registers
transfer(cmd, cmd, sizeof(cmd));
}