Skip to content

Commit e091ab9

Browse files
author
Max 'MaxMax' Mönikes
committed
Fix for Platform compatibility and voltage readout
1 parent 865d4a7 commit e091ab9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

TLE9012.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,24 @@ TLE9012::~TLE9012() //Destructor
7373
* @param txpin optional parameter to specify TX Pin under some architectures
7474
*/
7575

76-
void TLE9012::init(HardwareSerial* serial, uint32_t baudrate=1000000,uint8_t rxpin=0,uint8_t txpin=0)//Driver init
76+
void TLE9012::init(HardwareSerial* serial, uint32_t baudrate,uint8_t rxpin,uint8_t txpin)//Driver init
7777
{
7878
hisoUART = serial;
7979
if((rxpin != 0) && (txpin != 0))
80+
{
81+
#ifdef ARDUINO_ARCH_ESP32
8082
hisoUART->begin(baudrate,SERIAL_8N1,rxpin,txpin);
83+
#else
84+
hisoUART->begin(baudrate,SERIAL_8N1);
85+
#endif
86+
}
8187
else
88+
{
8289
hisoUART->begin(baudrate,SERIAL_8N1);
90+
}
8391
}
8492

93+
8594
/**
8695
* @brief Wakeup all TLE9012 devices on the Bus
8796
*
@@ -147,7 +156,7 @@ void TLE9012::wakeUp()
147156

148157
for(uint8_t n = 0; n < devices[deviceID].n_cells; n++)
149158
{
150-
(void) readRegisterSingle(nodeID, PCVM_0 + (11-devices[deviceID].n_cells + n), &devices[deviceID].cell_voltages[n]);
159+
(void) readRegisterSingle(nodeID, PCVM_0 + (12-devices[deviceID].n_cells + n), &devices[deviceID].cell_voltages[n]);
151160
}
152161

153162
(void) readRegisterSingle(nodeID,BVM,&devices[deviceID].block_voltage);

TLE9012.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ typedef struct
335335

336336

337337

338-
void init(HardwareSerial* serial, uint32_t baudrate,uint8_t rxpin,uint8_t txpin);//Driver init
338+
void init(HardwareSerial* serial,uint32_t baudrate,uint8_t rxpin,uint8_t txpin);//Driver init
339339
void wakeUp();
340340

341341

0 commit comments

Comments
 (0)