caffeine-hal 0.6.6
A Header-Defined Interface c library, it provides the hal layer for the Caffeine framework
Loading...
Searching...
No Matches
cfn_hal_base.h
Go to the documentation of this file.
1
26#ifndef CAFFEINE_HAL_HAL_BASE_H
27#define CAFFEINE_HAL_HAL_BASE_H
28
29#ifdef __cplusplus
30extern "C"
31{
32#endif
33
34/* Includes ---------------------------------------------------------*/
35#include "cfn_hal.h"
36#include "cfn_hal_types.h"
37
38/* Defines ----------------------------------------------------------*/
39
48#if defined(CFN_HAL_COMPILE_BASE)
49#define CFN_HAL_BASE_API
50#elif defined(CFN_HAL_USE_LIB_BASE)
51#define CFN_HAL_BASE_API extern
52#else
53#define CFN_HAL_BASE_API static inline
54#endif
55
56/* Types Structs ----------------------------------------------------*/
57
62typedef struct cfn_hal_api_base_s
63{
66
68 cfn_hal_error_code_t (*config_set)(cfn_hal_driver_t *base, const void *config);
69 cfn_hal_error_code_t (*config_validate)(const cfn_hal_driver_t *base, const void *config);
71
72 cfn_hal_error_code_t (*event_enable)(cfn_hal_driver_t *base, uint32_t event_mask);
73 cfn_hal_error_code_t (*event_disable)(cfn_hal_driver_t *base, uint32_t event_mask);
74 cfn_hal_error_code_t (*event_get)(cfn_hal_driver_t *base, uint32_t *event_mask);
75
76 cfn_hal_error_code_t (*error_enable)(cfn_hal_driver_t *base, uint32_t error_mask);
77 cfn_hal_error_code_t (*error_disable)(cfn_hal_driver_t *base, uint32_t error_mask);
78 cfn_hal_error_code_t (*error_get)(cfn_hal_driver_t *base, uint32_t *error_mask);
79
80#if (CFN_HAL_USE_LOCK == 1)
81 cfn_hal_error_code_t (*lock)(cfn_hal_driver_t *base, uint32_t timeout);
83#endif
85
91#define CFN_HAL_VMT_CHECK(api_struct_type) \
92 CFN_HAL_STATIC_ASSERT(offsetof(api_struct_type, base) == 0, \
93 "cfn_hal_api_base_t must be the first member of the VMT struct")
94
95/* Functions Prototypes ---------------------------------------------*/
96
105 cfn_hal_peripheral_type_t expected_type);
106
115 cfn_hal_peripheral_type_t expected_type);
116
125 cfn_hal_peripheral_type_t expected_type,
126 const void *config);
127
136 cfn_hal_peripheral_type_t expected_type,
137 const void *config);
148 cfn_hal_peripheral_type_t expected_type,
149 cfn_hal_callback_t callback,
150 void *user_arg);
151
160 cfn_hal_peripheral_type_t expected_type,
162
171
182 cfn_hal_peripheral_type_t expected_type,
183 uint32_t event_mask);
184
195 cfn_hal_peripheral_type_t expected_type,
196 uint32_t event_mask);
197
208 cfn_hal_peripheral_type_t expected_type,
209 uint32_t *event_mask);
210
221 cfn_hal_peripheral_type_t expected_type,
222 uint32_t error_mask);
223
234 cfn_hal_peripheral_type_t expected_type,
235 uint32_t error_mask);
236
247 cfn_hal_peripheral_type_t expected_type,
248 uint32_t *error_mask);
249
250#if (CFN_HAL_USE_LOCK == 1)
257CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_lock(cfn_hal_driver_t *base, uint32_t timeout);
258
265#endif
266
267/* Include Implementation -------------------------------------------*/
268
269#if !defined(CFN_HAL_USE_LIB_BASE) && !defined(CFN_HAL_COMPILE_BASE)
270#include "cfn_hal_base_impl.h"
271#endif
272
273#ifdef __cplusplus
274}
275#endif
276
277#endif // CAFFEINE_HAL_HAL_BASE_H
Core Hardware Abstraction Layer definitions and macros.
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_error_disable(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, uint32_t error_mask)
Generic error disable for any driver. Deactivates exception-flow hardware triggers based on the provi...
Definition cfn_hal_base_impl.h:436
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_callback_register(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, cfn_hal_callback_t callback, void *user_arg)
Generic callback registration for any driver.
Definition cfn_hal_base_impl.h:254
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_error_enable(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, uint32_t error_mask)
Generic error enable for any driver. Activates exception-flow hardware triggers based on the provided...
Definition cfn_hal_base_impl.h:411
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_event_enable(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, uint32_t event_mask)
Generic event enable for any driver. Activates nominal hardware triggers based on the provided mask.
Definition cfn_hal_base_impl.h:331
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_event_get(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, uint32_t *event_mask)
Generic event status getter for any driver. Retrieves the current nominal hardware triggers/flags.
Definition cfn_hal_base_impl.h:386
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_error_get(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, uint32_t *error_mask)
Generic error status getter for any driver. Retrieves current exception-flow hardware flags/errors.
Definition cfn_hal_base_impl.h:461
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_config_set(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, const void *config)
Generic configuration setter for any driver.
Definition cfn_hal_base_impl.h:196
#define CFN_HAL_BASE_API
API visibility macro for the base driver.
Definition cfn_hal_base.h:53
CFN_HAL_BASE_API cfn_hal_power_state_t cfn_hal_power_state_get(const cfn_hal_driver_t *base)
Generic power state getter. Returns the current power state from the software shadow.
Definition cfn_hal_base_impl.h:321
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_power_state_set(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, cfn_hal_power_state_t state)
Generic power state transition for any driver.
Definition cfn_hal_base_impl.h:279
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_deinit(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type)
Generic deinitialization for any driver. Returns the driver to the CONSTRUCTED state and releases boa...
Definition cfn_hal_base_impl.h:144
struct cfn_hal_api_base_s cfn_hal_api_base_t
Base API structure for all peripheral drivers. Every peripheral-specific API struct MUST have this as...
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_init(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type)
Generic initialization for any driver. Handles board-level hooks, type validation,...
Definition cfn_hal_base_impl.h:85
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_config_validate(const cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, const void *config)
Generic validation for a configuration.
Definition cfn_hal_base_impl.h:234
CFN_HAL_BASE_API cfn_hal_error_code_t cfn_hal_base_event_disable(cfn_hal_driver_t *base, cfn_hal_peripheral_type_t expected_type, uint32_t event_mask)
Generic event disable for any driver. Deactivates nominal hardware triggers based on the provided mas...
Definition cfn_hal_base_impl.h:361
Base driver Hardware Abstraction Layer implementation logic. This file should be included by cfn_hal_...
Common type definitions and enums for the HAL.
void(* cfn_hal_callback_t)(void)
Generic function pointer for HAL callbacks. Used as a standard-compliant carrier in the base layer.
Definition cfn_hal_types.h:98
enum cfn_hal_error_codes cfn_hal_error_code_t
uint32_t cfn_hal_peripheral_type_t
Definition cfn_hal_types.h:85
cfn_hal_power_state_t
Definition cfn_hal_types.h:156
Base API structure for all peripheral drivers. Every peripheral-specific API struct MUST have this as...
Definition cfn_hal_base.h:63
cfn_hal_error_code_t(* power_state_set)(cfn_hal_driver_t *base, cfn_hal_power_state_t state)
Definition cfn_hal_base.h:67
cfn_hal_error_code_t(* error_disable)(cfn_hal_driver_t *base, uint32_t error_mask)
Definition cfn_hal_base.h:77
cfn_hal_error_code_t(* callback_register)(cfn_hal_driver_t *base, cfn_hal_callback_t callback, void *user_arg)
Definition cfn_hal_base.h:70
cfn_hal_error_code_t(* event_enable)(cfn_hal_driver_t *base, uint32_t event_mask)
Definition cfn_hal_base.h:72
cfn_hal_error_code_t(* error_enable)(cfn_hal_driver_t *base, uint32_t error_mask)
Definition cfn_hal_base.h:76
cfn_hal_error_code_t(* config_set)(cfn_hal_driver_t *base, const void *config)
Definition cfn_hal_base.h:68
cfn_hal_error_code_t(* config_validate)(const cfn_hal_driver_t *base, const void *config)
Definition cfn_hal_base.h:69
cfn_hal_error_code_t(* error_get)(cfn_hal_driver_t *base, uint32_t *error_mask)
Definition cfn_hal_base.h:78
cfn_hal_error_code_t(* event_get)(cfn_hal_driver_t *base, uint32_t *event_mask)
Definition cfn_hal_base.h:74
cfn_hal_error_code_t(* init)(cfn_hal_driver_t *base)
Definition cfn_hal_base.h:64
cfn_hal_error_code_t(* event_disable)(cfn_hal_driver_t *base, uint32_t event_mask)
Definition cfn_hal_base.h:73
cfn_hal_error_code_t(* deinit)(cfn_hal_driver_t *base)
Definition cfn_hal_base.h:65
Base structure for all peripheral drivers. Contains common state and polymorphic interface linkage.
Definition cfn_hal_types.h:171