Skip to content

Commit 3cf1258

Browse files
committed
stm: sdioio: Get rid of debug code and useless comments
1 parent 6a99a7b commit 3cf1258

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

ports/stm/common-hal/sdioio/SDCard.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@
3535
#include "supervisor/shared/translate.h"
3636
#include "common-hal/microcontroller/Pin.h"
3737

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-
4838
STATIC bool reserved_sdio[MP_ARRAY_SIZE(mcu_sdio_banks)];
4939
STATIC bool never_reset_sdio[MP_ARRAY_SIZE(mcu_sdio_banks)];
5040

@@ -138,10 +128,7 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
138128

139129
GPIO_InitTypeDef GPIO_InitStruct = {0};
140130

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 */
145132
for (int i=0; i<num_data; i++) {
146133
GPIO_InitStruct.Pin = pin_mask(data[i]->number);
147134
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@@ -151,12 +138,12 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
151138
HAL_GPIO_Init(pin_port(data[i]->port), &GPIO_InitStruct);
152139
}
153140

154-
/* Configure PD.02 CMD line */
141+
/* Configure command pin */
155142
GPIO_InitStruct.Alternate = self->command->altfn_index;
156143
GPIO_InitStruct.Pin = pin_mask(command->number);
157144
HAL_GPIO_Init(pin_port(command->port), &GPIO_InitStruct);
158145

159-
/* Configure PC.12 pin: CLK pin */
146+
/* Configure clock */
160147
GPIO_InitStruct.Alternate = self->clock->altfn_index;
161148
GPIO_InitStruct.Pin = pin_mask(clock->number);
162149
HAL_GPIO_Init(pin_port(clock->port), &GPIO_InitStruct);
@@ -195,11 +182,9 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
195182
self->num_data = 1;
196183
if (num_data == 4) {
197184
if ((r = HAL_SD_ConfigWideBusOperation(&self->handle, SDIO_BUS_WIDE_4B)) == HAL_SD_ERROR_NONE) {
198-
DEBUG_PRINT("Switched bus to 4B mode\n");
199185
self->handle.Init.BusWide = SDIO_BUS_WIDE_4B;
200186
self->num_data = 4;
201187
} else {
202-
DEBUG_PRINT("WideBus_Enable returned %r, leaving at 1B mode\n", (int)r);
203188
}
204189
}
205190

@@ -216,11 +201,11 @@ uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self) {
216201
}
217202

218203
uint32_t common_hal_sdioio_sdcard_get_frequency(sdioio_sdcard_obj_t *self) {
219-
return self->frequency; // self->frequency;
204+
return self->frequency;
220205
}
221206

222207
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;
224209
}
225210

226211
STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
@@ -243,13 +228,6 @@ STATIC void wait_write_complete(sdioio_sdcard_obj_t *self) {
243228
}
244229
}
245230

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-
253231
STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) {
254232
if (common_hal_sdioio_sdcard_deinited(self)) {
255233
raise_deinited_error();
@@ -265,11 +243,8 @@ int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t sta
265243
HAL_StatusTypeDef r = HAL_SD_WriteBlocks(&self->handle, bufinfo->buf, start_block, bufinfo->len / 512, 1000);
266244
common_hal_mcu_enable_interrupts();
267245
if (r != HAL_OK) {
268-
debug_print_state(self, "after writeblocks error");
269246
return -EIO;
270247
}
271-
// debug_print_state(self, "after writeblocks OK");
272-
// debug_print_state(self, "after writeblocks complete");
273248
return 0;
274249
}
275250

@@ -281,7 +256,6 @@ int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t star
281256
HAL_StatusTypeDef r = HAL_SD_ReadBlocks(&self->handle, bufinfo->buf, start_block, bufinfo->len / 512, 1000);
282257
common_hal_mcu_enable_interrupts();
283258
if (r != HAL_OK) {
284-
debug_print_state(self, "after readblocks error");
285259
return -EIO;
286260
}
287261
return 0;

0 commit comments

Comments
 (0)