AP_BoardConfig: added BRD_SD_SLOWDOWN parameter

allows for reduction in microSD clock speed
This commit is contained in:
Andrew Tridgell 2018-12-28 12:06:12 +11:00
parent 85c3ef229d
commit 274dc0b9bd
2 changed files with 37 additions and 1 deletions

View File

@ -223,6 +223,16 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
// @Path: ../AP_RTC/AP_RTC.cpp // @Path: ../AP_RTC/AP_RTC.cpp
AP_SUBGROUPINFO(rtc, "RTC", 14, AP_BoardConfig, AP_RTC), AP_SUBGROUPINFO(rtc, "RTC", 14, AP_BoardConfig, AP_RTC),
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
// @Param: SD_SLOWDOWN
// @DisplayName: microSD slowdown
// @Description: This is a scaling factor to slow down microSD operation. It can be used on flight board and microSD card combinations where full speed is not reliable. For normal full speed operation a value of 0 should be used.
// @Range: 0 32
// @Increment: 1
// @User: Advanced
AP_GROUPINFO("SD_SLOWDOWN", 17, AP_BoardConfig, _sdcard_slowdown, 0),
#endif
AP_GROUPEND AP_GROUPEND
}; };
@ -238,6 +248,23 @@ void AP_BoardConfig::init()
#endif #endif
AP::rtc().set_utc_usec(hal.util->get_hw_rtc(), AP_RTC::SOURCE_HW); AP::rtc().set_utc_usec(hal.util->get_hw_rtc(), AP_RTC::SOURCE_HW);
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS && defined(USE_POSIX)
uint8_t slowdown = constrain_int16(_sdcard_slowdown.get(), 0, 32);
const uint8_t max_slowdown = 8;
do {
if (hal.util->fs_init()) {
break;
}
slowdown++;
hal.scheduler->delay(5);
} while (slowdown < max_slowdown);
if (slowdown < max_slowdown) {
_sdcard_slowdown.set(slowdown);
} else {
printf("SDCard failed to start\n");
}
#endif
} }
// set default value for BRD_SAFETY_MASK // set default value for BRD_SAFETY_MASK

View File

@ -149,7 +149,12 @@ public:
#endif #endif
} }
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
static uint8_t get_sdcard_slowdown(void) {
return instance?instance->_sdcard_slowdown.get():0;
}
#endif
private: private:
static AP_BoardConfig *instance; static AP_BoardConfig *instance;
@ -216,4 +221,8 @@ private:
// real-time-clock; private because access is via the singleton // real-time-clock; private because access is via the singleton
AP_RTC rtc; AP_RTC rtc;
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
AP_Int8 _sdcard_slowdown;
#endif
}; };