chore: cleanup sdcard (#5519)
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "diskio_spi.h"
|
||||
#include "stm32_gpio_driver.h"
|
||||
#include "stm32_gpio.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "sdcard_spi.h"
|
||||
|
||||
#include "hal.h"
|
||||
@@ -53,24 +55,8 @@ static const stm32_spi_t _sd_spi_hw = {
|
||||
|
||||
static uint32_t _sdcard_sectors;
|
||||
|
||||
static void _sd_present_gpio_init()
|
||||
{
|
||||
#if defined(SD_PRESENT_GPIO)
|
||||
LL_GPIO_InitTypeDef pinInit;
|
||||
LL_GPIO_StructInit(&pinInit);
|
||||
pinInit.Pin = SD_PRESENT_GPIO_PIN;
|
||||
pinInit.Mode = LL_GPIO_MODE_INPUT;
|
||||
pinInit.Pull = LL_GPIO_PULL_UP;
|
||||
|
||||
stm32_gpio_enable_clock(SD_PRESENT_GPIO);
|
||||
LL_GPIO_Init(SD_PRESENT_GPIO, &pinInit);
|
||||
#endif
|
||||
}
|
||||
|
||||
static DSTATUS sdcard_spi_initialize(BYTE lun)
|
||||
{
|
||||
_sd_present_gpio_init();
|
||||
|
||||
sdcard_info_t card_info;
|
||||
if (sdcard_spi_init(&_sd_spi_hw, &card_info) != SDCARD_SPI_OK) {
|
||||
return STA_NOINIT;
|
||||
@@ -86,7 +72,7 @@ static DSTATUS sdcard_spi_status(BYTE lun)
|
||||
DSTATUS stat = 0;
|
||||
|
||||
#if defined(SD_PRESENT_GPIO)
|
||||
if (LL_GPIO_IsInputPinSet(SD_PRESENT_GPIO, SD_PRESENT_GPIO_PIN)) {
|
||||
if (gpio_read(SD_PRESENT_GPIO)) {
|
||||
stat |= STA_NODISK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
void pwrInit()
|
||||
{
|
||||
#if defined(SD_PRESENT_GPIO)
|
||||
gpio_init(SD_PRESENT_GPIO, GPIO_IN_PU, GPIO_PIN_SPEED_LOW);
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_BOOTCMD_GPIO)
|
||||
gpio_init(INTMODULE_BOOTCMD_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_write(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_DEFAULT);
|
||||
|
||||
@@ -2610,13 +2610,12 @@
|
||||
#if defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS)
|
||||
// Using chip, so no detect
|
||||
#else
|
||||
#define SD_PRESENT_GPIO GPIOD
|
||||
#if defined(PCBXLITE) || defined(PCBX9LITE)
|
||||
#define SD_PRESENT_GPIO_PIN LL_GPIO_PIN_10 // PD.10
|
||||
#define SD_PRESENT_GPIO GPIO_PIN(GPIOD, 10) // PD.10
|
||||
#elif defined(RADIO_COMMANDO8)
|
||||
#define SD_PRESENT_GPIO_PIN LL_GPIO_PIN_8 // PD.08
|
||||
#define SD_PRESENT_GPIO GPIO_PIN(GPIOD, 8) // PD.08
|
||||
#else
|
||||
#define SD_PRESENT_GPIO_PIN LL_GPIO_PIN_9 // PD.09
|
||||
#define SD_PRESENT_GPIO GPIO_PIN(GPIOD, 9) // PD.09
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user