26#ifndef CAFFEINE_HAL_HAL_BASE_H
27#define CAFFEINE_HAL_HAL_BASE_H
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
53#define CFN_HAL_BASE_API static inline
80#if (CFN_HAL_USE_LOCK == 1)
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")
183 uint32_t event_mask);
196 uint32_t event_mask);
209 uint32_t *event_mask);
222 uint32_t error_mask);
235 uint32_t error_mask);
248 uint32_t *error_mask);
250#if (CFN_HAL_USE_LOCK == 1)
269#if !defined(CFN_HAL_USE_LIB_BASE) && !defined(CFN_HAL_COMPILE_BASE)
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