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.

bq76pl536a.h

Committer:
dmwahl
Date:
2020-07-29
Revision:
1:4ae1a58697d7
Parent:
0:47a258755906
Child:
3:a0e12d12f780

File content as of revision 1:4ae1a58697d7:

#ifndef BQ76PL536A_H
#define BQ76PL536A_H

#include "mbed.h"
#include "bq76pl536a_typedefs.h"

class BQ76PL536A
{
protected:
    SPI spi;
    DigitalOut cs;
    
    bool *read(u8t deviceAddress, u8t regAddress, u8t count, u8t *pRegisterValue);
    void write(u8t deviceAddress, u8t regAddress, u8t regData);
    
    void adcConvert();
    void setAddresses();
    void softReset();
    
    u8t pec(u8t crcBuffer[], u8t crcLength);

public:
    // (SPI object, PinName cs, u8t attachedCells[], u16t cov[mV], u16t cuv[mV], u8t balanceTimeout[sec], bool balanceEnabled)
    BQ76PL536A(SPI _spi, PinName _cs, u8t _numDev,  u16t _cov, u16t _cuv, u8t _balanceTimeout, bool balanceEnabled);
    //BQ76PL536A(SPI _spi, PinName _cs);

    BQ76PL536A();
    u8t error, balanceTimeout;
    u16t cov, cuv;
    bool balanceEnabled;
    u8t numDev, attachedCells[];
    
    u8t devStatus();
};

#endif