diff --git a/make/source.mk b/make/source.mk index c68b6b5a4..195b27ac0 100644 --- a/make/source.mk +++ b/make/source.mk @@ -64,8 +64,9 @@ COMMON_SRC = \ pg/bus_i2c.c \ pg/flash.c \ pg/max7456.c \ - pg/rx_pwm.c \ pg/pg.c \ + pg/rx_pwm.c \ + pg/sdcard.c \ scheduler/scheduler.c \ sensors/battery.c \ sensors/current.c \ diff --git a/src/main/cms/cms_menu_blackbox.c b/src/main/cms/cms_menu_blackbox.c index 67b94cb48..731bde0fa 100644 --- a/src/main/cms/cms_menu_blackbox.c +++ b/src/main/cms/cms_menu_blackbox.c @@ -41,10 +41,9 @@ #include "common/utils.h" #include "config/feature.h" -#include "pg/pg.h" -#include "pg/pg_ids.h" #include "drivers/time.h" +#include "drivers/sdcard.h" #include "fc/config.h" @@ -52,6 +51,8 @@ #include "io/flashfs.h" #include "io/beeper.h" +#include "pg/pg.h" + static const char * const cmsx_BlackboxDeviceNames[] = { "NONE", "FLASH ", diff --git a/src/main/drivers/sdcard.h b/src/main/drivers/sdcard.h index 1dca00444..8d7a5b232 100644 --- a/src/main/drivers/sdcard.h +++ b/src/main/drivers/sdcard.h @@ -20,10 +20,6 @@ #include #include -typedef struct sdcardConfig_s { - uint8_t useDma; -} sdcardConfig_t; - typedef struct sdcardMetadata_s { uint32_t numBlocks; /* Card capacity in 512-byte blocks*/ uint16_t oemID; diff --git a/src/main/fc/config.c b/src/main/fc/config.c index e1b967df5..3ee9b43ed 100644 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -50,7 +50,6 @@ #include "drivers/pwm_esc_detect.h" #include "drivers/pwm_output.h" #include "drivers/rx_spi.h" -#include "drivers/sdcard.h" #include "drivers/sensor.h" #include "drivers/sound_beeper.h" #include "drivers/system.h" @@ -142,15 +141,6 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig, ); #endif - -#ifdef USE_SDCARD -PG_REGISTER_WITH_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, PG_SDCARD_CONFIG, 0); - -PG_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, - .useDma = false -); -#endif // USE_SDCARD - // no template required since defaults are zero PG_REGISTER(vcdProfile_t, vcdProfile, PG_VCD_CONFIG, 0); diff --git a/src/main/fc/config.h b/src/main/fc/config.h index 6379e9121..99a2613fb 100644 --- a/src/main/fc/config.h +++ b/src/main/fc/config.h @@ -23,7 +23,6 @@ #include "pg/pg.h" #include "drivers/flash.h" -#include "drivers/sdcard.h" #include "drivers/serial.h" #include "drivers/bus_i2c.h" #include "drivers/sound_beeper.h" @@ -84,7 +83,6 @@ PG_DECLARE(pilotConfig_t, pilotConfig); PG_DECLARE(systemConfig_t, systemConfig); PG_DECLARE(beeperDevConfig_t, beeperDevConfig); PG_DECLARE(vcdProfile_t, vcdProfile); -PG_DECLARE(sdcardConfig_t, sdcardConfig); struct pidProfile_s; extern struct pidProfile_s *currentPidProfile; diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index b1917d71e..c83ae3de1 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -81,8 +81,8 @@ #include "pg/bus_i2c.h" #include "pg/flash.h" #include "pg/pg.h" -#include "pg/pg_ids.h" #include "pg/rx_pwm.h" +#include "pg/sdcard.h" #include "rx/rx.h" #include "rx/rx_spi.h" diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index f9c96fb7b..b650aba63 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -66,6 +66,7 @@ #include "pg/pg.h" #include "pg/pg_ids.h" #include "pg/rx_pwm.h" +#include "pg/sdcard.h" #include "rx/rx.h" #include "rx/cc2500_frsky_common.h" diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 44718deb2..4f7beed2b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -49,11 +49,10 @@ #include "common/utils.h" #include "config/feature.h" -#include "pg/pg.h" -#include "pg/pg_ids.h" #include "drivers/display.h" #include "drivers/max7456_symbols.h" +#include "drivers/sdcard.h" #include "drivers/time.h" #include "io/asyncfatfs/asyncfatfs.h" @@ -75,6 +74,9 @@ #include "flight/imu.h" #include "flight/pid.h" +#include "pg/pg.h" +#include "pg/pg_ids.h" + #include "rx/rx.h" #include "sensors/barometer.h" diff --git a/src/main/pg/sdcard.c b/src/main/pg/sdcard.c new file mode 100644 index 000000000..3e1d8c550 --- /dev/null +++ b/src/main/pg/sdcard.c @@ -0,0 +1,35 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include +#include + +#include "platform.h" + +#ifdef USE_SDCARD + +#include "pg/pg.h" +#include "pg/pg_ids.h" + +#include "sdcard.h" + +PG_REGISTER_WITH_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, PG_SDCARD_CONFIG, 0); + +PG_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig, + .useDma = false +); +#endif diff --git a/src/main/pg/sdcard.h b/src/main/pg/sdcard.h new file mode 100644 index 000000000..261003242 --- /dev/null +++ b/src/main/pg/sdcard.h @@ -0,0 +1,26 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#pragma once + +#include "pg/pg.h" + +typedef struct sdcardConfig_s { + uint8_t useDma; +} sdcardConfig_t; + +PG_DECLARE(sdcardConfig_t, sdcardConfig); diff --git a/src/main/target/MOTOLABF4/config.c b/src/main/target/MOTOLABF4/config.c index 4f5ce4820..7d7a2b7f9 100644 --- a/src/main/target/MOTOLABF4/config.c +++ b/src/main/target/MOTOLABF4/config.c @@ -23,7 +23,7 @@ #ifdef USE_TARGET_CONFIG #include "telemetry/telemetry.h" -#include "fc/config.h" +#include "pg/sdcard.h" void targetConfiguration(void) { diff --git a/src/main/target/SPRACINGF3EVO/config.c b/src/main/target/SPRACINGF3EVO/config.c index 5506ee186..470ddc417 100644 --- a/src/main/target/SPRACINGF3EVO/config.c +++ b/src/main/target/SPRACINGF3EVO/config.c @@ -21,11 +21,11 @@ #include "common/axis.h" -#include "fc/config.h" - #include "flight/mixer.h" #include "flight/pid.h" +#include "pg/sdcard.h" + #if defined(SPRACINGF3MQ) #ifdef BRUSHED_MOTORS_PWM_RATE