openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 lines
577 B

#pragma once
#include <cstdint>
#include "cereal/gen/cpp/log.capnp.h"
#include "common/i2c.h"
#include "sensors/constants.hpp"
int16_t read_12_bit(uint8_t lsb, uint8_t msb);
int16_t read_16_bit(uint8_t lsb, uint8_t msb);
class I2CSensor {
private:
I2CBus *bus;
virtual uint8_t get_device_address() = 0;
public:
I2CSensor(I2CBus *bus);
int read_register(uint register_address, uint8_t *buffer, uint8_t len);
int set_register(uint register_address, uint8_t data);
virtual int init() = 0;
virtual void get_event(cereal::SensorEventData::Builder &event) = 0;
};