45 #define DIR_READ (1<<7) 46 #define DIR_WRITE (0<<7) 48 #define HMC_MAX_SEND_LEN 4 49 #define HMC_MAX_RCV_LEN 8 53 class LPS25H_SPI :
public device::SPI
56 LPS25H_SPI(
int bus, uint32_t
device);
57 virtual ~LPS25H_SPI() =
default;
60 virtual int read(
unsigned address,
void *
data,
unsigned count);
61 virtual int write(
unsigned address,
void *
data,
unsigned count);
63 virtual int ioctl(
unsigned operation,
unsigned &arg);
70 return new LPS25H_SPI(bus, PX4_SPIDEV_HMC);
73 LPS25H_SPI::LPS25H_SPI(
int bus, uint32_t
device) :
74 SPI(
"LPS25H_SPI", nullptr, bus, device,
SPIDEV_MODE3, 11 * 1000 * 1000 )
76 _device_id.devid_s.devtype = DRV_MAG_DEVTYPE_LPS25H;
94 if (
read(ADDR_ID, &
id, 1)) {
108 LPS25H_SPI::ioctl(
unsigned operation,
unsigned &arg)
114 case DEVIOCGDEVICEID:
115 return CDev::ioctl(
nullptr, operation, arg);
130 if (
sizeof(buf) < (count + 1)) {
135 memcpy(&buf[1], data, count);
137 return transfer(&buf[0], &buf[0], count + 1);
145 if (
sizeof(buf) < (count + 1)) {
151 int ret = transfer(&buf[0], &buf[0], count + 1);
152 memcpy(data, &buf[1], count);
Shared defines for the lps25h driver.
device::Device * LPS25H_SPI_interface(int bus)
Namespace encapsulating all device framework classes, functions and data.
static void read(bootloader_app_shared_t *pshared)
void init()
Activates/configures the hardware registers.
virtual int read(unsigned address, void *data, unsigned count)
static void write(bootloader_app_shared_t *pshared)
Fundamental base class for all physical drivers (I2C, SPI).
#define DEVICE_DEBUG(FMT,...)