Skip to content

Instantly share code, notes, and snippets.

@kvalv
Created March 11, 2016 13:16
Show Gist options
  • Select an option

  • Save kvalv/2881cbb937feb4471770 to your computer and use it in GitHub Desktop.

Select an option

Save kvalv/2881cbb937feb4471770 to your computer and use it in GitHub Desktop.
// New interface
enum RegisterGroup { CONFIG, CELLA, CELLB, CELLC, AUXA, AUXB, STATA, STATB };
struct configRegisterStruct
{
bool refon;
bool adcModeOpt;
uint16_t underVoltageMonitoringEnable_bm;
uint16_t overVoltageMonitoringEnable_bm;
uint16_t dischargeCellEnable_bm;
enum dischargeTimeoutValue;
};
union RegisterData
{
uint8_t rawData[8];
struct {
uint8_t GPIO_Vaue : 5;
uint8_t refon : 1;
uint8_t swton : 1;
uint8_t adcModeOpt : 1;
uint16_t underVoltage : 12;
uint16_t overVoltage : 12;
uint16_t dischargeEnable : 12;
uint8_t disctahregTimeout : 4;
} config;
struct {
uint16_t cellVoltage1;
uint16_t cellVoltage2;
uint16_t cellVoltage3;
} cellVoltageA;
};
void wakeup( void );
void / bool ltc6804_sendCommand ( enum command, /*int numberOfUnits = 12*/)
bool readRegister ( enum register, RegisterData* pRxBuffer )
void / bool writeConfigurationRegister ( struct configRegisterStruct )
#endif /* LTC6804_H_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment