40 #include <px4_platform_common/px4_config.h> 48 #include <sys/types.h> 51 #include <arch/board/board.h> 57 #include "board_config.h" 60 #if defined(PX4_SPIDEV_RM) || defined (PX4_SPIDEV_RM_EXT) 63 #define DIR_READ (1<<7) 64 #define DIR_WRITE (0<<7) 66 class RM3100_SPI :
public device::SPI
69 RM3100_SPI(
int bus, uint32_t
device);
70 virtual ~RM3100_SPI() =
default;
73 virtual int ioctl(
unsigned operation,
unsigned &arg);
74 virtual int read(
unsigned address,
void *
data,
unsigned count);
75 virtual int write(
unsigned address,
void *
data,
unsigned count);
84 #ifdef PX4_SPIDEV_RM_EXT 85 return new RM3100_SPI(bus, PX4_SPIDEV_RM_EXT);
87 return new RM3100_SPI(bus, PX4_SPIDEV_RM);
91 RM3100_SPI::RM3100_SPI(
int bus, uint32_t
device) :
92 SPI(
"RM3100_SPI", nullptr, bus, device,
SPIDEV_MODE3, 1 * 1000 * 1000 )
125 RM3100_SPI::ioctl(
unsigned operation,
unsigned &arg)
134 case DEVIOCGDEVICEID:
135 return CDev::ioctl(
nullptr, operation, arg);
150 if (
sizeof(buf) < (count + 1)) {
156 int ret = transfer(&buf[0], &buf[0], count + 1);
157 memcpy(data, &buf[1], count);
166 if (
sizeof(buf) < (count + 1)) {
171 memcpy(&buf[1], data, count);
173 return transfer(&buf[0], &buf[0], count + 1);
#define MAGIOCGEXTERNAL
determine if mag is external or onboard
Namespace encapsulating all device framework classes, functions and data.
static void read(bootloader_app_shared_t *pshared)
Generic device / sensor interface.
void init()
Activates/configures the hardware registers.
#define DRV_MAG_DEVTYPE_RM3100
static void write(bootloader_app_shared_t *pshared)
Fundamental base class for all physical drivers (I2C, SPI).
Shared defines for the RM3100 driver.
#define DEVICE_DEBUG(FMT,...)
device::Device * RM3100_SPI_interface(int bus)