RRH46410 Firmware Documentation
hal.h
Go to the documentation of this file.
1 
13 #ifndef HAL_H
14 #define HAL_H
15 
16 #include <stdint.h>
17 
21 typedef enum {
22  ecSuccess = 0,
23  ecHALError = 0x10000
27 
32 typedef enum {
33  esSensor = 0x00000000,
34  esAlgorithm = 0x10000000,
35  esInterface = 0x20000000,
36  esHAL = 0x30000000,
37 } ErrorScope_t;
38 
47 typedef enum {
54 } HALError_t;
55 
56 
63 typedef int ( *I2CImpl_t ) ( void*, uint8_t, uint8_t*, int, uint8_t*, int );
64 
65 
69 typedef struct {
71  void* handle;
72 
91 
105 
110  void ( *msSleep ) ( uint32_t ms );
111 
116  int ( *reset ) ( void* handle );
117 } Interface_t;
118 
119 
132 int HAL_Init ( Interface_t* hal );
133 
145 int HAL_Deinit ( Interface_t* hal );
146 
156 void HAL_HandleError ( int errorCode, void const* context );
157 
165 typedef char const* ( *ErrorStringGenerator_t ) ( int, int, char*, int );
166 
193 int HAL_SetError ( int error, int scope,
194  ErrorStringGenerator_t errStrFn );
195 
213 char const* HAL_GetErrorInfo ( int* error, int* scope, char* str, int bufSize );
214 
227 char const* HAL_GetErrorString ( int error, int scope, char* str, int bufSize );
228 
229 #endif /* HAL_H */
230 
Definition: hal.h:22
GenericError_t
Error code definitions.
Definition: hal.h:21
Definition: hal.h:53
char const *(* ErrorStringGenerator_t)(int, int, char *, int)
Function type used for generation of error strings.
Definition: hal.h:165
HALError_t
HAL scope error definitions.
Definition: hal.h:47
Definition: hal.h:52
Definition: hal.h:50
char const * HAL_GetErrorString(int error, int scope, char *str, int bufSize)
Error string generator for HAL-scoped errors.
ErrorScope_t
Success status code and error scopes.
Definition: hal.h:32
Definition: hal.h:33
Definition: hal.h:48
int HAL_Init(Interface_t *hal)
Initialize hardware and populate Interface_t object.
Definition: template.c:73
I2CImpl_t i2cRead
Definition: hal.h:90
Definition: hal.h:23
void * handle
Definition: hal.h:71
A structure of pointers to hardware specific functions.
Definition: hal.h:69
int HAL_SetError(int error, int scope, ErrorStringGenerator_t errStrFn)
Function storing error information.
Definition: hal.h:35
void HAL_HandleError(int errorCode, void const *context)
Error handling function.
Definition: template.c:105
Definition: hal.h:36
char const * HAL_GetErrorInfo(int *error, int *scope, char *str, int bufSize)
Get detailed information for last error.
I2CImpl_t i2cWrite
Definition: hal.h:104
Definition: hal.h:34
int(* I2CImpl_t)(void *, uint8_t, uint8_t *, int, uint8_t *, int)
Function pointer type defining signature of I2C functions.
Definition: hal.h:63
Definition: hal.h:51
Definition: hal.h:49
int HAL_Deinit(Interface_t *hal)
Cleanup before program exit.
Definition: template.c:95