Skip to content

Commit

Permalink
sdcard: reset looptime during init
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Feb 9, 2025
1 parent a923a25 commit 2855a61
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/driver/blackbox/sdcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>

#include "core/project.h"
#include "core/scheduler.h"
#include "driver/spi.h"
#include "driver/time.h"
#include "util/util.h"
Expand Down Expand Up @@ -304,6 +305,7 @@ sdcard_status_t sdcard_update() {
spi_make_seg_buffer(NULL, buf, 20),
};
spi_seg_submit_continue(&bus, segs);
task_reset_runtime();

state = SDCARD_RESET;
delay_loops = 100;
Expand All @@ -314,6 +316,7 @@ sdcard_status_t sdcard_update() {
case SDCARD_RESET: {
static uint32_t tries = 0;

task_reset_runtime();
uint8_t ret = sdcard_command(SDCARD_GO_IDLE, 0);
if (ret == 0x01) {
state = SDCARD_DETECT_INTERFACE;
Expand All @@ -329,6 +332,8 @@ sdcard_status_t sdcard_update() {
break;
}
case SDCARD_DETECT_INTERFACE: {
task_reset_runtime();

uint8_t ret = sdcard_command(SDCARD_IF_COND, 0x1AA);
if (ret == SDCARD_R1_IDLE) {
uint32_t voltage_check = sdcard_read_response();
Expand All @@ -351,6 +356,8 @@ sdcard_status_t sdcard_update() {
break;
}
case SDCARD_DETECT_INIT: {
task_reset_runtime();

uint8_t ret = sdcard_app_command(SDCARD_ACMD_OD_COND, sdcard_info.version == 2 ? (1 << 30) : 0);
if (ret == 0x0) {
state = SDCARD_DETECT_READ_INFO;
Expand All @@ -359,6 +366,8 @@ sdcard_status_t sdcard_update() {
}

case SDCARD_DETECT_READ_INFO: {
task_reset_runtime();

uint8_t ret = sdcard_command(SDCARD_OCR, 0);
if (ret != 0x0) {
state = SDCARD_DETECT_FAILED;
Expand Down Expand Up @@ -389,6 +398,8 @@ sdcard_status_t sdcard_update() {

case SDCARD_DETECT_FINISH: {
if (!sdcard_info.high_capacity) {
task_reset_runtime();

uint8_t ret = sdcard_command(SDACARD_SET_BLOCK_LEN, SDCARD_PAGE_SIZE);
if (ret != 0x0) {
state = SDCARD_DETECT_FAILED;
Expand Down

0 comments on commit 2855a61

Please sign in to comment.