Skip to content

Commit b0180ac

Browse files
committed
Implement support for I2C QMI8658 IMU
Signed-off-by: Daniël van de Giessen <[email protected]>
1 parent d1cf81a commit b0180ac

File tree

16 files changed

+1357
-0
lines changed

16 files changed

+1357
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ src/addons/input_macro.cpp
232232
src/addons/snes_input.cpp
233233
src/addons/tilt.cpp
234234
src/addons/spi_analog_ads1256.cpp
235+
src/addons/i2c_qmi8658.cpp
235236
${PROTO_OUTPUT_DIR}/enums.pb.c
236237
${PROTO_OUTPUT_DIR}/config.pb.c
237238
)
@@ -262,6 +263,7 @@ WiiExtension
262263
SNESpad
263264
pico_mbedtls
264265
nanopb
266+
QMI8658
265267
)
266268

267269
target_include_directories(${PROJECT_NAME} PUBLIC

headers/addons/i2c_qmi8658.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef _I2C_QMI8658_H
2+
#define _I2C_QMI8658_H
3+
4+
extern "C" {
5+
#include "QMI8658.h"
6+
}
7+
8+
#include "gpaddon.h"
9+
10+
#include "GamepadEnums.h"
11+
#include "peripheralmanager.h"
12+
13+
#ifndef I2C_QMI8658_ENABLED
14+
#define I2C_QMI8658_ENABLED 0
15+
#endif
16+
17+
// Analog Module Name
18+
#define I2C_QMI8658_Name "I2C_QMI8658"
19+
20+
class I2CQMI8658Input : public GPAddon {
21+
public:
22+
virtual bool available();
23+
virtual void setup();
24+
virtual void preprocess() {}
25+
virtual void process();
26+
virtual std::string name() { return I2C_QMI8658_Name; }
27+
private:
28+
PeripheralI2C *i2c;
29+
uint32_t uIntervalMS;
30+
uint32_t nextTimer;
31+
int16_t acc[3];
32+
int16_t gyro[3];
33+
};
34+
35+
#endif // _I2C_QMI8658_H_

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ add_subdirectory(PlayerLEDs)
1313
add_subdirectory(rndis)
1414
add_subdirectory(WiiExtension)
1515
add_subdirectory(SNESpad)
16+
add_subdirectory(QMI8658)

lib/QMI8658/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_library(QMI8658 QMI8658.c)
2+
target_link_libraries(QMI8658 PUBLIC PicoPeripherals)
3+
target_include_directories(QMI8658 INTERFACE .)
4+
target_include_directories(QMI8658 PUBLIC . PicoPeripherals)

0 commit comments

Comments
 (0)