@@ -29,41 +29,45 @@ SOFTWARE.
29
29
30
30
TLE9012 tle9012;
31
31
32
+ ntc_config_t ntc_config = {.ntc_resistance =100000 ,.ntc_b_value =3000 };
33
+
34
+
32
35
void setup () {
33
36
// put your setup code here, to run once:
34
37
tle9012.init (&Serial2, 2000000 ,16 ,17 );
35
38
Serial.begin (115200 );
36
39
Serial.println (" Boot completed" );
37
40
tle9012.wakeUp ();
38
41
delay (200 );
39
- tle9012.writeRegisterSingle (0 , 0x01 , 0x0FFF );
40
- tle9012.writeRegisterSingle (0 , 0x36 , 0x0800 );
42
+ tle9012.setExtendedWatchdog (0 );
43
+ tle9012.setNodeID (0 , 1 , 1 );
44
+ tle9012.writeMailboxRegister (1 , 0xAA55 );
45
+
46
+ uint16_t mailbox = tle9012.readMailboxRegister (1 );
47
+ if (mailbox == 0xAA55 )
48
+ Serial.println (" Mailbox Check completed" );
49
+
50
+ tle9012.setNumberofCells (1 , 12 );
51
+ tle9012.setTempSensorsConfig (1 , 5 , ntc_config);
52
+ uint16_t ptconf = 0 ;
53
+ tle9012.readRegisterSingle (1 , 0x01 , &ptconf);
54
+ Serial.println (ptconf);
41
55
}
42
56
43
57
void loop () {
44
- iso_uart_status_t status = isoUART_OK;
45
- uint16_t cellVoltages[12 ];
46
- // put your main code here, to run repeatedly:
47
- tle9012.wakeUp ();
48
- delay (5 );
49
- status = tle9012.writeRegisterBroadcast (0x3D , 0x007F );// Trigger WDT
50
- tle9012.writeRegisterBroadcast (0x18 , 0xEE61 );
51
58
52
- delay ( 5 );
53
- uint8_t errors = 0 ;
54
- for (uint8_t n = 0 ; n < 12 ; n++)
59
+ // put your main code here, to run repeatedly:
60
+ tle9012. readTemperatures ( 1 ) ;
61
+ for (uint8_t n = 0 ; n < 5 ; n++)
55
62
{
56
- errors += (uint8_t ) tle9012.readRegisterSingle (0 , 0x19 +n, &cellVoltages[n]);
57
-
58
- Serial.print (" Cell Voltage: " );
63
+ Serial.println (" -------------------------------------------" );
64
+ Serial.print (" Resistance " );
59
65
Serial.print (n+1 );
60
- Serial.print (" is " );
61
- Serial.print ((float ) 5 *cellVoltages[n]/65536 );
62
- Serial.print (" V\n " );
66
+ Serial.print (" : " );
67
+ Serial.print (tle9012.devices [0 ].ntc_resistances [n]);
68
+ Serial.print (" \n " );
69
+ Serial.println (" -------------------------------------------" );
63
70
}
64
-
65
- Serial.print (" Status: " );
66
- Serial.println (status+errors);
67
- delay (100 );
71
+ delay (1000 );
68
72
69
73
}
0 commit comments