ChibiOS/HAL 9.0.0
hal_xsnor_micron_n25q.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_micron_n25q.h
19 * @brief Generated SNOR Micron N25Q header.
20 * @note This is a generated file, do not edit directly.
21 *
22 * @addtogroup HAL_XSNOR_MICRON_N25Q
23 * @brief SNOR Micron N25Q driver.
24 * @details Module for SNOR Micron N25Q flash devices.
25 * @{
26 */
27
28#ifndef HAL_XSNOR_MICRON_N25Q_H
29#define HAL_XSNOR_MICRON_N25Q_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 N25Q_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 N25Q_OPT_DUMMY_CYCLES(n) ((n) << 0)
61
62/**
63 * @brief Switch bus width on initialization.
64 * @details If @p N25Q_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 N25Q_OPT_NO_WIDTH_SWITCH (1U << 4)
70
71/**
72 * @brief Use 4kB sub-sectors rather than 64kB sectors.
73 */
74#define N25Q_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 N25Q_OPT_NICE_WAITING (1U << 6)
83/** @} */
84
85/*===========================================================================*/
86/* Module macros. */
87/*===========================================================================*/
88
89/*===========================================================================*/
90/* Module data structures and types. */
91/*===========================================================================*/
92
93/**
94 * @class hal_xsnor_micron_n25q_c
95 * @extends hal_xsnor_base_c
96 *
97 *
98 * @name Class @p hal_xsnor_micron_n25q_c structures
99 * @{
100 */
101
102/**
103 * @brief Type of a SNOR Micron N25Q driver class.
104 */
106
107/**
108 * @brief Class @p hal_xsnor_micron_n25q_c virtual methods table.
109 */
111 /* From base_object_c.*/
112 void (*dispose)(void *ip);
113 /* From hal_xsnor_base_c.*/
114 flash_error_t (*init)(void *ip);
115 flash_error_t (*read)(void *ip, flash_offset_t offset, size_t n, uint8_t *rp);
116 flash_error_t (*program)(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp);
119 flash_error_t (*query_erase)(void *ip, unsigned *msec);
121 flash_error_t (*mmap_on)(void *ip, uint8_t **addrp);
122 void (*mmap_off)(void *ip);
123 /* From hal_xsnor_micron_n25q_c.*/
124};
125
126/**
127 * @brief Structure representing a SNOR Micron N25Q driver class.
128 */
130 /**
131 * @brief Virtual Methods Table.
132 */
134 /**
135 * @brief Implemented interface @p flash_interface_i.
136 */
138 /**
139 * @brief Driver state.
140 */
142 /**
143 * @brief Driver configuration.
144 */
146#if (XSNOR_USE_WSPI == TRUE) || defined (__DOXYGEN__)
147 /**
148 * @brief Current commands configuration.
149 * @note This field is meant to be initialized by subclasses on object
150 * creation.
151 */
153#endif /* XSNOR_USE_WSPI == TRUE */
154 /**
155 * @brief Flash access mutex.
156 */
158 /**
159 * @brief Flash descriptor.
160 * @note This field is meant to be initialized by subclasses on memory
161 * initialization.
162 */
164};
165/** @} */
166
167/*===========================================================================*/
168/* External declarations. */
169/*===========================================================================*/
170
171#ifdef __cplusplus
172extern "C" {
173#endif
174 /* Methods of hal_xsnor_micron_n25q_c.*/
175 void *__n25q_objinit_impl(void *ip, const void *vmt);
176 void __n25q_dispose_impl(void *ip);
178 flash_error_t __n25q_read_impl(void *ip, flash_offset_t offset, size_t n,
179 uint8_t *rp);
180 flash_error_t __n25q_program_impl(void *ip, flash_offset_t offset, size_t n,
181 const uint8_t *pp);
184 flash_error_t __n25q_query_erase_impl(void *ip, unsigned *msec);
186 flash_error_t __n25q_mmap_on_impl(void *ip, uint8_t **addrp);
187 void __n25q_mmap_off_impl(void *ip);
188 /* Regular functions.*/
189#ifdef __cplusplus
190}
191#endif
192
193/*===========================================================================*/
194/* Module inline functions. */
195/*===========================================================================*/
196
197/**
198 * @name Default constructor of hal_xsnor_micron_n25q_c
199 * @{
200 */
201/**
202 * @brief Default initialization function of @p hal_xsnor_micron_n25q_c.
203 *
204 * @param[out] self Pointer to a @p hal_xsnor_micron_n25q_c
205 * instance to be initialized.
206 * @return Pointer to the initialized object.
207 *
208 * @objinit
209 */
216/** @} */
217
218#endif /* HAL_XSNOR_MICRON_N25Q_H */
219
220/** @} */
#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 __n25q_mmap_on_impl(void *ip, uint8_t **addrp)
Override of method xsnor_device_mmap_on().
flash_error_t __n25q_start_erase_sector_impl(void *ip, flash_sector_t sector)
Override of method xsnor_device_start_erase_sector().
void * __n25q_objinit_impl(void *ip, const void *vmt)
Implementation of object creation.
static CC_FORCE_INLINE hal_xsnor_micron_n25q_c * n25qObjectInit(hal_xsnor_micron_n25q_c *self)
Default initialization function of hal_xsnor_micron_n25q_c.
flash_error_t __n25q_read_impl(void *ip, flash_offset_t offset, size_t n, uint8_t *rp)
Override of method xsnor_device_read().
flash_error_t __n25q_start_erase_all_impl(void *ip)
Override of method xsnor_device_start_erase_all().
const struct hal_xsnor_micron_n25q_vmt __hal_xsnor_micron_n25q_vmt
VMT structure of SNOR Micron N25Q driver class.
flash_error_t __n25q_query_erase_impl(void *ip, unsigned *msec)
Override of method xsnor_device_query_erase().
flash_error_t __n25q_init_impl(void *ip)
Override of method xsnor_device_init().
void __n25q_dispose_impl(void *ip)
Implementation of object finalization.
flash_error_t __n25q_program_impl(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp)
Override of method xsnor_device_program().
void __n25q_mmap_off_impl(void *ip)
Override of method xsnor_device_mmap_off().
flash_error_t __n25q_verify_erase_impl(void *ip, flash_sector_t sector)
Override of method xsnor_device_verify_erase().
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_micron_n25q_c virtual methods table.
flash_error_t(* program)(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp)
flash_error_t(* start_erase_sector)(void *ip, flash_sector_t sector)
flash_error_t(* query_erase)(void *ip, unsigned *msec)
flash_error_t(* mmap_on)(void *ip, uint8_t **addrp)
flash_error_t(* init)(void *ip)
flash_error_t(* verify_erase)(void *ip, flash_sector_t sector)
flash_error_t(* read)(void *ip, flash_offset_t offset, size_t n, uint8_t *rp)
flash_error_t(* start_erase_all)(void *ip)
Structure representing a SNOR Micron N25Q driver class.
flash_interface_i fls
Implemented interface flash_interface_i.
const xsnor_config_t * config
Driver configuration.
const xsnor_commands_t * commands
Current commands configuration.
flash_state_t state
Driver state.
mutex_t mutex
Flash access mutex.
flash_descriptor_t descriptor
Flash descriptor.
const struct hal_xsnor_micron_n25q_vmt * vmt
Virtual Methods Table.