26#ifndef CAFFEINE_HAL_HAL_QSPI_H
27#define CAFFEINE_HAL_HAL_QSPI_H
155 uint32_t peripheral_id,
156 struct cfn_hal_clock_s *clock,
177 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;
467 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
General Purpose Input/Output (GPIO) HAL API.
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_config_set(cfn_hal_qspi_t *driver, const cfn_hal_qspi_config_t *config)
Sets the QSPI configuration.
Definition cfn_hal_qspi.h:225
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_event_get(cfn_hal_qspi_t *driver, uint32_t *event_mask)
Retrieves the current QSPI nominal event status.
Definition cfn_hal_qspi.h:332
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_autopolling_enable(cfn_hal_qspi_t *driver, const cfn_hal_qspi_cmd_t *cmd, uint32_t match, uint32_t mask, uint32_t timeout)
Configures autonomous polling of a memory status register.
Definition cfn_hal_qspi.h:455
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_error_get(cfn_hal_qspi_t *driver, uint32_t *error_mask)
Retrieves the current QSPI exception error status.
Definition cfn_hal_qspi.h:377
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_error_disable(cfn_hal_qspi_t *driver, uint32_t error_mask)
Disables one or more QSPI exception errors.
Definition cfn_hal_qspi.h:362
struct cfn_hal_qspi_s cfn_hal_qspi_t
Definition cfn_hal_qspi.h:117
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_config_validate(const cfn_hal_qspi_t *driver, const cfn_hal_qspi_config_t *config)
Validates the QSPI configuration.
Definition cfn_hal_qspi.h:174
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_error_enable(cfn_hal_qspi_t *driver, uint32_t error_mask)
Enables one or more QSPI exception errors.
Definition cfn_hal_qspi.h:347
cfn_hal_error_code_t cfn_hal_qspi_destruct(cfn_hal_qspi_t *driver)
Definition cfn_hal_qspi_port.c:85
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_event_enable(cfn_hal_qspi_t *driver, uint32_t event_mask)
Enables one or more QSPI nominal events.
Definition cfn_hal_qspi.h:302
cfn_hal_qspi_event_t
QSPI nominal event flags.
Definition cfn_hal_qspi.h:48
@ CFN_HAL_QSPI_EVENT_NONE
Definition cfn_hal_qspi.h:49
@ CFN_HAL_QSPI_EVENT_RX_READY
Definition cfn_hal_qspi.h:51
@ CFN_HAL_QSPI_EVENT_TX_COMPLETE
Definition cfn_hal_qspi.h:50
@ CFN_HAL_QSPI_EVENT_CMD_DONE
Definition cfn_hal_qspi.h:52
cfn_hal_qspi_error_t
QSPI exception error flags.
Definition cfn_hal_qspi.h:59
@ CFN_HAL_QSPI_ERROR_TIMEOUT
Definition cfn_hal_qspi.h:61
@ CFN_HAL_QSPI_ERROR_NONE
Definition cfn_hal_qspi.h:60
@ CFN_HAL_QSPI_ERROR_GENERAL
Definition cfn_hal_qspi.h:62
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_callback_register(cfn_hal_qspi_t *driver, const cfn_hal_qspi_callback_t callback, void *user_arg)
Registers a callback for QSPI events and errors.
Definition cfn_hal_qspi.h:265
cfn_hal_error_code_t cfn_hal_qspi_construct(cfn_hal_qspi_t *driver, const cfn_hal_qspi_config_t *config, const cfn_hal_qspi_phy_t *phy, struct cfn_hal_clock_s *clock, void *dependency, cfn_hal_qspi_callback_t callback, void *user_arg)
Definition cfn_hal_qspi_port.c:69
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_config_get(cfn_hal_qspi_t *driver, cfn_hal_qspi_config_t *config)
Gets the current QSPI configuration.
Definition cfn_hal_qspi.h:248
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_init(cfn_hal_qspi_t *driver)
Initializes the QSPI driver.
Definition cfn_hal_qspi.h:190
cfn_hal_qspi_bus_width_t
QSPI bus width modes.
Definition cfn_hal_qspi.h:69
@ CFN_HAL_QSPI_BUS_WIDTH_QUAD
Definition cfn_hal_qspi.h:73
@ CFN_HAL_QSPI_BUS_WIDTH_SINGLE
Definition cfn_hal_qspi.h:71
@ CFN_HAL_QSPI_BUS_WIDTH_NONE
Definition cfn_hal_qspi.h:70
@ CFN_HAL_QSPI_BUS_WIDTH_DUAL
Definition cfn_hal_qspi.h:72
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_command(cfn_hal_qspi_t *driver, const cfn_hal_qspi_cmd_t *cmd, uint32_t timeout)
Sends a command sequence to the memory device.
Definition cfn_hal_qspi.h:395
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_memory_mapped_enable(cfn_hal_qspi_t *driver, const cfn_hal_qspi_cmd_t *cmd)
Enables memory-mapped mode for direct CPU access.
Definition cfn_hal_qspi.h:438
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_power_state_set(cfn_hal_qspi_t *driver, cfn_hal_power_state_t state)
Sets the QSPI power state.
Definition cfn_hal_qspi.h:287
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_receive(cfn_hal_qspi_t *driver, uint8_t *data, uint32_t timeout)
Receives data following a command phase.
Definition cfn_hal_qspi.h:425
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_deinit(cfn_hal_qspi_t *driver)
Deinitializes the QSPI driver.
Definition cfn_hal_qspi.h:210
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_transmit(cfn_hal_qspi_t *driver, const uint8_t *data, uint32_t timeout)
Transmits data following a command phase.
Definition cfn_hal_qspi.h:411
void(* cfn_hal_qspi_callback_t)(cfn_hal_qspi_t *driver, uint32_t event_mask, uint32_t error_mask, void *user_arg)
QSPI callback signature.
Definition cfn_hal_qspi.h:127
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_qspi_event_disable(cfn_hal_qspi_t *driver, uint32_t event_mask)
Disables one or more QSPI nominal events.
Definition cfn_hal_qspi.h:317
CFN_HAL_INLINE void cfn_hal_qspi_populate(cfn_hal_qspi_t *driver, uint32_t peripheral_id, struct cfn_hal_clock_s *clock, void *dependency, const cfn_hal_qspi_api_t *api, const cfn_hal_qspi_phy_t *phy, const cfn_hal_qspi_config_t *config, cfn_hal_qspi_callback_t callback, void *user_arg)
Definition cfn_hal_qspi.h:154
Common type definitions and enums for the HAL.
#define CFN_HAL_PERIPHERAL_TYPE_QSPI
Definition cfn_hal_types.h:136
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
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
Base API structure for all peripheral drivers. Every peripheral-specific API struct MUST have this as...
Definition cfn_hal_base.h:63
Lightweight handle to a specific GPIO pin. Used by other peripherals to reference physical pins.
Definition cfn_hal_gpio.h:173
QSPI Virtual Method Table (VMT).
Definition cfn_hal_qspi.h:136
cfn_hal_error_code_t(* memory_mapped_enable)(cfn_hal_qspi_t *driver, const cfn_hal_qspi_cmd_t *cmd)
Definition cfn_hal_qspi.h:143
cfn_hal_error_code_t(* autopolling_enable)(cfn_hal_qspi_t *driver, const cfn_hal_qspi_cmd_t *cmd, uint32_t match, uint32_t mask, uint32_t timeout)
Definition cfn_hal_qspi.h:144
cfn_hal_api_base_t base
Definition cfn_hal_qspi.h:137
cfn_hal_error_code_t(* transmit)(cfn_hal_qspi_t *driver, const uint8_t *data, uint32_t timeout)
Definition cfn_hal_qspi.h:141
cfn_hal_error_code_t(* receive)(cfn_hal_qspi_t *driver, uint8_t *data, uint32_t timeout)
Definition cfn_hal_qspi.h:142
cfn_hal_error_code_t(* command)(cfn_hal_qspi_t *driver, const cfn_hal_qspi_cmd_t *cmd, uint32_t timeout)
Definition cfn_hal_qspi.h:140
QSPI command configuration.
Definition cfn_hal_qspi.h:82
cfn_hal_qspi_bus_width_t instruction_mode
Definition cfn_hal_qspi.h:86
uint32_t dummy_cycles
Definition cfn_hal_qspi.h:85
cfn_hal_qspi_bus_width_t address_mode
Definition cfn_hal_qspi.h:87
size_t nbr_of_data
Definition cfn_hal_qspi.h:89
cfn_hal_qspi_bus_width_t data_mode
Definition cfn_hal_qspi.h:88
uint32_t instruction
Definition cfn_hal_qspi.h:83
uint32_t address
Definition cfn_hal_qspi.h:84
QSPI configuration structure.
Definition cfn_hal_qspi.h:96
uint32_t flash_size
Definition cfn_hal_qspi.h:98
void * custom
Definition cfn_hal_qspi.h:99
uint32_t clock_prescaler
Definition cfn_hal_qspi.h:97
QSPI hardware physical mapping.
Definition cfn_hal_qspi.h:106
cfn_hal_gpio_pin_handle_t * io3
Definition cfn_hal_qspi.h:113
cfn_hal_gpio_pin_handle_t * cs
Definition cfn_hal_qspi.h:109
cfn_hal_gpio_pin_handle_t * clk
Definition cfn_hal_qspi.h:108
cfn_hal_gpio_pin_handle_t * io2
Definition cfn_hal_qspi.h:112
cfn_hal_gpio_pin_handle_t * io1
Definition cfn_hal_qspi.h:111
cfn_hal_gpio_pin_handle_t * io0
Definition cfn_hal_qspi.h:110
void * user_arg
Definition cfn_hal_qspi.h:114
void * instance
Definition cfn_hal_qspi.h:107