ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_nrf5_sdk15_error.c
Go to the documentation of this file.
2 #if RUUVI_NRF5_SDK15_ENABLED
16 #include "ruuvi_driver_error.h"
17 #include "ruuvi_nrf5_sdk15_error.h"
18 #include "nrf_drv_twi.h"
19 
20 rd_status_t ruuvi_nrf5_sdk15_to_ruuvi_error (const ret_code_t err_code)
21 {
22  if (NRF_SUCCESS == err_code) { return RD_SUCCESS; }
23 
24  if (NRF_ERROR_INTERNAL == err_code) { return RD_ERROR_INTERNAL; }
25 
26  if (NRF_ERROR_NO_MEM == err_code) { return RD_ERROR_NO_MEM; }
27 
28  if (NRF_ERROR_NOT_FOUND == err_code) { return RD_ERROR_NOT_FOUND; }
29 
30  if (NRF_ERROR_NOT_SUPPORTED == err_code) { return RD_ERROR_NOT_SUPPORTED; }
31 
32  if (NRF_ERROR_INVALID_PARAM == err_code) { return RD_ERROR_INVALID_PARAM; }
33 
34  if (NRF_ERROR_INVALID_STATE == err_code) { return RD_ERROR_INVALID_STATE; }
35 
36  if (NRF_ERROR_MODULE_ALREADY_INITIALIZED == err_code)
37  {
39  }
40 
41  if (NRF_ERROR_INVALID_LENGTH == err_code) { return RD_ERROR_INVALID_LENGTH; }
42 
43  if (NRF_ERROR_INVALID_FLAGS == err_code) { return RD_ERROR_INVALID_FLAGS; }
44 
45  if (NRF_ERROR_DATA_SIZE == err_code) { return RD_ERROR_DATA_SIZE; }
46 
47  if (NRF_ERROR_TIMEOUT == err_code) { return RD_ERROR_TIMEOUT; }
48 
49  if (NRF_ERROR_NULL == err_code) { return RD_ERROR_NULL; }
50 
51  if (NRF_ERROR_FORBIDDEN == err_code) { return RD_ERROR_FORBIDDEN; }
52 
53  if (NRF_ERROR_INVALID_ADDR == err_code) { return RD_ERROR_INVALID_ADDR; }
54 
55  if (NRF_ERROR_BUSY == err_code) { return RD_ERROR_BUSY; }
56 
57  if (NRF_ERROR_RESOURCES == err_code) { return RD_ERROR_RESOURCES; }
58 
59  if (NRF_ERROR_DRV_TWI_ERR_DNACK == err_code ||
60  NRF_ERROR_DRV_TWI_ERR_ANACK == err_code)
61  {
63  }
64 
65  return RD_ERROR_INTERNAL;
66 }
68 #endif
#define RD_ERROR_INVALID_PARAM
Invalid Parameter.
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_INVALID_LENGTH
Invalid Length.
rd_status_t ruuvi_nrf5_sdk15_to_ruuvi_error(const ret_code_t error)
convert nrf5 sdk15 error code into Ruuvi error code.
#define RD_ERROR_FORBIDDEN
Forbidden Operation.
#define RD_ERROR_RESOURCES
Not enough resources for operation.
#define RD_ERROR_NOT_SUPPORTED
Not supported.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_NOT_ACKNOWLEDGED
Ack was expected but not received.
#define RD_ERROR_DATA_SIZE
Invalid Data size.
#define RD_ERROR_NO_MEM
No Memory for operation.
#define RD_ERROR_TIMEOUT
Operation timed out.
#define RD_ERROR_INVALID_FLAGS
Invalid Flags.
#define RD_ERROR_NOT_FOUND
Not found.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RD_ERROR_INTERNAL
Internal Error.
#define RD_ERROR_BUSY
Busy.
#define RD_ERROR_INVALID_ADDR
Bad Memory Address.
Header to enable and disable module compilation.
Ruuvi error codes and error check function.