[hal] Add HAL_GetLastError to enable better error messages from HAL calls (#3320)

This uses thread local storage so a full error string can be provided, not just an error code.
This commit is contained in:
Thad House
2021-04-29 09:56:54 -07:00
committed by GitHub
parent ced654880c
commit 5127380727
10 changed files with 81 additions and 13 deletions

View File

@@ -65,7 +65,7 @@ int main(void) {
HAL_DigitalHandle pwmPort = HAL_InitializePWMPort(HAL_GetPort(2), &status);
if (status != 0) {
const char* message = HAL_GetErrorMessage(status);
const char* message = HAL_GetLastError(&status);
printf("%s\n", message);
return 1;
}
@@ -78,7 +78,7 @@ int main(void) {
HAL_DigitalHandle dio = HAL_InitializeDIOPort(HAL_GetPort(2), 1, &status);
if (status != 0) {
const char* message = HAL_GetErrorMessage(status);
const char* message = HAL_GetLastError(&status);
printf("%s\n", message);
status = 0;
HAL_FreePWMPort(pwmPort, &status);