ChibiOS/HAL 9.0.0
hal_xsnor_macronix_mx25.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2025 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_xsnor_macronix_mx25.h
19 * @brief Generated SNOR Macronix MX25 header.
20 * @note This is a generated file, do not edit directly.
21 *
22 * @addtogroup HAL_XSNOR_MACRONIX_MX25
23 * @brief SNOR Macronix MX25 driver.
24 * @details Module for SNOR Macronix MX25 flash devices.
25 * @{
26 */
27
28#ifndef HAL_XSNOR_MACRONIX_MX25_H
29#define HAL_XSNOR_MACRONIX_MX25_H
30
31#include "oop_base_object.h"
32#include "hal_xsnor_base.h"
33
34/*===========================================================================*/
35/* Module constants. */
36/*===========================================================================*/
37
38/*===========================================================================*/
39/* Module pre-compile time settings. */
40/*===========================================================================*/
41
42/*===========================================================================*/
43/* Derived constants and error checks. */
44/*===========================================================================*/
45
46/**
47 * @name Device options
48 * @{
49 */
50/**
51 * @brief Mask of the dummy cycles field.
52 */
53#define MX25_OPT_DUMMY_CYCLES_MASK (15U << 0)
54
55/**
56 * @brief Number of dummy cycles.
57 *
58 * @param n Number of dummy cycles (2..15)
59 */
60#define MX25_OPT_DUMMY_CYCLES(n) ((n) << 0)
61
62/**
63 * @brief Switch bus width on initialization.
64 * @details If @p MX25_OPT_NO_WIDTH_SWITCH is specified then this is the
65 * bus mode that the device is expected to be using else this is
66 * the bus mode that the device will be switched in.
67 * @note This option is only valid in WSPI bus mode.
68 */
69#define MX25_OPT_NO_WIDTH_SWITCH (1U << 4)
70
71/**
72 * @brief Use 4kB sub-sectors rather than 64kB sectors.
73 */
74#define MX25_OPT_USE_SUBSECTORS (1U << 5)
75
76/**
77 * @brief Delays insertion.
78 * @details If enabled this options inserts delays into the flash waiting
79 * routines releasing some extra CPU time for threads with lower
80 * priority, this may slow down the driver a bit however.
81 */
82#define MX25_OPT_NICE_WAITING (1U << 6)
83
84/**
85 * @brief Enables DTR in 8 lines mode.
86 */
87#define MX25_OPT_USE_DTR (1U << 7)
88/** @} */
89
90/*===========================================================================*/
91/* Module macros. */
92/*===========================================================================*/
93
94/*===========================================================================*/
95/* Module data structures and types. */
96/*===========================================================================*/
97
98/**
99 * @class hal_xsnor_macronix_mx25_c
100 * @extends hal_xsnor_base_c
101 *
102 *
103 * @name Class @p hal_xsnor_macronix_mx25_c structures
104 * @{
105 */
106
107/**
108 * @brief Type of a SNOR Macronix MX25 driver class.
109 */
111
112/**
113 * @brief Class @p hal_xsnor_macronix_mx25_c virtual methods table.
114 */
116 /* From base_object_c.*/
117 void (*dispose)(void *ip);
118 /* From hal_xsnor_base_c.*/
119 flash_error_t (*init)(void *ip);
120 flash_error_t (*read)(void *ip, flash_offset_t offset, size_t n, uint8_t *rp);
121 flash_error_t (*program)(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp);
124 flash_error_t (*query_erase)(void *ip, unsigned *msec);
126 flash_error_t (*mmap_on)(void *ip, uint8_t **addrp);
127 void (*mmap_off)(void *ip);
128 /* From hal_xsnor_macronix_mx25_c.*/
129};
130
131/**
132 * @brief Structure representing a SNOR Macronix MX25 driver class.
133 */
135 /**
136 * @brief Virtual Methods Table.
137 */
139 /**
140 * @brief Implemented interface @p flash_interface_i.
141 */
143 /**
144 * @brief Driver state.
145 */
147 /**
148 * @brief Driver configuration.
149 */
151#if (XSNOR_USE_WSPI == TRUE) || defined (__DOXYGEN__)
152 /**
153 * @brief Current commands configuration.
154 * @note This field is meant to be initialized by subclasses on object
155 * creation.
156 */
158#endif /* XSNOR_USE_WSPI == TRUE */
159 /**
160 * @brief Flash access mutex.
161 */
163 /**
164 * @brief Flash descriptor.
165 * @note This field is meant to be initialized by subclasses on memory
166 * initialization.
167 */
169};
170/** @} */
171
172/*===========================================================================*/
173/* External declarations. */
174/*===========================================================================*/
175
176#ifdef __cplusplus
177extern "C" {
178#endif
179 /* Methods of hal_xsnor_macronix_mx25_c.*/
180 void *__mx25_objinit_impl(void *ip, const void *vmt);
181 void __mx25_dispose_impl(void *ip);
183 flash_error_t __mx25_read_impl(void *ip, flash_offset_t offset, size_t n,
184 uint8_t *rp);
185 flash_error_t __mx25_program_impl(void *ip, flash_offset_t offset, size_t n,
186 const uint8_t *pp);
189 flash_error_t __mx25_query_erase_impl(void *ip, unsigned *msec);
191 flash_error_t __mx25_mmap_on_impl(void *ip, uint8_t **addrp);
192 void __mx25_mmap_off_impl(void *ip);
193 /* Regular functions.*/
194#ifdef __cplusplus
195}
196#endif
197
198/*===========================================================================*/
199/* Module inline functions. */
200/*===========================================================================*/
201
202/**
203 * @name Default constructor of hal_xsnor_macronix_mx25_c
204 * @{
205 */
206/**
207 * @brief Default initialization function of @p
208 * hal_xsnor_macronix_mx25_c.
209 *
210 * @param[out] self Pointer to a @p hal_xsnor_macronix_mx25_c
211 * instance to be initialized.
212 * @return Pointer to the initialized object.
213 *
214 * @objinit
215 */
222/** @} */
223
224#endif /* HAL_XSNOR_MACRONIX_MX25_H */
225
226/** @} */
#define CC_FORCE_INLINE
Enforces a function inline.
Definition ccportab.h:108
static const struct EFlashDriverVMT vmt
Definition hal_efl.c:71
uint32_t flash_sector_t
Type of a flash sector number.
Definition hal_flash.h:117
flash_state_t
Driver state machine possible states.
Definition hal_flash.h:86
uint32_t flash_offset_t
Type of a flash offset.
Definition hal_flash.h:112
flash_error_t
Type of a flash error code.
Definition hal_flash.h:98
struct xsnor_config xsnor_config_t
Type of a SNOR configuration structure.
struct xsnor_commands xsnor_commands_t
Type of a commands configuration structure.
flash_error_t __mx25_mmap_on_impl(void *ip, uint8_t **addrp)
Override of method xsnor_device_mmap_on().
void __mx25_mmap_off_impl(void *ip)
Override of method xsnor_device_mmap_off().
static CC_FORCE_INLINE hal_xsnor_macronix_mx25_c * mx25ObjectInit(hal_xsnor_macronix_mx25_c *self)
Default initialization function of hal_xsnor_macronix_mx25_c.
flash_error_t __mx25_query_erase_impl(void *ip, unsigned *msec)
Override of method xsnor_device_query_erase().
void __mx25_dispose_impl(void *ip)
Implementation of object finalization.
flash_error_t __mx25_program_impl(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp)
Override of method xsnor_device_program().
flash_error_t __mx25_start_erase_sector_impl(void *ip, flash_sector_t sector)
Override of method xsnor_device_start_erase_sector().
flash_error_t __mx25_read_impl(void *ip, flash_offset_t offset, size_t n, uint8_t *rp)
Override of method xsnor_device_read().
flash_error_t __mx25_init_impl(void *ip)
Override of method xsnor_device_init().
const struct hal_xsnor_macronix_mx25_vmt __hal_xsnor_macronix_mx25_vmt
VMT structure of SNOR Macronix MX25 driver class.
flash_error_t __mx25_start_erase_all_impl(void *ip)
Override of method xsnor_device_start_erase_all().
flash_error_t __mx25_verify_erase_impl(void *ip, flash_sector_t sector)
Override of method xsnor_device_verify_erase().
void * __mx25_objinit_impl(void *ip, const void *vmt)
Implementation of object creation.
uint32_t mutex_t
Type of a mutex.
Definition osal.h:229
Generated SNOR Base Driver header.
Generic flash interface.
Type of a flash device descriptor.
Definition hal_flash.h:136
Class hal_xsnor_macronix_mx25_c virtual methods table.
flash_error_t(* start_erase_all)(void *ip)
flash_error_t(* start_erase_sector)(void *ip, flash_sector_t sector)
flash_error_t(* query_erase)(void *ip, unsigned *msec)
flash_error_t(* program)(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp)
flash_error_t(* mmap_on)(void *ip, uint8_t **addrp)
flash_error_t(* init)(void *ip)
flash_error_t(* read)(void *ip, flash_offset_t offset, size_t n, uint8_t *rp)
flash_error_t(* verify_erase)(void *ip, flash_sector_t sector)
Structure representing a SNOR Macronix MX25 driver class.
const struct hal_xsnor_macronix_mx25_vmt * vmt
Virtual Methods Table.
const xsnor_config_t * config
Driver configuration.
mutex_t mutex
Flash access mutex.
flash_descriptor_t descriptor
Flash descriptor.
const xsnor_commands_t * commands
Current commands configuration.
flash_interface_i fls
Implemented interface flash_interface_i.
flash_state_t state
Driver state.