@@ -947,6 +947,7 @@ void TLE9012::wakeUp()
947
947
*/
948
948
iso_uart_status_t TLE9012::readRegisterSingle (uint8_t nodeID, uint16_t regaddress, uint16_t * result)
949
949
{
950
+ ISOUART_LOCK ();
950
951
iso_uart_status_t status;
951
952
uint8_t response_buffer[9 ];
952
953
@@ -970,6 +971,7 @@ iso_uart_status_t TLE9012::readRegisterSingle(uint8_t nodeID, uint16_t regaddres
970
971
if (status != isoUART_OK)
971
972
{
972
973
status = isoUART_TIMEOUT;
974
+ ISOUART_UNLOCK ();
973
975
return status;
974
976
}
975
977
@@ -980,9 +982,10 @@ iso_uart_status_t TLE9012::readRegisterSingle(uint8_t nodeID, uint16_t regaddres
980
982
981
983
*result = (((uint16_t ) response_buffer[6 ])<<8 ) | ((uint16_t ) response_buffer[7 ]);
982
984
983
- if (crc != response_buffer[8 ]);
984
- // status = isoUART_CRC_ERROR;
985
+ if (crc != response_buffer[8 ])
986
+ status = isoUART_CRC_ERROR;
985
987
988
+ ISOUART_UNLOCK ();
986
989
return status;
987
990
}
988
991
@@ -996,7 +999,7 @@ iso_uart_status_t TLE9012::readRegisterSingle(uint8_t nodeID, uint16_t regaddres
996
999
*/
997
1000
iso_uart_status_t TLE9012::writeRegisterSingle (uint8_t nodeID, uint16_t regaddress, uint16_t databuffer) // Write data to a single register
998
1001
{
999
-
1002
+ ISOUART_LOCK ();
1000
1003
iso_uart_status_t status;
1001
1004
uint8_t response_buffer[7 ];
1002
1005
@@ -1020,6 +1023,7 @@ iso_uart_status_t TLE9012::writeRegisterSingle(uint8_t nodeID, uint16_t regaddre
1020
1023
if (status != isoUART_OK)
1021
1024
{
1022
1025
status = isoUART_TIMEOUT;
1026
+ ISOUART_UNLOCK ();
1023
1027
return status;
1024
1028
}
1025
1029
@@ -1030,9 +1034,10 @@ iso_uart_status_t TLE9012::writeRegisterSingle(uint8_t nodeID, uint16_t regaddre
1030
1034
if (!crc3 (response_buffer[6 ]))
1031
1035
{
1032
1036
status = isoUART_CRC_ERROR;
1037
+ ISOUART_UNLOCK ();
1033
1038
return status;
1034
1039
}
1035
-
1040
+ ISOUART_UNLOCK ();
1036
1041
return status;
1037
1042
}
1038
1043
@@ -1045,6 +1050,7 @@ iso_uart_status_t TLE9012::writeRegisterSingle(uint8_t nodeID, uint16_t regaddre
1045
1050
*/
1046
1051
iso_uart_status_t TLE9012::readRegisterBroadcast (uint16_t regaddress, uint16_t * result) // Read a broadcast to all devices in the daisy chain
1047
1052
{
1053
+ ISOUART_LOCK ();
1048
1054
iso_uart_status_t status;
1049
1055
uint8_t response_buffer[N_DEVICES*5 +4 ];
1050
1056
@@ -1068,6 +1074,7 @@ iso_uart_status_t TLE9012::readRegisterBroadcast(uint16_t regaddress, uint16_t*
1068
1074
if (status != isoUART_OK)
1069
1075
{
1070
1076
status = isoUART_TIMEOUT;
1077
+ ISOUART_UNLOCK ();
1071
1078
return status;
1072
1079
}
1073
1080
@@ -1083,7 +1090,7 @@ iso_uart_status_t TLE9012::readRegisterBroadcast(uint16_t regaddress, uint16_t*
1083
1090
status = isoUART_CRC_ERROR;
1084
1091
}
1085
1092
1086
-
1093
+ ISOUART_UNLOCK ();
1087
1094
return status;
1088
1095
}
1089
1096
@@ -1096,7 +1103,7 @@ iso_uart_status_t TLE9012::readRegisterBroadcast(uint16_t regaddress, uint16_t*
1096
1103
*/
1097
1104
iso_uart_status_t TLE9012::writeRegisterBroadcast (uint16_t regaddress, uint16_t databuffer) // Write a register as broadcast from all devices in the chain
1098
1105
{
1099
-
1106
+ ISOUART_LOCK ();
1100
1107
iso_uart_status_t status;
1101
1108
uint8_t response_buffer[7 ];
1102
1109
@@ -1119,6 +1126,7 @@ iso_uart_status_t TLE9012::writeRegisterBroadcast(uint16_t regaddress, uint16_t
1119
1126
if (status != isoUART_OK)
1120
1127
{
1121
1128
status = isoUART_TIMEOUT;
1129
+ ISOUART_UNLOCK ();
1122
1130
return status;
1123
1131
}
1124
1132
@@ -1130,9 +1138,11 @@ iso_uart_status_t TLE9012::writeRegisterBroadcast(uint16_t regaddress, uint16_t
1130
1138
if (!crc3 (response_buffer[6 ]))
1131
1139
{
1132
1140
status = isoUART_CRC_ERROR;
1141
+ ISOUART_UNLOCK ();
1133
1142
return status;
1134
1143
}
1135
1144
1145
+ ISOUART_UNLOCK ();
1136
1146
return status;
1137
1147
}
1138
1148
@@ -1159,6 +1169,9 @@ iso_uart_status_t TLE9012::configureMultiread(multiread_cfg_t cfg) //Write a mu
1159
1169
*/
1160
1170
iso_uart_status_t TLE9012::multiRead (multread_result_t * databuffer) // Multiread command from all devices in the chain
1161
1171
{
1172
+ ISOUART_LOCK ();
1173
+
1174
+ ISOUART_UNLOCK ();
1162
1175
return isoUART_OK; // Multiread is unsuported for the moment
1163
1176
}
1164
1177
0 commit comments