ZMOD4510 Ultra-Low Power 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
35 } GenericError_t;
36
41 typedef enum {
42 esSensor = 0x0000,
43 esAlgorithm = 0x1000,
44 esInterface = 0x2000,
45 esHAL = 0x3000,
46 } ErrorScope_t;
47
56 typedef enum {
57 heNoInterface = 1,
58 heNotImplemented,
59 heI2CReadMissing,
60 heI2CWriteMissing,
61 heSleepMissing,
62 heResetMissing
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
99 I2CImpl_t i2cRead;
100
113 I2CImpl_t i2cWrite;
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
ecSuccess
Definition: hal.h:31
GenericError_t
GenericError_t
Error code definitions.
Definition: hal.h:30
heResetMissing
Definition: hal.h:62
ErrorStringGenerator_t
char const *(* ErrorStringGenerator_t)(int, int, char *, int)
Function type used for generation of error strings.
Definition: hal.h:174
HALError_t
HALError_t
HAL scope error definitions.
Definition: hal.h:56
heSleepMissing
Definition: hal.h:61
heI2CReadMissing
Definition: hal.h:59
HAL_GetErrorString
char const * HAL_GetErrorString(int error, int scope, char *str, int bufSize)
Error string generator for HAL-scoped errors.
ErrorScope_t
ErrorScope_t
Success status code and error scopes.
Definition: hal.h:41
esSensor
Definition: hal.h:42
heNoInterface
Definition: hal.h:57
HAL_Init
int HAL_Init(Interface_t *hal)
Initialize hardware and populate Interface_t object.
Interface_t::i2cRead
I2CImpl_t i2cRead
Definition: hal.h:99
ecHALError
Definition: hal.h:32
Interface_t::handle
void * handle
Definition: hal.h:80
Interface_t
A structure of pointers to hardware specific functions.
Definition: hal.h:78
HAL_SetError
int HAL_SetError(int error, int scope, ErrorStringGenerator_t errStrFn)
Function storing error information.
esInterface
Definition: hal.h:44
HAL_HandleError
void HAL_HandleError(int errorCode, void const *context)
Error handling function.
esHAL
Definition: hal.h:45
HAL_GetErrorInfo
char const * HAL_GetErrorInfo(int *error, int *scope, char *str, int bufSize)
Get detailed information for last error.
Interface_t::i2cWrite
I2CImpl_t i2cWrite
Definition: hal.h:113
esAlgorithm
Definition: hal.h:43
I2CImpl_t
int(* I2CImpl_t)(void *, uint8_t, uint8_t *, int, uint8_t *, int)
Function pointer type defining signature of I2C functions.
Definition: hal.h:72
heI2CWriteMissing
Definition: hal.h:60
heNotImplemented
Definition: hal.h:58
HAL_Deinit
int HAL_Deinit(Interface_t *hal)
Cleanup before program exit.