furi_hal_sd.c 597 B

12345678910111213141516171819202122
  1. #include <furi_hal_sd.h>
  2. #include <stm32wbxx_ll_gpio.h>
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. void hal_sd_detect_init(void) {
  6. // low speed input with pullup
  7. furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullUp, GpioSpeedLow);
  8. }
  9. void hal_sd_detect_set_low(void) {
  10. // low speed input with pullup
  11. furi_hal_gpio_init_simple(&gpio_sdcard_cd, GpioModeOutputOpenDrain);
  12. furi_hal_gpio_write(&gpio_sdcard_cd, 0);
  13. }
  14. bool hal_sd_detect(void) {
  15. bool result = !furi_hal_gpio_read(&gpio_sdcard_cd);
  16. return result;
  17. }
  18. FuriHalSpiBusHandle* furi_hal_sd_spi_handle = NULL;