2023-02-07 16:33:05 +00:00
|
|
|
#include <furi_hal_sd.h>
|
2021-05-18 09:23:14 +00:00
|
|
|
#include <stm32wbxx_ll_gpio.h>
|
|
|
|
#include <furi.h>
|
2022-03-30 15:23:40 +00:00
|
|
|
#include <furi_hal.h>
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
void hal_sd_detect_init(void) {
|
|
|
|
// low speed input with pullup
|
2023-02-07 16:33:05 +00:00
|
|
|
furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullUp, GpioSpeedLow);
|
2021-05-18 09:23:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hal_sd_detect_set_low(void) {
|
|
|
|
// low speed input with pullup
|
2023-02-07 16:33:05 +00:00
|
|
|
furi_hal_gpio_init_simple(&gpio_sdcard_cd, GpioModeOutputOpenDrain);
|
|
|
|
furi_hal_gpio_write(&gpio_sdcard_cd, 0);
|
2021-05-18 09:23:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool hal_sd_detect(void) {
|
2023-02-07 16:33:05 +00:00
|
|
|
bool result = !furi_hal_gpio_read(&gpio_sdcard_cd);
|
2021-05-18 09:23:14 +00:00
|
|
|
return result;
|
2021-11-30 12:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FuriHalSpiBusHandle* furi_hal_sd_spi_handle = NULL;
|