Skip to content

Commit 8078815

Browse files
iabdalkaderdpgeorge
authored andcommitted
stm32/sdio: Add functions to re/enable SDIO/SDIOIT.
1 parent 4d96786 commit 8078815

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ports/stm32/sdio.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ void sdio_deinit(void) {
9393
#endif
9494
}
9595

96+
void sdio_reenable(void) {
97+
if (__HAL_RCC_SDMMC1_IS_CLK_DISABLED()) {
98+
__HAL_RCC_SDMMC1_CLK_ENABLE(); // enable SDIO peripheral
99+
sdio_enable_high_speed_4bit();
100+
}
101+
}
102+
103+
void sdio_enable_irq(bool enable) {
104+
if (enable) {
105+
SDMMC1->MASK |= SDMMC_MASK_SDIOITIE;
106+
} else {
107+
SDMMC1->MASK &= ~SDMMC_MASK_SDIOITIE;
108+
}
109+
}
110+
96111
void sdio_enable_high_speed_4bit(void) {
97112
SDMMC_TypeDef *SDIO = SDMMC1;
98113
SDIO->POWER = 0; // power off

ports/stm32/sdio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
void sdio_init(uint32_t irq_pri);
3333
void sdio_deinit(void);
34+
void sdio_reenable(void);
35+
void sdio_enable_irq(bool enable);
3436
void sdio_enable_high_speed_4bit(void);
3537
int sdio_transfer(uint32_t cmd, uint32_t arg, uint32_t *resp);
3638
int sdio_transfer_cmd53(bool write, uint32_t block_size, uint32_t arg, size_t len, uint8_t *buf);

0 commit comments

Comments
 (0)