DevLab_ICM20948 1.0.2 ICM-20948 9-Axis Motion Sensor Driver

Loading...
Searching...
No Matches
7Semi_Interface.h
Go to the documentation of this file.
1// #pragma once
2#ifndef INTERFACE_7SEMI_H
3#define INTERFACE_7SEMI_H
4
5#include <Arduino.h>
6#include <Wire.h>
7#include <SPI.h>
8
9/**
10 * 7Semi Universal Interface Layer
11 *
12 * - Abstract communication layer for I2C / SPI
13 * - Ensures sensor drivers remain hardware independent
14 */
15 class Interface_7Semi {
16 public:
17
18 virtual ~Interface_7Semi() {}
19
20 /**
21 * beginI2C()
22 *
23 * - Initializes I2C peripheral
24 * - Configures SDA / SCL pins if supported
25 * - Sets communication clock
26 *
27 * Returns:
28 * - true → Initialization successful
29 * - false → Initialization failed
30 */
31 virtual bool beginI2C(
32 uint8_t address,
33 TwoWire &wire,
34 uint32_t speed,
35 uint8_t sda = 255,
36 uint8_t scl = 255) = 0;
37
38 virtual bool beginSPI(
39 uint8_t cs_pin,
40 SPIClass &wire,
41 uint32_t speed,
42 uint8_t csk = 255,
43 uint8_t miso = 255,
44 uint8_t mosi = 255) = 0;
45
46
47 /**
48 * read()
49 *
50 * - Reads data from device register
51 *
52 * Parameters:
53 * - reg : Register address
54 * - data : Output buffer
55 * - len : Number of bytes
56 *
57 * Returns:
58 * - 0 → Success
59 * - <0 → Error
60 */
61 virtual int8_t read(
62 uint8_t reg,
63 uint8_t *data,
64 uint32_t len) = 0;
65
66 /**
67 * write()
68 *
69 * - Writes data to device register
70 *
71 * Returns:
72 * - 0 → Success
73 * - <0 → Error
74 */
75 virtual int8_t write(
76 uint8_t reg,
77 const uint8_t *data,
78 uint32_t len) = 0;
79
80 protected:
81 /** Delay wrapper */
82 static void delay_us(uint32_t us)
83 {
84 delayMicroseconds(us);
85 }
86};
87#endif
Interface_7Semi
Definition 7Semi_Interface.h:15
Interface_7Semi::write
virtual int8_t write(uint8_t reg, const uint8_t *data, uint32_t len)=0
Interface_7Semi::beginSPI
virtual bool beginSPI(uint8_t cs_pin, SPIClass &wire, uint32_t speed, uint8_t csk=255, uint8_t miso=255, uint8_t mosi=255)=0
Interface_7Semi::delay_us
static void delay_us(uint32_t us)
Definition 7Semi_Interface.h:82
Interface_7Semi::~Interface_7Semi
virtual ~Interface_7Semi()
Definition 7Semi_Interface.h:18
Interface_7Semi::read
virtual int8_t read(uint8_t reg, uint8_t *data, uint32_t len)=0
Interface_7Semi::beginI2C
virtual bool beginI2C(uint8_t address, TwoWire &wire, uint32_t speed, uint8_t sda=255, uint8_t scl=255)=0