2016-02-17 21:25:15 -04:00
|
|
|
#pragma once
|
2014-11-25 01:57:54 -04:00
|
|
|
|
2015-08-11 03:28:42 -03:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <AP_Math/AP_Math.h>
|
2014-11-25 01:57:54 -04:00
|
|
|
#include "AP_BattMonitor_SMBus.h"
|
2016-04-19 13:11:29 -03:00
|
|
|
#include <AP_HAL/I2CDevice.h>
|
|
|
|
|
2017-02-08 20:28:14 -04:00
|
|
|
class AP_BattMonitor_SMBus_Solo : public AP_BattMonitor_SMBus
|
2014-11-25 01:57:54 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor
|
2017-02-08 20:28:14 -04:00
|
|
|
AP_BattMonitor_SMBus_Solo(AP_BattMonitor &mon, uint8_t instance,
|
2016-04-19 13:11:29 -03:00
|
|
|
AP_BattMonitor::BattMonitor_State &mon_state,
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);
|
2014-11-25 01:57:54 -04:00
|
|
|
|
2017-02-08 20:28:14 -04:00
|
|
|
// read does nothing, all done in timer
|
|
|
|
void read() override;
|
2014-11-25 01:57:54 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-01-13 15:26:14 -04:00
|
|
|
void timer(void);
|
2016-11-04 00:54:51 -03:00
|
|
|
|
2014-11-25 01:57:54 -04:00
|
|
|
// read word from register
|
|
|
|
// returns true if read was successful, false if failed
|
|
|
|
bool read_word(uint8_t reg, uint16_t& data) const;
|
|
|
|
|
|
|
|
// read_block - returns number of characters read if successful, zero if unsuccessful
|
|
|
|
uint8_t read_block(uint8_t reg, uint8_t* data, uint8_t max_len, bool append_zero) const;
|
2014-12-29 22:10:01 -04:00
|
|
|
|
|
|
|
// get_PEC - calculate PEC for a read or write from the battery
|
|
|
|
// buff is the data that was read or will be written
|
|
|
|
uint8_t get_PEC(const uint8_t i2c_addr, uint8_t cmd, bool reading, const uint8_t buff[], uint8_t len) const;
|
2016-04-19 13:11:29 -03:00
|
|
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
|
2017-02-08 20:28:14 -04:00
|
|
|
uint8_t _button_press_count;
|
2014-11-25 01:57:54 -04:00
|
|
|
};
|