Sygaldry
Loading...
Searching...
No Matches
sygsp-icm20948_aux_serif.hpp
1/*
2Copyright 2023 Travis J. West, https://traviswest.ca, Input Devices and Music
3Interaction Laboratory (IDMIL), Centre for Interdisciplinary Research in Music
4Media and Technology (CIRMMT), McGill University, Montréal, Canada, and Univ.
5Lille, Inria, CNRS, Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
6
7SPDX-License-Identifier: MIT
8*/
9#pragma once
10#include <cstdint>
11#include "sygsp-delay.hpp"
12#include "sygsp-icm20948_registers.hpp"
13
14namespace sygaldry { namespace sygsp {
18
30template<typename Serif, uint8_t i2c_address>
32{
33 using Registers = ICM20948Registers<Serif>;
34
36 [[nodiscard]] static uint8_t read(uint8_t register_address)
37 {
38 Registers::I2C_SLV4_ADDR::write(1<<8 | i2c_address);
39 Registers::I2C_SLV4_REG::write(register_address);
40 Registers::I2C_SLV4_CTRL::I2C_SLV4_EN::trigger();
41 delay(1);
42 return Registers::I2C_SLV4_DI::read();
43 }
44
46 static void write(uint8_t register_address, uint8_t value)
47 {
48 Registers::I2C_SLV4_ADDR::write(1<<8 | i2c_address);
49 Registers::I2C_SLV4_REG::write(register_address);
50 Registers::I2C_SLV4_DO::write(value);
51 Registers::I2C_SLV4_CTRL::I2C_SLV4_EN::trigger();
52 }
53};
54
57} }
void delay(unsigned long ms)
Definition sygsa-delay.cpp:14
Definition sygsp-icm20948_aux_serif.hpp:32
static void write(uint8_t register_address, uint8_t value)
Write one byte.
Definition sygsp-icm20948_aux_serif.hpp:46
static uint8_t read(uint8_t register_address)
Read one byte and return it.
Definition sygsp-icm20948_aux_serif.hpp:36
Definition sygsp-icm20948_registers.hpp:27