ChibiOS/HAL  7.0.3
hal_wspi_lld.c
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_wspi_lld.c
19  * @brief PLATFORM WSPI subsystem low level driver source.
20  *
21  * @addtogroup WSPI
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_WSPI == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /** @brief WSPID1 driver identifier.*/
38 #if (PLATFORM_WSPI_USE_WSPI1 == TRUE) || defined(__DOXYGEN__)
40 #endif
41 
42 /*===========================================================================*/
43 /* Driver local variables and types. */
44 /*===========================================================================*/
45 
46 /*===========================================================================*/
47 /* Driver local functions. */
48 /*===========================================================================*/
49 
50 /*===========================================================================*/
51 /* Driver interrupt handlers. */
52 /*===========================================================================*/
53 
54 /*===========================================================================*/
55 /* Driver exported functions. */
56 /*===========================================================================*/
57 
58 /**
59  * @brief Low level WSPI driver initialization.
60  *
61  * @notapi
62  */
63 void wspi_lld_init(void) {
64 
65 #if PLATFORM_WSPI_USE_WSPI1
66  wspiObjectInit(&WSPID1);
67 #endif
68 }
69 
70 /**
71  * @brief Configures and activates the WSPI peripheral.
72  *
73  * @param[in] wspip pointer to the @p WSPIDriver object
74  *
75  * @notapi
76  */
77 void wspi_lld_start(WSPIDriver *wspip) {
78 
79  /* If in stopped state then full initialization.*/
80  if (wspip->state == WSPI_STOP) {
81 #if PLATFORM_WSPI_USE_WSPI1
82  if (&WSPID1 == wspip) {
83  }
84 #endif
85 
86  /* Common initializations.*/
87  }
88 
89  /* WSPI setup and enable.*/
90 }
91 
92 /**
93  * @brief Deactivates the WSPI peripheral.
94  *
95  * @param[in] wspip pointer to the @p WSPIDriver object
96  *
97  * @notapi
98  */
99 void wspi_lld_stop(WSPIDriver *wspip) {
100 
101  /* If in ready state then disables WSPI.*/
102  if (wspip->state == WSPI_READY) {
103 
104  /* WSPI disable.*/
105 
106  /* Stopping involved clocks.*/
107 #if PLATFORM_WSPI_USE_WSPI1
108  if (&WSPID1 == wspip) {
109  }
110 #endif
111  }
112 }
113 
114 /**
115  * @brief Sends a command without data phase.
116  * @post At the end of the operation the configured callback is invoked.
117  *
118  * @param[in] wspip pointer to the @p WSPIDriver object
119  * @param[in] cmdp pointer to the command descriptor
120  *
121  * @notapi
122  */
123 void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) {
124 
125  (void)wspip;
126  (void)cmdp;
127 }
128 
129 /**
130  * @brief Sends a command with data over the WSPI bus.
131  * @post At the end of the operation the configured callback is invoked.
132  *
133  * @param[in] wspip pointer to the @p WSPIDriver object
134  * @param[in] cmdp pointer to the command descriptor
135  * @param[in] n number of bytes to send
136  * @param[in] txbuf the pointer to the transmit buffer
137  *
138  * @notapi
139  */
140 void wspi_lld_send(WSPIDriver *wspip, const wspi_command_t *cmdp,
141  size_t n, const uint8_t *txbuf) {
142 
143  (void)wspip;
144  (void)cmdp;
145  (void)n;
146  (void)txbuf;
147 }
148 
149 /**
150  * @brief Sends a command then receives data over the WSPI bus.
151  * @post At the end of the operation the configured callback is invoked.
152  *
153  * @param[in] wspip pointer to the @p WSPIDriver object
154  * @param[in] cmdp pointer to the command descriptor
155  * @param[in] n number of bytes to send
156  * @param[out] rxbuf the pointer to the receive buffer
157  *
158  * @notapi
159  */
160 void wspi_lld_receive(WSPIDriver *wspip, const wspi_command_t *cmdp,
161  size_t n, uint8_t *rxbuf) {
162 
163  (void)wspip;
164  (void)cmdp;
165  (void)n;
166  (void)rxbuf;
167 }
168 
169 #if (WSPI_SUPPORTS_MEMMAP == TRUE) || defined(__DOXYGEN__)
170 /**
171  * @brief Maps in memory space a WSPI flash device.
172  * @pre The memory flash device must be initialized appropriately
173  * before mapping it in memory space.
174  *
175  * @param[in] wspip pointer to the @p WSPIDriver object
176  * @param[in] cmdp pointer to the command descriptor
177  * @param[out] addrp pointer to the memory start address of the mapped
178  * flash or @p NULL
179  *
180  * @notapi
181  */
183  const wspi_command_t *cmdp,
184  uint8_t **addrp) {
185 
186  (void)wspip;
187  (void)cmdp;
188  (void)addrp;
189 }
190 
191 /**
192  * @brief Unmaps from memory space a WSPI flash device.
193  * @post The memory flash device must be re-initialized for normal
194  * commands exchange.
195  *
196  * @param[in] wspip pointer to the @p WSPIDriver object
197  *
198  * @notapi
199  */
201 
202  (void)wspip;
203 }
204 #endif /* WSPI_SUPPORTS_MEMMAP == TRUE */
205 
206 #endif /* HAL_USE_WSPI */
207 
208 /** @} */
void wspi_lld_unmap_flash(WSPIDriver *wspip)
Unmaps from memory space a WSPI flash device.
Definition: hal_wspi_lld.c:200
void wspi_lld_start(WSPIDriver *wspip)
Configures and activates the WSPI peripheral.
Definition: hal_wspi_lld.c:77
Structure representing an WSPI driver.
Definition: hal_wspi.h:150
HAL subsystem header.
void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
Definition: hal_wspi_lld.c:123
void wspi_lld_send(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the WSPI bus.
Definition: hal_wspi_lld.c:140
void wspi_lld_init(void)
Low level WSPI driver initialization.
Definition: hal_wspi_lld.c:63
void wspiObjectInit(WSPIDriver *wspip)
Initializes the standard part of a WSPIDriver structure.
Definition: hal_wspi.c:68
wspistate_t state
Driver state.
Definition: hal_wspi.h:154
void wspi_lld_receive(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the WSPI bus.
Definition: hal_wspi_lld.c:160
void wspi_lld_stop(WSPIDriver *wspip)
Deactivates the WSPI peripheral.
Definition: hal_wspi_lld.c:99
Type of a WSPI command descriptor.
Definition: hal_wspi.h:100
void wspi_lld_map_flash(WSPIDriver *wspip, const wspi_command_t *cmdp, uint8_t **addrp)
Maps in memory space a WSPI flash device.
Definition: hal_wspi_lld.c:182
WSPIDriver WSPID1
WSPID1 driver identifier.
Definition: hal_wspi_lld.c:39