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