26#ifndef CAFFEINE_HAL_HAL_RTC_H
27#define CAFFEINE_HAL_HAL_RTC_H
128 cfn_hal_rtc_t *driver, uint32_t event_mask, uint32_t error_mask, uint32_t id,
void *user_arg);
150 uint32_t peripheral_id,
151 struct cfn_hal_clock_s *clock,
171 if (driver == NULL || config == NULL)
237 driver->config = config;
250 if (!driver || !config || !driver->config)
254 *config = *(driver->config);
274 driver->cb = callback;
275 driver->cb_user_arg = user_arg;
461 struct cfn_hal_clock_s *clock,
Core Hardware Abstraction Layer definitions and macros.
#define CFN_HAL_CHECK_AND_CALL_FUNC_VARG(expected_peripheral_type, func, driver, result,...)
Definition cfn_hal.h:134
#define CFN_HAL_INLINE
Macro for inlining HAL wrapper functions. Can be overridden with attribute((always_inline)) for perfo...
Definition cfn_hal.h:61
#define CFN_HAL_BIT(x)
Definition cfn_hal.h:79
#define CFN_HAL_CREATE_DRIVER_TYPE(prefix, config_type, api_type, phy_type, cb_type)
Definition cfn_hal.h:102
Base driver Hardware Abstraction Layer declarations.
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
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
#define CFN_HAL_VMT_CHECK(api_struct_type)
Compile-time check to ensure a peripheral API struct is compatible with the base layer....
Definition cfn_hal_base.h:91
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
#define CFN_HAL_POPULATE_DRIVER( driver_ptr, periph_type, periph_id, clock_ptr, dep_ptr, api_ptr, phy_ptr, cfg_ptr, cb_func, cb_arg)
Standardizes the population of a peripheral driver structure. This macro ensures that the base driver...
Definition cfn_hal_base_impl.h:45
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_deinit(cfn_hal_rtc_t *driver)
Deinitializes the RTC driver.
Definition cfn_hal_rtc.h:210
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_stop_alarm(cfn_hal_rtc_t *driver, uint32_t id)
Disables a previously configured alarm.
Definition cfn_hal_rtc.h:452
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_config_get(cfn_hal_rtc_t *driver, cfn_hal_rtc_config_t *config)
Gets the current RTC configuration.
Definition cfn_hal_rtc.h:248
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_event_disable(cfn_hal_rtc_t *driver, uint32_t event_mask)
Disables one or more RTC nominal events.
Definition cfn_hal_rtc.h:317
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_set_alarm(cfn_hal_rtc_t *driver, uint32_t id, cfn_hal_rtc_time_t *time)
Configures an alarm event for a specific time.
Definition cfn_hal_rtc.h:421
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_callback_register(cfn_hal_rtc_t *driver, const cfn_hal_rtc_callback_t callback, void *user_arg)
Registers a callback for RTC events and errors.
Definition cfn_hal_rtc.h:265
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_get_alarm(cfn_hal_rtc_t *driver, uint32_t id, bool *elapsed, cfn_hal_rtc_time_t *time)
Retrieves configuration and status of a specific alarm.
Definition cfn_hal_rtc.h:436
cfn_hal_rtc_config_format_t
RTC time format.
Definition cfn_hal_rtc.h:70
@ CFN_HAL_RTC_CONFIG_FORMAT_24H
Definition cfn_hal_rtc.h:72
@ CFN_HAL_RTC_CONFIG_FORMAT_12H
Definition cfn_hal_rtc.h:71
@ CFN_HAL_RTC_CONFIG_FORMAT_MAX
Definition cfn_hal_rtc.h:74
cfn_hal_rtc_config_mode_t
RTC clocking mode.
Definition cfn_hal_rtc.h:81
@ CFN_HAL_RTC_CONFIG_MODE_MAX
Definition cfn_hal_rtc.h:86
@ CFN_HAL_RTC_CONFIG_MODE_BINARY_BCD
Definition cfn_hal_rtc.h:84
@ CFN_HAL_RTC_CONFIG_MODE_BINARY
Definition cfn_hal_rtc.h:83
@ CFN_HAL_RTC_CONFIG_MODE_BCD
Definition cfn_hal_rtc.h:82
cfn_hal_rtc_error_t
RTC exception error flags.
Definition cfn_hal_rtc.h:60
@ CFN_HAL_RTC_ERROR_NONE
Definition cfn_hal_rtc.h:61
@ CFN_HAL_RTC_ERROR_GENERAL
Definition cfn_hal_rtc.h:63
@ CFN_HAL_RTC_ERROR_INIT
Definition cfn_hal_rtc.h:62
struct tm cfn_hal_rtc_time_t
RTC time representation (std tm).
Definition cfn_hal_rtc.h:94
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_error_disable(cfn_hal_rtc_t *driver, uint32_t error_mask)
Disables one or more RTC exception errors.
Definition cfn_hal_rtc.h:362
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_config_set(cfn_hal_rtc_t *driver, const cfn_hal_rtc_config_t *config)
Sets the RTC configuration.
Definition cfn_hal_rtc.h:225
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_config_validate(const cfn_hal_rtc_t *driver, const cfn_hal_rtc_config_t *config)
Validates the RTC configuration.
Definition cfn_hal_rtc.h:168
cfn_hal_error_code_t cfn_hal_rtc_construct(cfn_hal_rtc_t *driver, const cfn_hal_rtc_config_t *config, const cfn_hal_rtc_phy_t *phy, struct cfn_hal_clock_s *clock, void *dependency, cfn_hal_rtc_callback_t callback, void *user_arg)
Definition cfn_hal_rtc_port.c:70
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_set_time(cfn_hal_rtc_t *driver, cfn_hal_rtc_time_t *time)
Sets the RTC current wall-clock time.
Definition cfn_hal_rtc.h:394
void(* cfn_hal_rtc_callback_t)(cfn_hal_rtc_t *driver, uint32_t event_mask, uint32_t error_mask, uint32_t id, void *user_arg)
RTC callback signature.
Definition cfn_hal_rtc.h:127
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_power_state_set(cfn_hal_rtc_t *driver, cfn_hal_power_state_t state)
Sets the RTC power state.
Definition cfn_hal_rtc.h:287
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_get_time(cfn_hal_rtc_t *driver, cfn_hal_rtc_time_t *time)
Retrieves the current wall-clock time from the RTC.
Definition cfn_hal_rtc.h:407
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_event_get(cfn_hal_rtc_t *driver, uint32_t *event_mask)
Retrieves the current RTC nominal event status.
Definition cfn_hal_rtc.h:332
cfn_hal_rtc_event_t
RTC nominal event flags.
Definition cfn_hal_rtc.h:48
@ CFN_HAL_RTC_EVENT_TAMPER
Definition cfn_hal_rtc.h:53
@ CFN_HAL_RTC_EVENT_WAKEUP
Definition cfn_hal_rtc.h:51
@ CFN_HAL_RTC_EVENT_TIMESTAMP
Definition cfn_hal_rtc.h:52
@ CFN_HAL_RTC_EVENT_ALARM
Definition cfn_hal_rtc.h:50
@ CFN_HAL_RTC_EVENT_NONE
Definition cfn_hal_rtc.h:49
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_error_enable(cfn_hal_rtc_t *driver, uint32_t error_mask)
Enables one or more RTC exception errors.
Definition cfn_hal_rtc.h:347
CFN_HAL_INLINE void cfn_hal_rtc_populate(cfn_hal_rtc_t *driver, uint32_t peripheral_id, struct cfn_hal_clock_s *clock, void *dependency, const cfn_hal_rtc_api_t *api, const cfn_hal_rtc_phy_t *phy, const cfn_hal_rtc_config_t *config, cfn_hal_rtc_callback_t callback, void *user_arg)
Definition cfn_hal_rtc.h:149
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_init(cfn_hal_rtc_t *driver)
Initializes the RTC driver.
Definition cfn_hal_rtc.h:190
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_event_enable(cfn_hal_rtc_t *driver, uint32_t event_mask)
Enables one or more RTC nominal events.
Definition cfn_hal_rtc.h:302
cfn_hal_error_code_t cfn_hal_rtc_destruct(cfn_hal_rtc_t *driver)
Definition cfn_hal_rtc_port.c:86
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_rtc_error_get(cfn_hal_rtc_t *driver, uint32_t *error_mask)
Retrieves the current RTC exception error status.
Definition cfn_hal_rtc.h:377
struct cfn_hal_rtc_s cfn_hal_rtc_t
Definition cfn_hal_rtc.h:116
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
#define CFN_HAL_PERIPHERAL_TYPE_RTC
Definition cfn_hal_types.h:128
enum cfn_hal_error_codes cfn_hal_error_code_t
cfn_hal_power_state_t
Definition cfn_hal_types.h:156
@ CFN_HAL_ERROR_OK
Definition cfn_hal_types.h:50
@ CFN_HAL_ERROR_BAD_PARAM
Definition cfn_hal_types.h:53
@ CFN_HAL_ERROR_BAD_CONFIG
Definition cfn_hal_types.h:60
Base API structure for all peripheral drivers. Every peripheral-specific API struct MUST have this as...
Definition cfn_hal_base.h:63
RTC Virtual Method Table (VMT).
Definition cfn_hal_rtc.h:134
cfn_hal_error_code_t(* get_alarm)(cfn_hal_rtc_t *driver, uint32_t id, bool *elapsed, cfn_hal_rtc_time_t *time)
Definition cfn_hal_rtc.h:141
cfn_hal_error_code_t(* get_time)(cfn_hal_rtc_t *driver, cfn_hal_rtc_time_t *time)
Definition cfn_hal_rtc.h:139
cfn_hal_error_code_t(* set_alarm)(cfn_hal_rtc_t *driver, uint32_t id, cfn_hal_rtc_time_t *time)
Definition cfn_hal_rtc.h:140
cfn_hal_error_code_t(* stop_alarm)(cfn_hal_rtc_t *driver, uint32_t id)
Definition cfn_hal_rtc.h:142
cfn_hal_error_code_t(* set_time)(cfn_hal_rtc_t *driver, cfn_hal_rtc_time_t *time)
Definition cfn_hal_rtc.h:138
cfn_hal_api_base_t base
Definition cfn_hal_rtc.h:135
RTC configuration structure.
Definition cfn_hal_rtc.h:109
void * custom
Definition cfn_hal_rtc.h:113
cfn_hal_rtc_config_format_t format
Definition cfn_hal_rtc.h:110
uint32_t target_rtc_clock
Definition cfn_hal_rtc.h:112
cfn_hal_rtc_config_mode_t mode
Definition cfn_hal_rtc.h:111
RTC hardware physical mapping.
Definition cfn_hal_rtc.h:100
void * instance
Definition cfn_hal_rtc.h:101
void * user_arg
Definition cfn_hal_rtc.h:102