ChibiOS/HAL  6.1.0
hal_qspi_lld.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 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_qspi_lld.h
19  * @brief PLATFORM QSPI subsystem low level driver header.
20  *
21  * @addtogroup QSPI
22  * @{
23  */
24 
25 #ifndef HAL_QSPI_LLD_H
26 #define HAL_QSPI_LLD_H
27 
28 #if (HAL_USE_QSPI == TRUE) || defined(__DOXYGEN__)
29 
30 /*===========================================================================*/
31 /* Driver constants. */
32 /*===========================================================================*/
33 
34 /**
35  * @name QSPI capabilities
36  * @{
37  */
38 #define QSPI_SUPPORTS_MEMMAP TRUE
39 /** @} */
40 
41 /*===========================================================================*/
42 /* Driver pre-compile time settings. */
43 /*===========================================================================*/
44 
45 /**
46  * @name Configuration options
47  * @{
48  */
49 /**
50  * @brief QSPID1 driver enable switch.
51  * @details If set to @p TRUE the support for QSPID1 is included.
52  * @note The default is @p FALSE.
53  */
54 #if !defined(PLATFORM_QSPI_USE_QSPI1) || defined(__DOXYGEN__)
55 #define PLATFORM_QSPI_USE_QSPI1 FALSE
56 #endif
57 /** @} */
58 
59 /*===========================================================================*/
60 /* Derived constants and error checks. */
61 /*===========================================================================*/
62 
63 /*===========================================================================*/
64 /* Driver data structures and types. */
65 /*===========================================================================*/
66 
67 /**
68  * @brief Type of a structure representing an QSPI driver.
69  */
70 typedef struct QSPIDriver QSPIDriver;
71 
72 /**
73  * @brief Type of a QSPI notification callback.
74  *
75  * @param[in] qspip pointer to the @p QSPIDriver object triggering the
76  * callback
77  */
78 typedef void (*qspicallback_t)(QSPIDriver *qspip);
79 
80 /**
81  * @brief Driver configuration structure.
82  */
83 typedef struct {
84  /**
85  * @brief Operation complete callback or @p NULL.
86  */
88  /* End of the mandatory fields.*/
89 } QSPIConfig;
90 
91 /**
92  * @brief Structure representing an QSPI driver.
93  */
94 struct QSPIDriver {
95  /**
96  * @brief Driver state.
97  */
99  /**
100  * @brief Current configuration data.
101  */
103 #if (QSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
104  /**
105  * @brief Waiting thread.
106  */
108 #endif /* QSPI_USE_WAIT */
109 #if (QSPI_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
110  /**
111  * @brief Mutex protecting the peripheral.
112  */
114 #endif /* QSPI_USE_MUTUAL_EXCLUSION */
115 #if defined(QSPI_DRIVER_EXT_FIELDS)
116  QSPI_DRIVER_EXT_FIELDS
117 #endif
118  /* End of the mandatory fields.*/
119 };
120 
121 /*===========================================================================*/
122 /* Driver macros. */
123 /*===========================================================================*/
124 
125 /*===========================================================================*/
126 /* External declarations. */
127 /*===========================================================================*/
128 
129 #if (PLATFORM_QSPI_USE_QSPI1 == TRUE) && !defined(__DOXYGEN__)
130 extern QSPIDriver QSPID1;
131 #endif
132 
133 #ifdef __cplusplus
134 extern "C" {
135 #endif
136  void qspi_lld_init(void);
137  void qspi_lld_start(QSPIDriver *qspip);
138  void qspi_lld_stop(QSPIDriver *qspip);
139  void qspi_lld_command(QSPIDriver *qspip, const qspi_command_t *cmdp);
140  void qspi_lld_send(QSPIDriver *qspip, const qspi_command_t *cmdp,
141  size_t n, const uint8_t *txbuf);
142  void qspi_lld_receive(QSPIDriver *qspip, const qspi_command_t *cmdp,
143  size_t n, uint8_t *rxbuf);
144 #if QSPI_SUPPORTS_MEMMAP == TRUE
145  void qspi_lld_map_flash(QSPIDriver *qspip,
146  const qspi_command_t *cmdp,
147  uint8_t **addrp);
148  void qspi_lld_unmap_flash(QSPIDriver *qspip);
149 #endif
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* HAL_USE_QSPI */
155 
156 #endif /* HAL_QSPI_LLD_H */
157 
158 /** @} */
qspistate_t state
Driver state.
Definition: hal_qspi_lld.h:98
void qspi_lld_unmap_flash(QSPIDriver *qspip)
Unmaps from memory space a QSPI flash device.
Definition: hal_qspi_lld.c:200
void qspi_lld_receive(QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the QSPI bus.
Definition: hal_qspi_lld.c:160
qspicallback_t end_cb
Operation complete callback or NULL.
Definition: hal_qspi_lld.h:87
void qspi_lld_send(QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the QSPI bus.
Definition: hal_qspi_lld.c:140
void qspi_lld_command(QSPIDriver *qspip, const qspi_command_t *cmdp)
Sends a command without data phase.
Definition: hal_qspi_lld.c:123
void qspi_lld_init(void)
Low level QSPI driver initialization.
Definition: hal_qspi_lld.c:63
void qspi_lld_map_flash(QSPIDriver *qspip, const qspi_command_t *cmdp, uint8_t **addrp)
Maps in memory space a QSPI flash device.
Definition: hal_qspi_lld.c:182
void(* qspicallback_t)(QSPIDriver *qspip)
Type of a QSPI notification callback.
Definition: hal_qspi_lld.h:78
Driver configuration structure.
Definition: hal_qspi_lld.h:83
void qspi_lld_start(QSPIDriver *qspip)
Configures and activates the QSPI peripheral.
Definition: hal_qspi_lld.c:77
const QSPIConfig * config
Current configuration data.
Definition: hal_qspi_lld.h:102
mutex_t mutex
Mutex protecting the peripheral.
Definition: hal_qspi_lld.h:113
void * thread_reference_t
Type of a thread reference.
Definition: osal.h:180
thread_reference_t thread
Waiting thread.
Definition: hal_qspi_lld.h:107
Structure representing an QSPI driver.
Definition: hal_qspi_lld.h:94
void qspi_lld_stop(QSPIDriver *qspip)
Deactivates the QSPI peripheral.
Definition: hal_qspi_lld.c:99
uint32_t mutex_t
Type of a mutex.
Definition: osal.h:223
qspistate_t
Driver state machine possible states.
Definition: hal_qspi.h:113
QSPIDriver QSPID1
QSPID1 driver identifier.
Definition: hal_qspi_lld.c:39
Type of a QSPI command descriptor.
Definition: hal_qspi.h:125