Skip to content

Commit 3299bd6

Browse files
[nrf fromlist] modules: hal_nordic: add new errno error handling
Addded macro responsible for translating new errno error codes to strings. Upstream PR #: 96776 Signed-off-by: Michał Stasiak <[email protected]>
1 parent 0c5f06f commit 3299bd6

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

modules/hal_nordic/nrfx/nrfx_glue.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,25 @@ char const *nrfx_error_string_get(nrfx_err_t code)
4545
default: return "unknown";
4646
}
4747
}
48+
49+
char const *nrfx_new_error_string_get(int code)
50+
{
51+
#define NRFX_NEW_ERROR_STRING_CASE(code) case code: return #code
52+
switch (-code)
53+
{
54+
NRFX_NEW_ERROR_STRING_CASE(0);
55+
NRFX_NEW_ERROR_STRING_CASE(ECANCELED);
56+
NRFX_NEW_ERROR_STRING_CASE(ENOMEM);
57+
NRFX_NEW_ERROR_STRING_CASE(ENOTSUP);
58+
NRFX_NEW_ERROR_STRING_CASE(EINVAL);
59+
NRFX_NEW_ERROR_STRING_CASE(EINPROGRESS);
60+
NRFX_NEW_ERROR_STRING_CASE(E2BIG);
61+
NRFX_NEW_ERROR_STRING_CASE(ETIMEDOUT);
62+
NRFX_NEW_ERROR_STRING_CASE(EPERM);
63+
NRFX_NEW_ERROR_STRING_CASE(EFAULT);
64+
NRFX_NEW_ERROR_STRING_CASE(EACCES);
65+
NRFX_NEW_ERROR_STRING_CASE(EBUSY);
66+
NRFX_NEW_ERROR_STRING_CASE(EALREADY);
67+
default: return "unknown";
68+
}
69+
}

modules/hal_nordic/nrfx/nrfx_log.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ LOG_MODULE_REGISTER(NRFX_MODULE_PREFIX, NRFX_MODULE_LOG_LEVEL);
128128
#define NRFX_LOG_ERROR_STRING_GET(error_code) nrfx_error_string_get(error_code)
129129
extern char const *nrfx_error_string_get(nrfx_err_t code);
130130

131+
/**
132+
* @brief Macro for getting the textual representation of a given errno error code.
133+
*
134+
* @param[in] error_code Errno error code.
135+
*
136+
* @return String containing the textual representation of the errno error code.
137+
*/
138+
#define NRFX_NEW_LOG_ERROR_STRING_GET(error_code) nrfx_new_error_string_get(error_code)
139+
extern char const *nrfx_new_error_string_get(int code);
140+
131141
/** @} */
132142

133143
#ifdef __cplusplus

0 commit comments

Comments
 (0)