2022-01-05 16:10:18 +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
|
|
|
|
LL_GPIO_SetPinMode(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_MODE_INPUT);
|
|
|
|
LL_GPIO_SetPinSpeed(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_SPEED_FREQ_LOW);
|
|
|
|
LL_GPIO_SetPinPull(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_PULL_UP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hal_sd_detect_set_low(void) {
|
|
|
|
// low speed input with pullup
|
|
|
|
LL_GPIO_SetPinMode(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_MODE_OUTPUT);
|
|
|
|
LL_GPIO_SetPinOutputType(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_OUTPUT_OPENDRAIN);
|
|
|
|
LL_GPIO_ResetOutputPin(SD_CD_GPIO_Port, SD_CD_Pin);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hal_sd_detect(void) {
|
|
|
|
bool result = !(LL_GPIO_IsInputPinSet(SD_CD_GPIO_Port, SD_CD_Pin));
|
|
|
|
return result;
|
2021-11-30 12:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FuriHalSpiBusHandle* furi_hal_sd_spi_handle = NULL;
|