Initial rough start to the BQ76PL536A (or BQ76PL536A-Q1) code. Free to use as long as you make any changes/improvements publicly available. Please notify me of any improvements.

Committer:
dmwahl
Date:
Sun Jul 25 18:15:36 2021 +0000
Revision:
3:a0e12d12f780
Parent:
1:4ae1a58697d7
Initial rough start to the BQ76PL536A (or BQ76PL536A-Q1) code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dmwahl 3:a0e12d12f780 1 ///-----------------------------------------------------------------
dmwahl 3:a0e12d12f780 2 /// Description: BQ76PL536A Driver
dmwahl 3:a0e12d12f780 3 /// Author: David Wahl
dmwahl 3:a0e12d12f780 4 /// Date: 13-JUL-2021
dmwahl 3:a0e12d12f780 5 /// Notes: Initial release
dmwahl 3:a0e12d12f780 6 ///
dmwahl 3:a0e12d12f780 7 /// Revision History:
dmwahl 3:a0e12d12f780 8 /// Name: Date: Description:
dmwahl 3:a0e12d12f780 9 ///-----------------------------------------------------------------
dmwahl 3:a0e12d12f780 10
dmwahl 0:47a258755906 11 #ifndef BQ76PL536A_H
dmwahl 0:47a258755906 12 #define BQ76PL536A_H
dmwahl 0:47a258755906 13
dmwahl 0:47a258755906 14 #include "mbed.h"
dmwahl 0:47a258755906 15 #include "bq76pl536a_typedefs.h"
dmwahl 0:47a258755906 16
dmwahl 0:47a258755906 17 class BQ76PL536A
dmwahl 0:47a258755906 18 {
dmwahl 0:47a258755906 19 protected:
dmwahl 0:47a258755906 20 SPI spi;
dmwahl 0:47a258755906 21 DigitalOut cs;
dmwahl 3:a0e12d12f780 22
dmwahl 3:a0e12d12f780 23
dmwahl 3:a0e12d12f780 24
dmwahl 0:47a258755906 25 void setAddresses();
dmwahl 0:47a258755906 26 void softReset();
dmwahl 3:a0e12d12f780 27
dmwahl 1:4ae1a58697d7 28 u8t pec(u8t crcBuffer[], u8t crcLength);
dmwahl 0:47a258755906 29
dmwahl 0:47a258755906 30 public:
dmwahl 0:47a258755906 31 // (SPI object, PinName cs, u8t attachedCells[], u16t cov[mV], u16t cuv[mV], u8t balanceTimeout[sec], bool balanceEnabled)
dmwahl 0:47a258755906 32 BQ76PL536A(SPI _spi, PinName _cs, u8t _numDev, u16t _cov, u16t _cuv, u8t _balanceTimeout, bool balanceEnabled);
dmwahl 0:47a258755906 33 //BQ76PL536A(SPI _spi, PinName _cs);
dmwahl 0:47a258755906 34
dmwahl 0:47a258755906 35 BQ76PL536A();
dmwahl 3:a0e12d12f780 36
dmwahl 3:a0e12d12f780 37 bool read(u8t deviceAddress, u8t regAddress, u8t count, u8t *pRegisterValue);
dmwahl 3:a0e12d12f780 38 void write(u8t deviceAddress, u8t regAddress, u8t regData);
dmwahl 3:a0e12d12f780 39
dmwahl 3:a0e12d12f780 40 void adcConvert();
dmwahl 3:a0e12d12f780 41 bool readAll(u8t deviceAddress);
dmwahl 3:a0e12d12f780 42
dmwahl 0:47a258755906 43 u8t error, balanceTimeout;
dmwahl 0:47a258755906 44 u16t cov, cuv;
dmwahl 0:47a258755906 45 bool balanceEnabled;
dmwahl 0:47a258755906 46 u8t numDev, attachedCells[];
dmwahl 3:a0e12d12f780 47
dmwahl 3:a0e12d12f780 48 u8t bqPackData[65];
dmwahl 3:a0e12d12f780 49
dmwahl 3:a0e12d12f780 50 float cellVolts(u8t lobyte, u8t hibyte);
dmwahl 0:47a258755906 51 };
dmwahl 0:47a258755906 52
dmwahl 0:47a258755906 53 #endif