• R/O
  • SSH
  • HTTPS

chibios: 提交


Commit MetaInfo

修订版15834 (tree)
时间2022-11-14 01:39:14
作者gdisirio

Log Message

Completed mutual exclusion support.

更改概述

差异

--- trunk/os/hal/src/hal_mmc_spi.c (revision 15833)
+++ trunk/os/hal/src/hal_mmc_spi.c (revision 15834)
@@ -44,10 +44,17 @@
4444 /*===========================================================================*/
4545
4646 /* Forward declarations required by mmc_vmt.*/
47+static bool mmc_is_card_inserted(void *instance);
48+static bool mmc_is_write_protected(void *instance);
49+static bool mmc_connect(void *instance);
50+static bool mmc_disconnect(void *instance);
51+static bool mmc_connect(void *instance);
4752 static bool mmc_read(void *instance, uint32_t startblk,
4853 uint8_t *buffer, uint32_t n);
4954 static bool mmc_write(void *instance, uint32_t startblk,
5055 const uint8_t *buffer, uint32_t n);
56+static bool mmc_sync(void *instance);
57+static bool mmc_get_info(void *instance, BlockDeviceInfo *bdip);
5158
5259 /**
5360 * @brief Virtual methods table.
@@ -54,14 +61,14 @@
5461 */
5562 static const struct mmc_spi_driver_vmt mmc_vmt = {
5663 (size_t)0,
57- (bool (*)(void *))mmc_lld_is_card_inserted,
58- (bool (*)(void *))mmc_lld_is_write_protected,
59- (bool (*)(void *))mmcConnect,
60- (bool (*)(void *))mmcDisconnect,
64+ mmc_is_card_inserted,
65+ mmc_is_write_protected,
66+ mmc_connect,
67+ mmc_disconnect,
6168 mmc_read,
6269 mmc_write,
63- (bool (*)(void *))mmcSync,
64- (bool (*)(void *, BlockDeviceInfo *))mmcGetInfo
70+ mmc_sync,
71+ mmc_get_info
6572 };
6673
6774 /**
@@ -96,6 +103,74 @@
96103 /* Driver local functions. */
97104 /*===========================================================================*/
98105
106+static bool mmc_is_card_inserted(void *instance) {
107+ MMCDriver *mmcp = (MMCDriver *)instance;
108+ bool err;
109+
110+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
111+ spiAcquireBus(mmcp->config->spip);
112+#endif
113+
114+ err = mmcIsCardInserted(mmcp);
115+
116+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
117+ spiReleaseBus(mmcp->config->spip);
118+#endif
119+
120+ return err;
121+}
122+
123+static bool mmc_is_write_protected(void *instance) {
124+ MMCDriver *mmcp = (MMCDriver *)instance;
125+ bool err;
126+
127+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
128+ spiAcquireBus(mmcp->config->spip);
129+#endif
130+
131+ err = mmcIsCardInserted(mmcp);
132+
133+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
134+ spiReleaseBus(mmcp->config->spip);
135+#endif
136+
137+ return err;
138+}
139+
140+static bool mmc_connect(void *instance) {
141+ MMCDriver *mmcp = (MMCDriver *)instance;
142+ bool err;
143+
144+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
145+ spiAcquireBus(mmcp->config->spip);
146+#endif
147+
148+ err = mmcConnect(mmcp);
149+
150+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
151+ spiReleaseBus(mmcp->config->spip);
152+#endif
153+
154+ return err;
155+}
156+
157+static bool mmc_disconnect(void *instance) {
158+ MMCDriver *mmcp = (MMCDriver *)instance;
159+ bool err;
160+
161+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
162+ spiAcquireBus(mmcp->config->spip);
163+#endif
164+
165+ err = mmcDisconnect(mmcp);
166+
167+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
168+ spiReleaseBus(mmcp->config->spip);
169+#endif
170+
171+ return err;
172+}
173+
99174 static bool mmc_read(void *instance, uint32_t startblk,
100175 uint8_t *buffer, uint32_t n) {
101176 MMCDriver *mmcp = (MMCDriver *)instance;
@@ -168,6 +243,32 @@
168243 return err;
169244 }
170245
246+static bool mmc_sync(void *instance) {
247+ MMCDriver *mmcp = (MMCDriver *)instance;
248+ bool err;
249+
250+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
251+ spiAcquireBus(mmcp->config->spip);
252+#endif
253+
254+ err = mmcSync(mmcp);
255+
256+#if MMC_USE_MUTUAL_EXCLUSION == TRUE
257+ spiReleaseBus(mmcp->config->spip);
258+#endif
259+
260+ return err;
261+}
262+
263+static bool mmc_get_info(void *instance, BlockDeviceInfo *bdip) {
264+ MMCDriver *mmcp = (MMCDriver *)instance;
265+ bool err;
266+
267+ err = mmcGetInfo(mmcp, bdip);
268+
269+ return err;
270+}
271+
171272 /**
172273 * @brief Calculate the MMC standard CRC-7 based on a lookup table.
173274 *
Show on old repository browser