35
35
#include "supervisor/shared/translate.h"
36
36
#include "common-hal/microcontroller/Pin.h"
37
37
38
- #ifndef DEBUG_SDIO
39
- #define DEBUG_SDIO (0)
40
- #endif
41
-
42
- #if DEBUG_SDIO
43
- #define DEBUG_PRINT (...) ((void)mp_printf(&mp_plat_print, __VA_ARGS__))
44
- #else
45
- #define DEBUG_PRINT (...) ((void)0)
46
- #endif
47
-
48
38
STATIC bool reserved_sdio [MP_ARRAY_SIZE (mcu_sdio_banks )];
49
39
STATIC bool never_reset_sdio [MP_ARRAY_SIZE (mcu_sdio_banks )];
50
40
@@ -138,10 +128,7 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
138
128
139
129
GPIO_InitTypeDef GPIO_InitStruct = {0 };
140
130
141
- // /* GPIOC and GPIOD Periph clock enable */
142
- // RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | SD_DETECT_GPIO_CLK, ENABLE);
143
-
144
- /* Configure data PC.08, PC.09, PC.10, PC.11 pins: D0, D1, D2, D3 pins */
131
+ /* Configure data pins */
145
132
for (int i = 0 ; i < num_data ; i ++ ) {
146
133
GPIO_InitStruct .Pin = pin_mask (data [i ]-> number );
147
134
GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_VERY_HIGH ;
@@ -151,12 +138,12 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
151
138
HAL_GPIO_Init (pin_port (data [i ]-> port ), & GPIO_InitStruct );
152
139
}
153
140
154
- /* Configure PD.02 CMD line */
141
+ /* Configure command pin */
155
142
GPIO_InitStruct .Alternate = self -> command -> altfn_index ;
156
143
GPIO_InitStruct .Pin = pin_mask (command -> number );
157
144
HAL_GPIO_Init (pin_port (command -> port ), & GPIO_InitStruct );
158
145
159
- /* Configure PC.12 pin: CLK pin */
146
+ /* Configure clock */
160
147
GPIO_InitStruct .Alternate = self -> clock -> altfn_index ;
161
148
GPIO_InitStruct .Pin = pin_mask (clock -> number );
162
149
HAL_GPIO_Init (pin_port (clock -> port ), & GPIO_InitStruct );
@@ -195,11 +182,9 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
195
182
self -> num_data = 1 ;
196
183
if (num_data == 4 ) {
197
184
if ((r = HAL_SD_ConfigWideBusOperation (& self -> handle , SDIO_BUS_WIDE_4B )) == HAL_SD_ERROR_NONE ) {
198
- DEBUG_PRINT ("Switched bus to 4B mode\n" );
199
185
self -> handle .Init .BusWide = SDIO_BUS_WIDE_4B ;
200
186
self -> num_data = 4 ;
201
187
} else {
202
- DEBUG_PRINT ("WideBus_Enable returned %r, leaving at 1B mode\n" , (int )r );
203
188
}
204
189
}
205
190
@@ -216,11 +201,11 @@ uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self) {
216
201
}
217
202
218
203
uint32_t common_hal_sdioio_sdcard_get_frequency (sdioio_sdcard_obj_t * self ) {
219
- return self -> frequency ; // self->frequency;
204
+ return self -> frequency ;
220
205
}
221
206
222
207
uint8_t common_hal_sdioio_sdcard_get_width (sdioio_sdcard_obj_t * self ) {
223
- return self -> num_data ; // self->width;
208
+ return self -> num_data ;
224
209
}
225
210
226
211
STATIC void check_whole_block (mp_buffer_info_t * bufinfo ) {
@@ -243,13 +228,6 @@ STATIC void wait_write_complete(sdioio_sdcard_obj_t *self) {
243
228
}
244
229
}
245
230
246
- STATIC void debug_print_state (sdioio_sdcard_obj_t * self , const char * what ) {
247
- #if DEBUG_SDIO
248
- HAL_SD_CardStateTypedef st = HAL_SD_GetCardState (& self -> handle );
249
- DEBUG_PRINT ("%s, st=0x%x State=0x%x ErrorCode=0x%x\n" , what , (int )st , self -> handle .State , self -> handle .ErrorCode );
250
- #endif
251
- }
252
-
253
231
STATIC void check_for_deinit (sdioio_sdcard_obj_t * self ) {
254
232
if (common_hal_sdioio_sdcard_deinited (self )) {
255
233
raise_deinited_error ();
@@ -265,11 +243,8 @@ int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t sta
265
243
HAL_StatusTypeDef r = HAL_SD_WriteBlocks (& self -> handle , bufinfo -> buf , start_block , bufinfo -> len / 512 , 1000 );
266
244
common_hal_mcu_enable_interrupts ();
267
245
if (r != HAL_OK ) {
268
- debug_print_state (self , "after writeblocks error" );
269
246
return - EIO ;
270
247
}
271
- // debug_print_state(self, "after writeblocks OK");
272
- // debug_print_state(self, "after writeblocks complete");
273
248
return 0 ;
274
249
}
275
250
@@ -281,7 +256,6 @@ int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t star
281
256
HAL_StatusTypeDef r = HAL_SD_ReadBlocks (& self -> handle , bufinfo -> buf , start_block , bufinfo -> len / 512 , 1000 );
282
257
common_hal_mcu_enable_interrupts ();
283
258
if (r != HAL_OK ) {
284
- debug_print_state (self , "after readblocks error" );
285
259
return - EIO ;
286
260
}
287
261
return 0 ;
0 commit comments