sd detect pin feature (#222)

* test sd detect pin
* sd detect support for f2 board
This commit is contained in:
DrZlo13 2020-11-11 09:17:53 +03:00 committed by GitHub
parent 748f7e4fc3
commit 49fdb28871
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 46 additions and 5 deletions

View File

@ -51,6 +51,13 @@ void fatfs_list(void* p) {
furi_log = get_default_log(); furi_log = get_default_log();
fuprintf(furi_log, "[fatfs_list] app start\n"); fuprintf(furi_log, "[fatfs_list] app start\n");
fuprintf(furi_log, "[fatfs_list] wait for sd insert\n");
while(!hal_gpio_read_sd_detect()) {
delay(100);
}
fuprintf(furi_log, "[fatfs_list] sd inserted\n");
FuriRecordSubscriber* fb_record = FuriRecordSubscriber* fb_record =
furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL); furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL);

View File

@ -2,6 +2,7 @@ PROJECT_ROOT = $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST))))..)
PROJECT = bootloader PROJECT = bootloader
include $(PROJECT_ROOT)/make/base.mk include $(PROJECT_ROOT)/make/base.mk
include $(PROJECT_ROOT)/make/git.mk
CFLAGS += -Itargets/include CFLAGS += -Itargets/include
ASM_SOURCES += $(wildcard src/*.s) ASM_SOURCES += $(wildcard src/*.s)

View File

@ -7,6 +7,7 @@ CPPFLAGS += -Werror
include $(PROJECT_ROOT)/make/base.mk include $(PROJECT_ROOT)/make/base.mk
include $(PROJECT_ROOT)/assets/assets.mk include $(PROJECT_ROOT)/assets/assets.mk
include $(PROJECT_ROOT)/core/core.mk include $(PROJECT_ROOT)/core/core.mk
include $(PROJECT_ROOT)/make/git.mk
include $(PROJECT_ROOT)/applications/applications.mk include $(PROJECT_ROOT)/applications/applications.mk
include $(PROJECT_ROOT)/lib/lib.mk include $(PROJECT_ROOT)/lib/lib.mk

View File

@ -12,3 +12,7 @@ void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed)
HAL_GPIO_Init(gpio->port, &GPIO_InitStruct); HAL_GPIO_Init(gpio->port, &GPIO_InitStruct);
} }
bool hal_gpio_read_sd_detect(void) {
return true;
}

View File

@ -59,3 +59,5 @@ static inline bool hal_gpio_read(const GpioPin* gpio) {
return false; return false;
} }
} }
bool hal_gpio_read_sd_detect(void);

View File

@ -1,4 +1,5 @@
#include "api-hal-gpio.h" #include "api-hal-gpio.h"
#include "api-hal-resources.h"
// init GPIO // init GPIO
void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed) { void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed) {
@ -12,3 +13,24 @@ void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed)
HAL_GPIO_Init(gpio->port, &GPIO_InitStruct); HAL_GPIO_Init(gpio->port, &GPIO_InitStruct);
} }
bool hal_gpio_read_sd_detect(void) {
bool result = false;
// create pin
GpioPin sd_cs_pin = sd_cs_gpio;
// TODO open record
GpioPin* sd_cs_record = &sd_cs_pin;
// configure pin as input
gpio_init_ex(sd_cs_record, GpioModeInput, GpioPullUp, GpioSpeedVeryHigh);
delay(50);
// if gpio_read == 0 return true else return false
result = !gpio_read(sd_cs_record);
// configure pin back
gpio_init_ex(sd_cs_record, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
delay(50);
return result;
}

View File

@ -59,3 +59,5 @@ static inline bool hal_gpio_read(const GpioPin* gpio) {
return false; return false;
} }
} }
bool hal_gpio_read_sd_detect(void);

View File

@ -25,3 +25,4 @@ const GpioPin led_gpio[3] = {
{LED_BLUE_GPIO_Port, LED_BLUE_Pin}}; {LED_BLUE_GPIO_Port, LED_BLUE_Pin}};
const GpioPin backlight_gpio = {DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin}; const GpioPin backlight_gpio = {DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin};
const GpioPin sd_cs_gpio = {SD_CS_GPIO_Port, SD_CS_Pin};

View File

@ -10,3 +10,4 @@ extern const bool input_invert[GPIO_INPUT_PINS_COUNT];
extern const GpioPin led_gpio[3]; extern const GpioPin led_gpio[3];
extern const GpioPin backlight_gpio; extern const GpioPin backlight_gpio;
extern const GpioPin sd_cs_gpio;