ZMOD4510 Nitrogen Dioxide and Ozone Firmware Documentation
hal.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2024 Renesas Electronics Corporation
3  * All Rights Reserved.
4  *
5  * This code is proprietary to Renesas, and is license pursuant to the terms and
6  * conditions that may be accessed at:
7  * https://www.renesas.com/eu/en/document/msc/renesas-software-license-terms-gas-sensor-software
8  *****************************************************************************/
9 
22 #ifndef HAL_H
23 #define HAL_H
24 
25 #include <stdint.h>
26 
30 typedef enum {
31  ecSuccess = 0,
32  ecHALError = 0x100
36 
41 typedef enum {
42  esSensor = 0x0000,
43  esAlgorithm = 0x1000,
44  esInterface = 0x2000,
45  esHAL = 0x3000,
46 } ErrorScope_t;
47 
56 typedef enum {
63 } HALError_t;
64 
65 
72 typedef int ( *I2CImpl_t ) ( void*, uint8_t, uint8_t*, int, uint8_t*, int );
73 
74 
78 typedef struct {
80  void* handle;
81 
100 
114 
119  void ( *msSleep ) ( uint32_t ms );
120 
125  int ( *reset ) ( void* handle );
126 } Interface_t;
127 
128 
141 int HAL_Init ( Interface_t* hal );
142 
154 int HAL_Deinit ( Interface_t* hal );
155 
165 void HAL_HandleError ( int errorCode, void const* context );
166 
174 typedef char const* ( *ErrorStringGenerator_t ) ( int, int, char*, int );
175 
202 int HAL_SetError ( int error, int scope,
203  ErrorStringGenerator_t errStrFn );
204 
222 char const* HAL_GetErrorInfo ( int* error, int* scope, char* str, int bufSize );
223 
236 char const* HAL_GetErrorString ( int error, int scope, char* str, int bufSize );
237 
238 #endif /* HAL_H */
239 
Definition: hal.h:31
GenericError_t
Error code definitions.
Definition: hal.h:30
Definition: hal.h:62
char const *(* ErrorStringGenerator_t)(int, int, char *, int)
Function type used for generation of error strings.
Definition: hal.h:174
HALError_t
HAL scope error definitions.
Definition: hal.h:56
Definition: hal.h:61
Definition: hal.h:59
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:41
Definition: hal.h:42
Definition: hal.h:57
int HAL_Init(Interface_t *hal)
Initialize hardware and populate Interface_t object.
I2CImpl_t i2cRead
Definition: hal.h:99
Definition: hal.h:32
void * handle
Definition: hal.h:80
A structure of pointers to hardware specific functions.
Definition: hal.h:78
int HAL_SetError(int error, int scope, ErrorStringGenerator_t errStrFn)
Function storing error information.
Definition: hal.h:44
void HAL_HandleError(int errorCode, void const *context)
Error handling function.
Definition: hal.h:45
char const * HAL_GetErrorInfo(int *error, int *scope, char *str, int bufSize)
Get detailed information for last error.
I2CImpl_t i2cWrite
Definition: hal.h:113
Definition: hal.h:43
int(* I2CImpl_t)(void *, uint8_t, uint8_t *, int, uint8_t *, int)
Function pointer type defining signature of I2C functions.
Definition: hal.h:72
Definition: hal.h:60
Definition: hal.h:58
int HAL_Deinit(Interface_t *hal)
Cleanup before program exit.