@@ -1139,9 +1139,9 @@ iso_uart_status_t TLE9012::readRegisterBroadcast(uint16_t regaddress, uint16_t*
1139
1139
1140
1140
for (uint8_t n = 0 ; n < N_DEVICES; n++)
1141
1141
{
1142
- uint8_t crc = crc8 (&response_buffer[4 +(n*N_DEVICES )],4 );
1143
- result[n] = (((uint16_t ) response_buffer[6 +(n*N_DEVICES )])<<8 ) | ((uint16_t ) response_buffer[7 +(n*N_DEVICES )]);
1144
- if (crc != 0 )
1142
+ uint8_t crc = crc8 (&response_buffer[4 +(5 *n )],4 );
1143
+ result[n] = (((uint16_t ) response_buffer[6 +(n*5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(n*5 )]);
1144
+ if (crc != response_buffer[ 8 +(n* 5 )] )
1145
1145
status = isoUART_CRC_ERROR;
1146
1146
}
1147
1147
@@ -1204,30 +1204,118 @@ iso_uart_status_t TLE9012::writeRegisterBroadcast(uint16_t regaddress, uint16_t
1204
1204
/* *
1205
1205
* @brief Configure the multiread function on all devices
1206
1206
*
1207
- * @note currently not supported
1207
+ * @note All devices in the daisy chain must have the same multiread address
1208
1208
*
1209
1209
* @param cfg multiread configuration containing information about what registers shall be reed with a multiread command
1210
1210
* @return iso_uart_status_t returns status of the bustransaction
1211
1211
*/
1212
- iso_uart_status_t TLE9012::configureMultiread (multiread_cfg_t cfg) // Write a multiread configuration to all devices in the daisy chain
1212
+ iso_uart_status_t TLE9012::configureMultiread (multiread_cfg_t * cfg) // Write a multiread configuration to all devices in the daisy chain
1213
1213
{
1214
- return isoUART_OK; // Multiread is unsuported for the moment
1214
+
1215
+ uint16_t multiread_cfg_reg = ((cfg->n_pcvm ) & 0xF ) |
1216
+ ((cfg->bvm_sel & 0x1 ) << 4 ) |
1217
+ ((cfg->ext_temp_sel & 0x7 ) << 5 ) |
1218
+ ((cfg->ext_temp_r_sel & 0x1 ) << 8 ) |
1219
+ ((cfg->int_temp_sel & 0x1 ) << 9 ) |
1220
+ ((cfg->scvm_sel & 0x1 ) << 10 ) |
1221
+ ((cfg->stress_pcvm_sel & 0x1 ) << 11 );
1222
+
1223
+ cfg->n_responses = cfg->n_pcvm + cfg->bvm_sel + cfg->ext_temp_sel + cfg->ext_temp_r_sel + cfg->int_temp_sel + cfg->scvm_sel + cfg->stress_pcvm_sel ;
1224
+
1225
+ iso_uart_status_t status = writeRegisterBroadcast (MULTI_READ_CFG, multiread_cfg_reg);
1226
+
1227
+ return status; // Multiread is unsuported for the moment
1215
1228
}
1216
1229
1217
1230
/* *
1218
1231
* @brief isoUART function to perform a multiread operation
1219
1232
*
1220
- * @note currently not supported
1233
+ * @note Broadcast multiread is not possible
1221
1234
*
1235
+ * @param nodeID targed address for the multiread command
1222
1236
* @param databuffer databuffer for the multiread command. The databuffer must have a large enough size to prevent bufferoverflow
1223
1237
* @return iso_uart_status_t returns status of the bustransaction
1224
1238
*/
1225
- iso_uart_status_t TLE9012::multiRead (multread_result_t * databuffer) // Multiread command from all devices in the chain
1239
+
1240
+ iso_uart_status_t TLE9012::multiRead (uint8_t nodeID, multiread_cfg_t cfg, multread_result_t * databuffer) // Multiread command from all devices in the chain
1226
1241
{
1227
1242
ISOUART_LOCK ();
1243
+ iso_uart_status_t status;
1244
+ uint8_t response_buffer[5 *cfg.n_responses +4 ];
1245
+
1246
+ status = isoUART_TIMEOUT;
1247
+
1248
+ isoUARTClearRXBUffer ();
1249
+ isoUARTReadRequest (BROADCAST_ID, MULTI_READ);
1250
+
1251
+ uint32_t starttime = millis ();
1252
+ while ((millis ()-starttime) < ISOUART_TIMEOUT)
1253
+ {
1254
+ if (hisoUART->available () > (3 +(5 *cfg.n_responses )))
1255
+ {
1256
+ hisoUART->readBytes (response_buffer,4 +5 *cfg.n_responses );
1257
+ status = isoUART_OK;
1258
+ break ;
1259
+ }
1260
+ }
1261
+
1262
+ // Check if Timeout occured
1263
+ if (status != isoUART_OK)
1264
+ {
1265
+ status = isoUART_TIMEOUT;
1266
+ ISOUART_UNLOCK ();
1267
+ return status;
1268
+ }
1269
+
1270
+ #ifdef SOFT_MSB_FIRST
1271
+ msb_first_converter (&response_buffer[4 ],5 *cfg.n_responses );
1272
+ #endif
1273
+
1274
+ for (uint8_t n = 0 ; n < cfg.n_responses ; n++)
1275
+ {
1276
+ uint8_t crc = crc8 (&response_buffer[4 +(5 *n)],4 );
1277
+ if (crc != response_buffer[8 +(n*5 )])
1278
+ status = isoUART_CRC_ERROR;
1279
+ return status;
1280
+ }
1281
+
1282
+ if (cfg.n_pcvm > 0 )
1283
+ {
1284
+ for (uint8_t n = 0 ; n < cfg.n_pcvm ; n++)
1285
+ {
1286
+ databuffer->pcvm [n] = (((uint16_t ) response_buffer[6 +(n*5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(n*5 )]);
1287
+ }
1288
+ }
1289
+
1290
+ if (cfg.bvm_offset != 0 )
1291
+ databuffer->bvm = (((uint16_t ) response_buffer[6 +(cfg.bvm_offset *5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(cfg.bvm_offset *5 )]);
1292
+
1293
+ if (cfg.n_pcvm > 0 )
1294
+ {
1295
+ for (uint8_t n = 0 ; n < cfg.ext_temp_sel ; n++)
1296
+ {
1297
+ databuffer->ext_temp [n] = (((uint16_t ) response_buffer[6 +((n+cfg.ext_temp_sel_offset )*5 )])<<8 ) | ((uint16_t ) response_buffer[7 +((n+cfg.ext_temp_sel_offset )*5 )]);
1298
+ }
1299
+ }
1300
+
1228
1301
1302
+ if (cfg.ext_temp_r_offset != 0 )
1303
+ databuffer->r_diag = (((uint16_t ) response_buffer[6 +(cfg.ext_temp_r_offset *5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(cfg.ext_temp_r_offset *5 )]);
1304
+
1305
+ if (cfg.int_temp_sel_offset != 0 )
1306
+ databuffer->int_temp = (((uint16_t ) response_buffer[6 +(cfg.int_temp_sel_offset *5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(cfg.int_temp_sel_offset *5 )]);
1307
+
1308
+ if (cfg.scvm_offset_high != 0 )
1309
+ databuffer->scvm [0 ] = (((uint16_t ) response_buffer[6 +(cfg.scvm_offset_high *5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(cfg.scvm_offset_high *5 )]);
1310
+
1311
+ if (cfg.scvm_offset_low != 0 )
1312
+ databuffer->scvm [1 ] = (((uint16_t ) response_buffer[6 +(cfg.scvm_offset_low *5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(cfg.scvm_offset_low *5 )]);
1313
+
1314
+ if (cfg.stress_pcvm_offset != 0 )
1315
+ databuffer->stress_pcvm = (((uint16_t ) response_buffer[6 +(cfg.stress_pcvm_offset *5 )])<<8 ) | ((uint16_t ) response_buffer[7 +(cfg.stress_pcvm_offset *5 )]);
1316
+
1229
1317
ISOUART_UNLOCK ();
1230
- return isoUART_OK; // Multiread is unsuported for the moment
1318
+ return status;
1231
1319
}
1232
1320
1233
1321
// ---------------------------------------------------------------------------
0 commit comments